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_t2i_3_0
prompt string required
Text prompt for generating the image. Supports both Chinese and English
Recommended length: ≤120 characters, maximum 800 characters. Excessively long prompts may cause abnormal generation or no effect
use_pre_llm boolean
Enable text expansion. When enabled, the input prompt will be expanded and optimized. Recommended to enable for shorter prompts, and disable for longer prompts
Default: true
seed integer
Random seed used to determine the initial state of diffusion. If the seed is the same positive integer and all other parameters are identical, the generated images will have a very high probability of being consistent
Default: -1 (random)
width integer
Width of the generated image
Supports custom width and height with aspect ratio between 1:3 and 3:1, and total pixels between [512×512, 2048×2048]
Recommended aspect ratios:
Standard 1K:
1328 × 1328 (1:1)
1472 × 1104 (4:3)
1584 × 1056 (3:2)
1664 × 936 (16:9)
2016 × 864 (21:9)
High Definition 2K:
2048 × 2048 (1:1)
2304 × 1728 (4:3)
2496 × 1664 (3:2)
2560 × 1440 (16:9)
3024 × 1296 (21:9)
Both width and height must be provided together to take effect
Default: 1328
height integer
Height of the generated image
Supports custom width and height with aspect ratio between 1:3 and 3:1, and total pixels between [512×512, 2048×2048]
Both width and height must be provided together to take effect
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
integerError code
error_message
stringDetailed error message
output array
Generation results. Only present when status is completed
content
arrayList of generated image content
type
stringResource type. Value:
imageurl
stringGenerated image URL
size
integerFile size in bytes
jobId
stringRemote job ID
usage object
Usage statistics. Only present when status is completed
cost
stringTotal cost in USD
discount
numberDiscount amount
input_tokens
integerNumber of input tokens
output_tokens
integerNumber of output tokens
total_tokens
integerTotal number of tokens
Error Codes
| Error Code | Description |
|---|---|
| 003001001 | Missing prompt |
| 003001002 | Invalid prompt length (1-800 characters) |
| 003001003 | Invalid use_pre_llm parameter |
| 003001004 | Invalid seed parameter (must be -1 or positive integer) |
| 003001005 | Invalid size parameter |
| 003001006 | Invalid aspect ratio (must be between 1:3 and 3:1) |
| 003001007 | Width and height must both be provided |
| 003001008 | Width and height must be integers |
| 003001009 | Width and height must be in 512-2048 range |
| 003001095 | Internal generation error |
| 003001096 | Result parsing error |
| 003001097 | HTTP error response |
| 003001098 | Status check error |
| 003001099 | Task creation error |