Skip to main content
Glama

Generate image (GPT Image via Codex)

generate_image

Generate or edit images and looping animated GIFs from prompts, optionally using reference images, and save results to disk.

Instructions

Generate or edit images with GPT Image through the local Codex CLI and return them inline, saved to disk. It also creates looping animated GIFs: pass the gif parameter. Pass reference_images to edit existing images or to use them as style/subject references. Set background: true to get a job id at once and keep working; the images then come from get_image_result. Takes about 30-90 seconds per image. There is no size parameter: put the aspect ratio in the prompt (for example "16:9 landscape", "square 1:1", "vertical 9:16"). The result lists each saved file path and size, the prompt that reached GPT Image, an alpha-channel check when a transparent background was requested, and the usage limits Codex reports.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "prompt": "<prompt>"
    },
    "name": "generate_image"
  }
}

Input Schema

NameRequiredDescriptionDefault
gifNoCreate a looping animated GIF instead of a still image. Pass {} for the defaults (9 frames, 200 ms each). Keep the motion simple and describe it in the prompt. Needs Codex CLI 0.167.0-alpha.5 or newer.
countNoHow many images to generate from the same prompt (1-4). Each one uses the ChatGPT image quota. Codex may return fewer; the result says so.
modelNoCodex chat model that relays the request and, in enhance mode, rewrites the prompt. It does not choose the image model. Default: GPT_IMAGE_MODEL if set, otherwise the model in the user's Codex config. Call codex_status for the list.
promptYesThe image prompt. In prompt_mode "exact" Codex is told to send it to GPT Image unchanged, so make it complete: aspect ratio, subject, composition, style, lighting, colors, and any text that must appear (in quotes, exact spelling). Do not put file paths in it; use reference_images.
backgroundNoReturn immediately with a job id and keep generating in the background, so you can do other work. Collect the images later with get_image_result.
output_pathNoWhere to save: a directory, or a file path such as hero.png (the name is kept; the extension follows the format returned, normally PNG). Relative paths resolve against the project directory; ~ is expanded. Default: <project>/generated-images/. Existing files are never overwritten; a numeric suffix is added instead.
prompt_modeNo"exact" (default): Codex is told to pass the prompt to GPT Image unchanged; the result reports any difference. "enhance": the Codex model first rewrites it into a more detailed prompt, and the result shows the rewritten prompt.exact
reasoning_effortNoReasoning effort for the Codex model, e.g. low, medium, high. Default: GPT_IMAGE_EFFORT if set; otherwise low in exact mode when the model supports it, else the Codex config default. Call codex_status for the values each model supports.
reference_imagesNoLocal image files (PNG, JPEG, WebP or GIF, up to 16) to edit, to use as references, or to place in the result (for example a real logo). Absolute, relative to the project directory, or starting with ~. Images the user pasted or attached in the chat come with a file path ("[Image: source: <path>]"): pass that path.
transparent_backgroundNoAsk for a transparent background (cutouts, icons, stickers). The result reports whether the PNG has an alpha channel.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only declare the generic profile (not read-only, open-world, not idempotent), while the description adds the traits that actually drive planning: 30-90 seconds per image, a background job-id flow, and the guarantee that existing files are never overwritten (a numeric suffix is appended). It also previews the return payload (file paths, sizes, the prompt actually sent, alpha-channel check, usage limits), which is the behavior an agent needs to interpret results.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core action and delivery, then ordered by mode (GIF, reference images, async, timing, aspect ratio, return shape). Slight redundancy in restating `gif`, `background`, and `reference_images` mechanics that the schema already documents in more detail, but nothing is filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 10-parameter, nested-object, no-output-schema generation tool, the description covers latency, async retrieval, file-save semantics, the aspect-ratio workaround, and the contents of the result — everything needed to call it correctly and to interpret what comes back.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds meaning the schema cannot: that no size parameter exists and aspect ratio must go in the prompt with examples, and that `background` pairs with `get_image_result`. It also reinforces the split between `reference_images` and file paths in the prompt, which is a common misuse the schema only hints at.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ("Generate or edit images with GPT Image") plus the delivery channel (inline and saved to disk), and immediately names the two variants — animated GIFs via `gif` and edits/references via `reference_images`. The async path is tied to the sibling `get_image_result`, so an agent can distinguish the two tools without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete routing conditions: `background: true` when you want to keep working and then collect via `get_image_result`; `reference_images` instead of file paths in the prompt; `gif` for animation; and the explicit instruction to encode aspect ratio in the prompt because there is no size parameter. It does not state any when-not-to-use case or contrast with `codex_status` beyond a pointer for model lists.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools