Skip to main content
Glama

Generate Image

generate_image

Generate images from text prompts using OpenAI's gpt-image-2, save to disk, and preview inline. Handles photoreal, infographics, and multilingual text, with background job polling.

Instructions

Generate an image from a text prompt using OpenAI's gpt-image-2 model family (models: "gpt-image-2" (default), "gpt-image-2.5-flare", "gpt-image-2.5-sunburst"). The image is written to disk and also returned inline so you can see it. These models handle photoreal, illustrations, infographics, multilingual text (incl. CJK), and complex structured visuals. They do NOT support transparent backgrounds. Sizes accept presets or any custom "WxH" where edges are multiples of 16, max edge ≤ 3840px, aspect ratio within 1:3–3:1, and total pixels 655,360–8,294,400. Outputs above 2K are beta. Calls that exceed ~20s (slow proxy routes, large sizes, high quality) automatically move to a background job: the first response then carries a job_id — poll get_image_job until it reports state "completed".

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nNoHow many images to generate (1–10). Each counts toward rate limits and cost.
sizeNoOutput dimensions. "auto" (default), one of the presets "1024x1024", "1536x1024", "1024x1536", or a custom "WxH" where both edges are multiples of 16, max edge ≤ 3840px, aspect ratio within 1:3–3:1, and total pixels 655,360–8,294,400. Outputs above 2K are beta.auto
userNoOptional end-user identifier forwarded to OpenAI for abuse monitoring. Pass a stable hashed user ID, not PII.
modelNoModel to use. One of "gpt-image-2", "gpt-image-2.5-flare", "gpt-image-2.5-sunburst"; defaults to "gpt-image-2". The 2.5 variants accept the same parameters. Cost/token estimates assume gpt-image-2 pricing.
promptYesImage description. gpt-image-2 handles very detailed prompts; use ALL CAPS or quote literal text you want rendered verbatim.
qualityNoGeneration quality. "low" for fast drafts, "medium" balanced (default when model picks), "high" for dense layouts and text, "auto" lets the model choose.auto
backgroundNoBackground behavior. "opaque" forces a filled background; "auto" lets the model pick. gpt-image-2 does NOT support transparent backgrounds — use a different model for that.auto
moderationNoModeration strictness. "auto" (default) applies standard safety filtering; "low" is less restrictive (still subject to OpenAI policy).auto
output_dirNoAbsolute or relative directory where generated images should be written. Defaults to $GPT_IMAGE_2_OUTPUT_DIR or a per-project subfolder under the OS config dir. The directory is created if missing.
output_formatNoFile format. "png" (default, lossless), "jpeg" (smaller, lossy), "webp" (best compression). When omitted on continue_edit_session, the session's current format is kept.
filename_prefixNoShort label appended to the generated filename so you can find it later (e.g. "hero-banner"). Letters/digits/hyphens only; auto-sanitized.
output_compressionNoCompression level 0–100 for jpeg/webp outputs. Ignored for png. Defaults to 100 (minimal compression).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
toolNo
modelNo
notesNo
routeNo
stateNo
usageNo
imagesNo
job_idNoPresent on background hand-off — pass to get_image_job.
promptNo
appliedNo
poll_hintNo
requestedNo
started_atNo
async_after_msNo
prompt_previewNo
cost_usd_estimatedNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.0

TDQS

A4.3/5.0
Behavior5/5

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

Goes well beyond the sparse annotations by disclosing that images are written to disk, returned inline, may move to a background job after ~20s with a job_id to poll via get_image_job, and that outputs above 2K are beta. Also notes the transparency limitation. No contradiction with annotations.

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

Conciseness3/5

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

Dense and front-loaded, but visibly redundant with the schema: the model list, size constraints, transparency limitation, and background option all appear in the input schema with nearly identical wording. The valuable additions (inline return, polling workflow, multilingual capabilities, beta caveat) could be retained while trimming duplicated schema text.

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 12-parameter generation tool with a complete input schema and an output schema, this description is operationally complete. It covers artifact handling, background job polling, model limitations, and output constraints, leaving no critical behavior for the agent to infer.

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

Parameters3/5

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

Schema description coverage is 100%, so the baseline is 3. The description mostly restates schema content (model enum, size constraints, background option) without adding new parameter-level meaning. It adds some operational context, such as inline return and background jobs, but not much beyond the structured fields.

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 an image from a text prompt'), names the model family, and describes the concrete output behavior (written to disk and returned inline). This clearly separates it from siblings like edit_image and get_image_job as the generative entry point.

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?

Provides clear context on when generation is suitable: model strengths (photoreal, illustrations, multilingual text), unsupported transparent backgrounds, and background-job fallback behavior. It does not explicitly name alternatives like edit_image for edits, but the generate-vs-edit distinction is strongly implied by the description and title.

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