⌘K

Spark Image 3.1

spark_image_3_1

Enhanced image generation with stronger detail rendering, richer color depth, and refined style control for higher-quality visuals.

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 integer

Error code

error_message string

Detailed error message


output array

Generation results. Only present when status is completed

content array

List of generated image content

type string

Resource type. Value: image

url string

Generated image URL

size integer

File size in bytes

jobId string

Remote job ID


usage object

Usage statistics. Only present when status is completed

cost string

Total cost in USD

discount number

Discount amount

input_tokens integer

Number of input tokens (this model does not provide this information, fixed at 0)

output_tokens integer

Number of output tokens (this model does not provide this information, fixed at 0)

total_tokens integer

Total number of tokens (uses comfyui_cost)

generated_images integer

Number of generated images


Error Codes

Error CodeDescription
003002001Prompt missing
003002002Invalid prompt length
003002003Invalid use_pre_llm parameter
003002004Invalid seed parameter
003002005Invalid dimension parameter
003002006Invalid aspect ratio
003002007Missing width/height parameter
003002008Invalid width/height parameter type
003002009Invalid width/height parameter range
003002095Internal generation error
003002096Result parsing error
003002097HTTP error response
003002098Status check error
003002099Service unavailable