/v1/images/generations to generate an image from a text prompt and /v1/images/edits to edit an input image. Both endpoints use OpenAI Images-compatible request shapes. Available operations depend on the model and channel exposed by your Flatkey service.
Generate an image
Endpoint
Headers
JSON body parameters
string
required
Image model ID exposed by your Flatkey service, such as
"gpt-image-2".string
required
Text description of the image to generate.
string
Output dimensions, such as
"1024x1024". Supported values depend on the model.string
Output quality:
"low", "medium", or "high". If omitted, the upstream default is used. Higher quality increases latency and usage.string
Background handling, such as
"transparent" or "opaque", when supported by the model.string
Output format, such as
"png", "jpeg", or "webp", when supported by the model.integer
Output compression level, when supported by the model.
string
Content moderation level, when supported by the model.
string
gpt-image-2 results are returned in data[].b64_json. Hosted image URLs are not provided, and response_format: "url" is unsupported.integer
Requested image count.
gpt-image-2 currently returns one image per request because its upstream image tool does not accept n. Send multiple requests if you need multiple images.boolean
Set to
true to receive an SSE response. Omit it for a synchronous response.Example requests
Edit an image
/v1/images/edits accepts an input image and editing instructions as multipart/form-data.
Endpoint
Headers
Form fields
Example request
mask field is optional. Omit it to edit the whole image based on the prompt. Do not set the Content-Type header manually; curl derives the correct multipart boundary from the -F fields.
Response
Synchronous generation and editing requests return the same response shape. Flatkey returns the image as base64 data; it does not provide a hosted image URL forgpt-image-2.
Response fields
integer
Unix timestamp of when the request completed.
array
Array of image objects.
Streaming
Setstream to true in a generation JSON body or add -F "stream=true" to an edit request to receive text/event-stream output. The final event contains the image result, followed by data: [DONE].
Streaming support can depend on the selected model and channel. For synchronous high-quality requests, configure a client timeout of at least 150 seconds.