Skip to main content

The short version

An agent does not generate images itself; it has to call an image model. Behind a sentence like “blend these two images together” there are usually three stages: planning, tool calls, and an image API call. Most of the money is spent on the text side, not on the image itself. First, the cost scale of three approaches:

How one sentence unfolds

1

Receive the request

You describe the goal in natural language, for example “put the person from a.png into the scene in b.png”.
2

Plan

The agent decides whether this is text-to-image, an edit, or multi-image fusion, and which inputs it needs.
3

Call tools

Find files, read images, and list directories or search code when necessary. This is the step most likely to run away: when the agent is unsure where a file is, it scans the project first.
4

Choose how to call

With a Skill installed it executes directly; without one it reads docs, writes a script, and tries parameters. Both reading and writing bill as text tokens.
5

Call the Images API

Text-to-image goes to /v1/images/generations; edits and multi-image fusion go to /v1/images/edits.
6

Return the result

Save the image and return the path or preview to the conversation; if more adjustment is needed, the next turn begins.
Do not use the Responses built-in image_generation tool inside Codex. It adds a fixed tool fee per generation (about $0.20) and its behavior is not stable across routes. When you need an image, call /v1/images/* directly or use the Skill described below.

A real case: where the money went for one “blend” task

On 2026-11-27 (UTC+8), a user doing image compositing in Codex produced two very different groups of requests in the logs: Two facts stand out:
  1. No image request at all during that hour. All 47 were text requests. The agent was planning, reading files, and making small decisions; the task never reached the image endpoint.
  2. The text-side exploration cost several times the image cost. The eight requests that actually produced images cost about $0.54; the text side cost about $3.3 in one hour.
This is not the model “deliberately making the task complicated”. It is the agent’s default behavior: when it does not know where a file is, it scans; when it does not know how to call the API, it reads docs. The difference is whether someone handed it that knowledge up front.

Why the agent “scans the whole project”

  • It does not know where the files are: the first reaction is to list directories and search for filenames instead of asking you
  • The fixed base is large: the system prompt, tool definitions, AGENTS.md, and project context are read again every turn
  • Context grows monotonically: every tool result is appended to the next turn’s input, so later turns cost more
  • A new conversation is not free: it clears history, but the fixed base still has to be written to cache again
In this case, the agent’s input grew from about 30k tokens to about 63k, and the run saw four cache writes from zero in 59 minutes (the initial cold start plus three rebuilds). None of that says anything about whether the model is genuine — it is the normal overhead of an agent loop. For Codex’s cost profile, see OpenAI Codex.

The cheaper path: turn exploration into a Skill

APIYI’s GPT-Image Skills package the “how to call the API” knowledge into a SKILL.md plus one script, so the agent does not have to read docs and write scaffolding first:
  • Default model gpt-image-2.6-all at a flat $0.025 per image — the cheapest way to iterate
  • One script covers 11 models plus 1 alias
  • -i can be repeated for up to 16 input images, so multi-image fusion works out of the box
  • When you need official quality tiers or a precise mask, switch with --model to gpt-image-2.6-flare / gpt-image-2.6-sunburst
Installation takes three steps: create the directory, write the .env, and hand the directory to the agent. For the full guide and parameter table, see GPT-Image Series Agent Skill.
A Skill does not make cost zero: the agent’s text turns still bill, and images still bill per image or per image token. What it removes is the “read docs, write scaffolding, retry parameters” stretch.

Prompt templates (copy-paste ready)

Template 1: precise image work, with files and tools constrained
Template 2: forbid project scanning
Template 3: cap turns and output
Template 4: force the Skill path
Put these constraints in the project’s AGENTS.md rather than repeating them every time. But AGENTS.md is read on every turn, so keep it to a few dozen lines.

When not to use an agent

If image generation is a fixed pipeline, a batch job, or you just want to validate a prompt, leave the agent out:
  • Prompt validation / model comparison: use AI Image Master (imagen.apiyi.com). It uses the same APIYI key and the same image endpoints, with only image charges and no text-model charges.
  • Batch and scheduled jobs: call /v1/images/* from a script. Costs are predictable, retries are explicit, and the bill is easy to reconcile.
  • Production pipelines: scripts + queues + monitoring are more controllable than an agent.
AI Image Master is a web test bench, not a cheaper channel. Images still bill at the price of the model you select; see Model Pricing.

Cost comparison

Model prices match the official rates and may change with them; the table above is for reference only. The authoritative source is the Model Pricing tab in the top navigation: Model Pricing. Listed prices match the official rates; after recharge bonuses, the effective price is about 83–91% of the listed price. See Recharge Promotions.

GPT-Image Series Agent Skill

A ready-to-use SKILL.md plus script, defaulting to gpt-image-2.6-all

How can I use the API more economically?

A cost checklist covering model tiers, caching, output, and retries

OpenAI Codex setup

base_url, the responses protocol, and cost notes

Image editing and multi-image fusion

/v1/images/edits parameters, sizes, and masks