Generate images from a text prompt and receive image URLs or Base64 data.
Request
| Item | Description |
|---|---|
| Method | POST |
| Path | /v1/images/generations |
| Gateway URL | https://ailink.nativex.com |
| Authentication | Authorization: Bearer sk-xxxx; replace the placeholder with your API Key |
| Request format | application/json |
Replace MODEL_ID with a model from the Model Marketplace that supports this endpoint. Available models, parameters, and permissions depend on your account.
Parameters
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
model |
Body | string | Yes | A model that supports the Images API; specify it explicitly |
prompt |
Body | string | Yes | Image description |
n |
Body | integer | No | Image count. Start with 1; limits vary by model. dall-e-3 supports only 1. |
size |
Body | string | No | Dimensions, such as 1024x1024; supported values depend on the model |
quality |
Body | string | No | Quality level; available values differ by model |
response_format |
Body | string | No | url or b64_json; whether it can be selected depends on the model |
background |
Body | string | No | Supported GPT Image models accept transparent, opaque, or auto |
output_format |
Body | string | No | Supported models can select png, jpeg, or webp |
Send the literal API parameter values, not translated labels; for example, transparent specifies a transparent background. Dimensions, quality, and format must match the selected model.
Example
curl -X POST 'https://ailink.nativex.com/v1/images/generations' \
-H 'Authorization: Bearer sk-xxxx' \
-H 'Content-Type: application/json' \
-d '{
"model": "MODEL_ID",
"prompt": "An orange cat sitting by a window, watercolor illustration",
"n": 1
}'
Response
The following is a simplified response for readability. IDs, URLs, text, and usage values are illustrative.
{
"created": 0,
"data": [
{
"url": "https://example.com/generated.png"
}
]
}
| Field or result | Description |
|---|---|
| data[].url | Temporary image URL; download promptly if provided |
| data[].b64_json | Decode this field and save the image when returned |
| usage | Usage information returned by some models |
Error handling
For unsuccessful responses, check the HTTP status and error body first. Verify the API Key, model name, account balance, and parameters. If rate limited, reduce concurrency and retry later.