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_image_3_1
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 (this model does not provide this information, fixed at 0)
output_tokens
integerNumber of output tokens (this model does not provide this information, fixed at 0)
total_tokens
integerTotal number of tokens (uses comfyui_cost)
generated_images
integerNumber of generated images
Error Codes
| Error Code | Description |
|---|---|
| 003002001 | Prompt missing |
| 003002002 | Invalid prompt length |
| 003002003 | Invalid use_pre_llm parameter |
| 003002004 | Invalid seed parameter |
| 003002005 | Invalid dimension parameter |
| 003002006 | Invalid aspect ratio |
| 003002007 | Missing width/height parameter |
| 003002008 | Invalid width/height parameter type |
| 003002009 | Invalid width/height parameter range |
| 003002095 | Internal generation error |
| 003002096 | Result parsing error |
| 003002097 | HTTP error response |
| 003002098 | Status check error |
| 003002099 | Service unavailable |