Skip to main content

Overview

Beyond the standalone text-to-image / image-edit endpoints, APIYI also supports the OpenAI Responses API’s native image_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)

Optional parameters go inside the tools item: {"type": "image_generation", "output_format": "png|jpeg|webp", "size": "1024x1024", ...}. Omit them to use the defaults (png).

Response structure (key fields)

On success (HTTP 200), the response body contains:
How to tell whether an image was actually produced:
  • Success: output contains type="image_generation_call", and result decodes to a valid image starting with \x89PNG.
  • ⚠️ Silently stripped: HTTP 200 but no image_generation_call in output, 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 from 106977 quota = \$0.213954).
A display quirk in the console detail page (explain this to customers proactively)On APIYI’s “conditional billing detail” page:
  • The top section only shows the text portion of the math (base cost = (2347 + 74×6) × 2.5 = 6977.50);
  • The image tool-call charge (≈100,000 quota / ≈$0.20) shows up as a blank row in the detail list — it isn’t rendered;
  • but it is correctly counted in the bottom-line “final quota 106977 / $0.213954”.
Conclusion: billing is normal and accurate — the detail UI simply fails to display the “image tool” row, so the line items don’t sum to the final total. When explaining to customers, emphasize: the total is correct; the difference is this image’s tool fee (≈$0.20/image), just not itemized separately.

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/generations endpoint is likely cheaper and more controllable.

Troubleshooting