Skip to main content

Step 1: Get Your API Key

Visit the API Keys Management Page to create your API key.
  1. Log in to your SinanCode account
  2. Navigate to Dashboard → API Keys
  3. Click “Create New Key”
  4. Save the generated API Key (keep it secure, it’s only shown once)

Step 2: Make an API Request

All API requests require authentication in the HTTP Header:

Basic Request Example

Here’s a complete example of generating an image using Imagen4:
Response Example:

Step 3: Check Task Status

Since AI model generation takes time, most APIs work asynchronously. Use the returned task_id to check the task status:
Response Example:

Task Status Descriptions

  • pending - Task is queued
  • processing - Generation in progress
  • completed - Generation completed
  • failed - Generation failed

Image Generation Models

Imagen 4

  • Endpoint: POST /generate/k/imagen4
  • Features: Google’s latest image generation model with excellent quality
  • Parameters: prompt, aspect_ratio, num_images, seed

Midjourney

  • Endpoint: POST /generate/k/midjourney-txt2img
  • Features: Strong artistic style, ideal for creative design
  • Parameters: prompt, aspectRatio, version, stylization

Flux Kontext

  • Endpoint: POST /generate/k/flux-kontext
  • Features: Supports Chinese prompts with automatic translation
  • Parameters: prompt, aspect_ratio, model, enable_translation

Video Generation Models

Sora 2

  • Endpoint: POST /generate/k/sora2-text-to-video
  • Features: OpenAI’s video generation model
  • Parameters: prompt, aspect_ratio, n_frames

Veo 3

  • Endpoint: POST /generate/k/veo3-text-to-video
  • Features: Google’s video generation model with image-to-video support
  • Parameters: prompt, aspectRatio, model

Complete Code Examples

Python Example

JavaScript/TypeScript Example

Next Steps

Frequently Asked Questions

How do I choose the right model?

  • For Quality: Imagen 4 Ultra, Midjourney v7
  • For Speed: Imagen 4 Fast, Nano Banana
  • For Chinese Prompts: Flux Kontext, Tongyi Wanxiang
  • For Video Generation: Sora 2 Pro, Veo 3

What are the rate limits?

Each API Key has rate limits depending on your subscription plan. When limits are exceeded, you’ll receive a 429 Too Many Requests error. Need help? Visit sinancode.com to contact our technical support team.