Skip to content

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 ​

ItemValue
MethodPOST
Path/v1/images/generations
Content-Typeapplication/json
AuthenticationAuthorization: Bearer YOUR_API_KEY
Platform requirementRequires an OpenAI platform group with image generation enabled.

Request Parameters ​

ParameterTypeRequiredDescription
modelstringNoOpenAI Images compatible model. Defaults to gpt-image-2.
promptstringYesImage generation prompt.
sizestringNoOutput size, such as 1024x1024.
nintegerNoNumber of images. Defaults to 1 and must be greater than 0.
response_formatstringNoResponse format, commonly b64_json.
streambooleanNoWhether to stream the response when supported by the selected model.
qualitystringNoOpenAI Images API parameter. Availability depends on the selected model.
backgroundstringNoOpenAI Images API parameter. Availability depends on the selected model.
output_formatstringNoOpenAI Images API parameter. Availability depends on the selected model.
output_compressionintegerNoOpenAI Images API parameter. Availability depends on the selected model.
moderationstringNoOpenAI Images API parameter. Availability depends on the selected model.
stylestringNoOpenAI 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": "..."
    }
  ]
}
FieldDescription
createdUnix timestamp when the response was created.
data[].b64_jsonBase64 image payload when response_format is b64_json.
data[].urlImage URL when URL responses are available.

Errors ​

StatusCause
400Request body is invalid, the model is not an image model, or required parameters are missing.
401API key is missing or invalid.
403Balance, quota, or group permission check failed.
404Current API key group cannot call the OpenAI Images API.
429Rate limit or concurrency limit was reached.
500 / 502 / 503Gateway or upstream provider failed.

Boundaries ​

  • This endpoint is only for OpenAI Images API compatible requests.