OpenAI Generations
/v1/images/generations is the OpenAI Images API compatible synchronous image generation endpoint. The caller waits for the upstream response in the same HTTP request.
Interface
| Item | Value |
|---|---|
| Method | POST |
| Path | /v1/images/generations |
| Content-Type | application/json |
| Authentication | Authorization: Bearer YOUR_API_KEY |
| Platform requirement | OpenAI platform group with image generation enabled |
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | No | Image model. Defaults to gpt-image-2. Must be a gpt-image-* model. |
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. b64_json is commonly used. |
stream | boolean | No | Whether to stream the upstream response when supported. |
quality | string | No | Native OpenAI image parameter, forwarded when supported upstream. |
background | string | No | Native OpenAI image parameter, forwarded when supported upstream. |
output_format | string | No | Native OpenAI image parameter, forwarded when supported upstream. |
output_compression | integer | No | Native OpenAI image parameter, forwarded when supported upstream. |
moderation | string | No | Native OpenAI image parameter, forwarded when supported upstream. |
style | string | No | Native OpenAI image parameter, forwarded when supported upstream. |
Request Example
bash
curl https://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 Example
json
{
"created": 1779912000,
"data": [
{
"b64_json": "..."
}
]
}Common Errors
Calling from a non-OpenAI group:
json
{
"error": {
"type": "not_found_error",
"message": "Images API is not supported for this platform"
}
}Using a non-image model:
json
{
"error": {
"type": "invalid_request_error",
"message": "images endpoint requires an image model"
}
}Boundaries
- This endpoint is only for OpenAI Images API compatible requests.
- Gemini native image requests should use
/v1beta/models/{model}:generateContent. - Use async image tasks for long-running or production bulk jobs.