Step 1: Get Your API Key
Visit the API Keys Management Page to create your API key.- Log in to your SinanCode account
- Navigate to Dashboard → API Keys
- Click “Create New Key”
- 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:Step 3: Check Task Status
Since AI model generation takes time, most APIs work asynchronously. Use the returnedtask_id to check the task status:
Task Status Descriptions
pending- Task is queuedprocessing- Generation in progresscompleted- Generation completedfailed- Generation failed
Popular Models Quick Reference
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
- 📖 View Full API Documentation - Learn about all available models and parameters
- 💰 Check Credit Usage - Use the
/calculate-credits/{model}endpoint to estimate costs - 🔔 Configure Webhooks - Get automatic notifications when tasks complete
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 a429 Too Many Requests error.