Image Generation API
Use one OpenAI-compatible endpoint for GPT Image and Wan image models. This page covers authentication, text-to-image requests, Wan-specific parameters, temporary image URLs, billing, and operational limits.
Endpoint and Authentication
Image generation uses the same LingCoreX API key format as other OpenAI-compatible requests.
Supported Image Models
The same endpoint accepts different model IDs, while model capabilities and billing modes remain model-specific.
| Model | Best fit | Output and billing |
|---|---|---|
| gpt-image-2 | OpenAI-compatible image generation and GPT Image workflows. | Supports the provider's GPT Image options. Usage is settled using the configured image-token prices. |
| wan2.7-image | Faster Wan text-to-image generation up to 2K. | Returns signed image URLs. Supports 1 to 4 images and is billed per successfully returned image. |
| wan2.7-image-pro | Higher-quality Wan generation, including 4K text-to-image output. | Returns signed image URLs. Supports 1 to 4 images and is billed per successfully returned image. |
Wan Request Parameters
Wan models use a compact OpenAI-compatible request. Omitted optional fields use the defaults shown below.
| Field | Required | Description |
|---|---|---|
| model | Yes | wan2.7-image or wan2.7-image-pro. |
| prompt | Yes | Text description of the image to generate. Chinese and English prompts are supported. |
| n | No | Number of images. Range: 1 to 4. Default: 1. Billing increases with the number of successful images. |
| size | No | 1K or 2K for both Wan models; 4K is available only for wan2.7-image-pro text-to-image. Pixel sizes such as 1024x1024 are also accepted. Default: 2K. |
| response_format | No | Wan currently supports url only. Omit this field or set it to url. |
| watermark | No | Boolean. Adds the provider's AI-generated watermark when true. Default: false. |
| thinking_mode | No | Boolean. Enables enhanced inference for text-to-image. Default: true. |
| seed | No | Integer from 0 to 2147483647. Similar seeds can produce similar results, but output is not deterministic. |
| color_palette | No | Optional Wan color palette array. Use 3 to 10 HEX colors whose ratios total 100.00%. |
Request Examples
These examples all call the same public LingCoreX endpoint.
curl https://api.lingcorex.ai/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "wan2.7-image",
"prompt": "A quiet mountain lake at sunrise, cinematic photography, no text",
"n": 1,
"size": "1K"
}'import requests
response = requests.post(
"https://api.lingcorex.ai/v1/images/generations",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"model": "wan2.7-image-pro",
"prompt": "A premium studio photograph of a blue glass perfume bottle",
"n": 1,
"size": "2K",
"watermark": False,
},
timeout=600,
)
response.raise_for_status()
payload = response.json()
print(payload["data"][0]["url"])const response = await fetch(
"https://api.lingcorex.ai/v1/images/generations",
{
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "wan2.7-image",
prompt: "An isometric illustration of a small green energy laboratory",
n: 1,
size: "1024x1024",
}),
},
)
if (!response.ok) {
throw new Error(await response.text())
}
const result = await response.json()
console.log(result.data[0].url)Response Format
Wan responses are normalized to the OpenAI Images API shape and include the successful image count.
{
"created": 1784962566,
"data": [
{
"url": "https://example-oss.aliyuncs.com/generated-image.png?SIGNED_QUERY"
}
],
"usage": {
"image_count": 1
}
}Billing and Settlement
Wan billing is based on successfully returned images rather than token counts.
Common Errors
Use the HTTP status and OpenAI-style error body together when troubleshooting.
| Status | Meaning | What to check |
|---|---|---|
| 400 | Invalid or unsupported request parameter. | Check model, prompt, n, size, response_format, stream, and partial_images. |
| 401 | Missing or invalid API key. | Check the Authorization header and whether the key is active. |
| 402 | Insufficient balance for pre-authorization. | Recharge the account or review the active spending limits. |
| 403 | The key cannot use this model/provider. | Add the image model to the API key's assigned model group. |
| 429 | QPM or other rate limit exceeded. | Retry with backoff or adjust the key's QPM limit. |
| 502 | The upstream image provider failed or returned no successful images. | Inspect the error message and retry only when appropriate. |