API Tips
Input images must meet the following requirements:
Supported formats: JPEG, PNG only (JPEG format recommended)
File size: Maximum 4.7 MB
Image resolution: Maximum 4096 * 4096
Aspect ratio: Recommended range 16:9 to 9:16 (extreme aspect ratios may have poor results and may cause errors)
Subject requirement: Strongly recommend uploading single subject (supported types include realistic portraits, cartoon/anime characters, animals, and other objects). Multiple subjects significantly reduce quality and may cause errors
Authentication
authorization string required
All APIs require authentication via Bearer Token.
Get API Key:
Visit API Key Management Page to get your API Key.
Usage:
Add to request header:
Authorization: Bearer YOUR_API_KEY
Parameters
model string required
Model ID to use for the request
Value: spark_dreamo
prompt string required
Prompt for image editing, supports both Chinese and English
Recommended length around 300 characters. Prompts that are too long may not take effect and may cause errors
image_urls array required (one of two)
Image file URLs (must be publicly accessible). Requires exactly 1 input image
Either image_urls or binary_data_base64 must be provided (one of two)
binary_data_base64 array required (one of two)
Image files in Base64 encoding. Requires exactly 1 input image
Either image_urls or binary_data_base64 must be provided (one of two)
seed integer
Random seed as the basis for determining the initial diffusion state. If the random seed is the same positive integer and other parameters are consistent, the generated content will most likely have consistent results
Default: -1 (random)
use_rephraser boolean
Whether to rephrase the input text prompt to optimize results. It is recommended to keep this enabled under normal conditions
If the input text is very long, or you have a strong requirement not to change the prompt content, or you want to reduce processing time, you can disable this parameter
Default: true
width integer
Width of the generated image
Exceeding the upper limit requires ensuring width * height product is less than 2048 * 2048, and may cause abnormal results or timeout issues
Recommended ratios and corresponding dimensions (width * height):
1:1: 1328 * 1328
4:3: 1472 * 1104
3:2: 1584 * 1056
16:9: 1664 * 936
21:9: 2016 * 864
Range: 512-2048
Default: 1328
height integer
Height of the generated image
Exceeding the upper limit requires ensuring width * height product is less than 2048 * 2048, and may cause abnormal results or timeout issues
Range: 512-2048
Default: 1328
Polling
Since image generation takes time, you need to poll the task status after creation
The initial response returns the task ID and initial status. The actual generation results must be obtained through polling the task status endpoint
Response Format
error object
Error information. Only present when status is failed
code
stringError code
error_message
stringDetailed error message
output array
Generation results. Only present when status is completed
content
arrayList of generated content
type
stringResource type
Value:
imageurl
stringContent URL
size
integerImage size in bytes
jobId
stringJob ID
usage object
Usage statistics. Only present when status is completed
cost
stringTotal cost in USD
discount
numberDiscount amount
metadata object
Metadata information
Error Codes
| Error Code | Description |
|---|---|
| 003011001 | Missing prompt |
| 003011002 | Missing image |
| 003011003 | Invalid prompt length |
| 003011004 | Invalid parameter |
| 003011095 | Internal generation error |
| 003011096 | Result parsing error |
| 003011097 | HTTP error response |
| 003011098 | Status check error |
| 003011099 | Task creation error |