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_edit_3_0_i2i
prompt string required
Prompt for editing the image
Recommendations:
- Recommended length 120 characters or less, maximum 800 characters. Prompts that are too long may cause abnormal output or not take effect
- Use natural language for editing instructions
- Single instruction per edit works better
- For partial editing, describe precisely who to do what, especially when there are multiple entities in the image
- If the editing effect is not obvious, adjust the scale value. Higher values follow instructions more closely
- Use clear, high-resolution base images. Anime and images generated by Doubao model have better editing effects
Example instructions:
- Add/Remove entity: Add/Remove xxx (Remove the girl from the image / Add a rainbow)
- Modify entity: Change xxx to xxx (Change the drumstick in hand to a hamburger)
- Modify style: Change to xxx style (Change to comic style)
- Modify color: Change xxx to xx color (Change the clothes to pink)
- Modify action: Modify expression/action (Make him cry/smile/angry)
- Modify background: Change background to xxx (Change background to beach / Under the starry sky)
Default: "" (empty string)
image string required
Image file URL or Base64 encoding. This algorithm requires 1 input image
size string
Output image size, format like 1024x1024
seed integer
Random seed as the basis for determining the initial state of diffusion
If the random seed is the same positive integer and all other parameters are consistent, the generated image will have a very high probability of consistent results
Default: -1 (random)
scale number
Affects the degree of text description influence. Higher values mean greater text description influence and less input image influence
Range: 0 - 1
Default: 0.5
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 image content
type
stringResource type
Value:
imageurl
stringImage URL
size
integerImage size (bytes)
b64_json
stringBase64 encoded image data (only when response_format is
b64_json)
usage object
Usage statistics. Only present when status is completed
input_tokens
integerInput tokens
output_tokens
integerOutput tokens
total_tokens
integerTotal tokens
metadata object
Metadata information
Error Codes
| Error Code | Description |
|---|---|
| 3014001 | Missing model |
| 3014002 | Missing prompt |
| 3014003 | Missing image |
| 3014004 | Invalid prompt length |
| 3014005 | Invalid image format |
| 3014006 | Invalid image size |
| 3014007 | Invalid size parameter |
| 3014008 | Invalid seed parameter |
| 3014009 | Invalid guidance strength |
| 3014010 | Invalid response format |
| 3014095 | Internal generation error |
| 3014096 | Result parsing error |
| 3014097 | HTTP error response |
| 3014098 | Status check error |
| 3014099 | Task creation error / Service unavailable |