Generate an image
- curl
- Python
Request fields
Edit an image
Transform an existing image — edit it with a prompt (optionally guided by a mask) or remove its background — by uploading it toPOST /v1/images/edits. Unlike generation, this endpoint uses multipart/form-data (file upload), not JSON.
- curl
- Python
gpt-image-1 always returns the result as a base64 data URI in the url field. Pass response_format=b64_json for a b64_json field instead (supported on DALL·E models).Operations
Theoperation field selects what to do. Support varies by provider:
Requesting an operation a provider doesn’t support returns
422. A provider with no image-edit support at all returns 501.
BytePlus supports
edit only. remove_background is OpenAI-only.Request fields
multipart/form-data:
More examples
Remove a background:Streaming
Some models support streaming image generation — partial image data is sent as the model renders it. Set"stream": true:
text/event-stream. Its main job is to keep the connection open during a long generation: the server emits an initial processing chunk, then SSE comment pings until the image is ready. The stream always ends with data: [DONE].
Keep-alive chunk sequence
Available models
Check
GET /v1/models for the full live list of enabled image models and their pricing.