Image inputs
Every endpoint that takes an image (or mask) as input accepts the request in two interchangeable formats:multipart/form-data— upload the binary file directly using form fields (image,mask,file, …). This is convenient for local files.application/json— pass the image by reference instead of uploading bytes. Each file field has a JSON counterpart that accepts a public URL or a data URL (adata:image/...;base64,...string).
All other parameters are identical between the two formats. Use JSON when your image is already hosted somewhere (just send the URL) or when a JSON body fits your client better; use multipart to upload local files directly.
Examples
Generate an image with a style reference passed as a file and as a URL:multipart/form-data
application/json
Image results
Every endpoint that returns images takes theresponse_format parameter:
url(default) — a JSON response, every image carries aurlto download it from.b64_json— a JSON response, every image carries its bytes Base64-encoded inb64_json.multipart— amultipart/form-dataresponse. Theresponsepart carries the same JSON with animage_idper image, followed by one part per image with the raw bytes. The part is named by theimage_id, which is also in itsContent-IDheader, and itsContent-Typeis the image media type (image/png,image/webporimage/svg+xml).
For the best latency use
response_format: multipart.response_format. The OpenAI Python library only reads JSON responses, so use url or b64_json with it and a plain HTTP client for multipart.