Skip to main content

Overview

APIYI does not recommend this route for image generation. This page has been removed from the navigation and is kept for existing integrations only.On APIYI the Responses native image_generation tool can only be billed per call (a fixed tool-call fee of roughly $0.20 per image, with no usage-based option), which is not a reasonable pricing model; and because of supply constraints we cannot guarantee the stability of this path.Use the standalone Images API instead — /v1/images/generations and /v1/images/edits, billed by usage. If you need “let the agent decide whether to draw”, have your chat model classify intent and then call the Images API; see the orchestration pattern in Text + image in one API.
Beyond the standalone text-to-image / image-edit endpoints, the gateway can also pass through 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? Always use the standalone /v1/images/generations endpoint — it bills purely by actual usage, is cheaper and more controllable, and is the only image path APIYI guarantees supply for. The native tool method on this page adds a fixed tool-call fee of roughly $0.20 per image and its stability cannot be guaranteed. Not recommended for new integrations.

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

Pinning a 2.5 model (verified 2026-09-09): the tool object accepts a model field. Passing {"type": "image_generation", "model": "gpt-image-2.5-flare", "size": "1024x1024", "quality": "low"} works (HTTP 200, a 1024×1024 PNG comes back). Note that the image_generation_call output item does not echo the model name, only quality / size / background / revised_prompt, so the response cannot confirm which GPT Image model actually ran. When the model choice matters, call the standalone text-to-image endpoint instead.

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.

Transparent background

The image_generation tool accepts background: "transparent", same as /v1/images/generations:
The returned image_generation_call echoes "background": "transparent", and result decodes to a PNG with a real alpha channel. output_format must be png or webp — pairing it with jpeg errors out, since jpeg has no alpha channel. For per-model transparency support see How do I generate images with a transparent background.

💰 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