OpenAI Generations
/v1/images/generations is the OpenAI Images API compatible synchronous image generation endpoint. The HTTP request completes after the image result is ready.
Interface
| Item | Value |
|---|---|
| Method | POST |
| Path | /v1/images/generations |
| Content-Type | application/json |
| Authentication | Authorization: Bearer YOUR_API_KEY |
| Platform requirement | Requires an OpenAI platform group with image generation enabled. |
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | No | OpenAI Images compatible model. Defaults to gpt-image-2. |
prompt | string | Yes | Image generation prompt. |
size | string | No | Output size, such as 1024x1024. |
n | integer | No | Number of images. Defaults to 1 and must be greater than 0. |
response_format | string | No | Response format, commonly b64_json. |
stream | boolean | No | Whether to stream the response when supported by the selected model. |
quality | string | No | OpenAI Images API parameter. Availability depends on the selected model. |
background | string | No | OpenAI Images API parameter. Availability depends on the selected model. |
output_format | string | No | OpenAI Images API parameter. Availability depends on the selected model. |
output_compression | integer | No | OpenAI Images API parameter. Availability depends on the selected model. |
moderation | string | No | OpenAI Images API parameter. Availability depends on the selected model. |
style | string | No | OpenAI Images API parameter. Availability depends on the selected model. |
Request Example
bash
curl https://api.llmapi.site/v1/images/generations \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-image-2",
"prompt": "a product photo of a ceramic coffee cup on a white table",
"size": "1024x1024",
"n": 1,
"response_format": "b64_json"
}'Response — 200 OK
json
{
"created": 1779912000,
"data": [
{
"b64_json": "..."
}
]
}| Field | Description |
|---|---|
created | Unix timestamp when the response was created. |
data[].b64_json | Base64 image payload when response_format is b64_json. |
data[].url | Image URL when URL responses are available. |
Errors
| Status | Cause |
|---|---|
400 | Request body is invalid, the model is not an image model, or required parameters are missing. |
401 | API key is missing or invalid. |
403 | Balance, quota, or group permission check failed. |
404 | Current API key group cannot call the OpenAI Images API. |
429 | Rate limit or concurrency limit was reached. |
500 / 502 / 503 | Gateway or upstream provider failed. |
Boundaries
- This endpoint is only for OpenAI Images API compatible requests.