Image Generation
Image generation is a synchronous endpoint: a single request returns the result data[] directly. Both text-to-image and image-to-image (with reference images) are supported.
POST https://api.smartapi.cc/api/openapi/v1/generate/image/generationsAuthentication#
Authorization: Bearer sk-your-key-here
Content-Type: application/jsonRequest Body#
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model id, e.g. wan2.5-image, gpt-image-2. |
prompt | string | Yes | Text prompt. |
files | array | No | Reference images (image-to-image); each has file_uri and mime_type. |
| provider config | object | No | Provider-specific config block, see table below. |
Different providers accept different config blocks (match the model’s provider; send only one):
| Provider | Config field | Options |
|---|---|---|
| QWEN | qwenConfig | size, n, prompt_extend |
| DOUBAO | doubaoConfig | size, seed, guidance_scale, n |
| GEMINI | geminiConfig | aspect_ratio, resolution |
| AZURE | azureConfig | size, quality (low/medium/high), n |
To see which config block each model needs and the valid values (sizes, counts, quality, etc.) at a glance, open the “Image/Video Call Rules” tab on the Models page. You can also select the model in the Playground and toggle “Custom body / Debug” to inspect the exact request body.
Text-to-Image Example#
curl https://api.smartapi.cc/api/openapi/v1/generate/image/generations \
-H "Authorization: Bearer $SMARTAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "wan2.5-image",
"prompt": "A shiba inu running in snow, cinematic lighting",
"qwenConfig": { "size": "1328*1328", "n": 1 }
}'Image-to-Image Example#
Pass reference image URLs in files to switch to image-to-image:
curl https://api.smartapi.cc/api/openapi/v1/generate/image/generations \
-H "Authorization: Bearer $SMARTAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "wan2.5-image",
"prompt": "Change the background to spring cherry blossoms",
"files": [
{ "file_uri": "https://example.com/input.png", "mime_type": "image/png" }
],
"qwenConfig": { "size": "1664*928", "n": 1 }
}'For the QWEN / Wan family (qwen-image, wan2.5/2.6/2.7-image,
wan2.7-image-pro), image-to-image has a stricter pixel limit: total
pixels must be between 768×768 (589,824) and 1280×1280 (1,638,400).
1328*1328, 1472*1140, 1140*1472 exceed the limit and will error in
image-to-image — use 1664*928, 928*1664 or smaller. Text-to-image is not
restricted.
Response#
{
"data": [{ "url": "https://.../result.png" }],
"model": "wan2.5-image"
}Some models may return b64_json (base64 image) instead of url; handle both forms. If upstream
validation fails, the endpoint returns the original upstream error message (e.g. size limit) to aid
debugging.
Billing#
Image models are billed in credits (not tokens). FLAT pricing charges a fixed credit amount
per image, so the total = base credits × count n. gpt-image-2 additionally applies a quality
multiplier: low ×1, medium ×2.5, high ×5. See per-model prices in the
Models page and the Billing doc for details.