Overview
Beyond the standalone text-to-image / image-edit endpoints, APIYI also supports the OpenAI Responses API’s nativeimage_generation tool: the main model gpt-5.5 decides on its own when to draw, internally selects a GPT Image model, and returns the image as base64 in the response output array.
Verified working (2026-06-17):
gpt-5.5 + POST /v1/responses + tools: [{"type": "image_generation"}] returns a valid base64 PNG. Both image paths route directly through OpenAI’s official upstream.Which should you use? For the vast majority of “I just want an image” cases, prefer the standalone
/v1/images/generations endpoint — it bills purely by actual usage, which is cheaper and more controllable. Only use the native tool method on this page when your pipeline must go through Responses (e.g. letting gpt-5.5 autonomously decide whether to draw inside an Agent conversation). It adds a fixed tool-call fee of roughly $0.20 per image.Comparison of the two methods
Core difference: the native tool method adds a fixed ≈$0.20 tool fee per image, while the images API bills purely by actual usage — so it is cheaper in most cases.
Minimal request
cURL
Python (requests)
Response structure (key fields)
On success (HTTP 200), the response body contains:- ✅ Success:
outputcontainstype="image_generation_call", andresultdecodes to a valid image starting with\x89PNG. - ⚠️ Silently stripped: HTTP 200 but no
image_generation_callinoutput, only text (common when a channel doesn’t support the tool). - ❌ Error: non-200, or returns
unknown tool/no available channels, etc. For the latter two, fall back to/v1/images/generations.
💰 Billing
Take one real call as an example (input 2347 tokens, output 74 tokens, generating one 1122×1402 PNG). The final charge = $0.213954, which is correct. Breakdown:Conversion:500,000 quota = \$1(derived from106977 quota = \$0.213954).
Cost notes
- The generation fee is fixed per image (≈$0.20/image) and does not vary with prompt length; the text token cost is small by comparison.
- Each image takes ~60-90s; set a client timeout of ≥300s.
- If you only need an image and don’t need the model to decide autonomously, the standalone
/v1/images/generationsendpoint is likely cheaper and more controllable.
Troubleshooting
Related docs
- GPT-Image-2 Overview - Model overview and pricing
- Text-to-Image API Reference -
/v1/images/generations, the default choice for most cases - Image Edit API Reference -
/v1/images/edits, reference-image edits / multi-image fusion / mask