Skip to main content
Glama

Generate image

generate_image

Create one or more AI images from a text prompt, save them to local disk, and return absolute file paths with metadata for use in downstream workflows.

Instructions

Generate one or more images with the OpenAI Images API (POST /v1/images/generations), save them to local disk, and return absolute file paths plus metadata. Image bytes are never returned. Requires OPENAI_API_KEY. The model defaults to IMG_MODEL (gpt-image-2.6-sunburst); set OPENAI_BASE_URL for OpenAI-compatible gateways.

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
nNoThe number of images to generate. Must be between 1 and 10.
svgNoSelects the model and reasoning effort used to author SVG output. Requires output_format=svg. SVG generation requires n=1 and does not support streaming, partial images, prompt rewriting, or output compression.
sizeNoThe size of the image(s). Standard sizes are 1024x1024, 1536x1024 and 1024x1536; 'auto' lets the model choose. GPT Image 2.x models also accept arbitrary WIDTHxHEIGHT values (both divisible by 16, aspect ratio between 1:3 and 3:1, maximum 3840x2160). Defaults to auto.
userNoDeprecated: use safety_identifier instead. Kept for backward compatibility and used when safety_identifier is omitted.
modelNoThe GPT image model to use, for example gpt-image-2.6-sunburst or gpt-image-2.6-flare. Defaults to IMG_MODEL, or gpt-image-2.6-sunburst.
promptYesA text description of the desired image(s). The maximum length is 32000 characters.
qualityNoThe quality of the image. 'auto' (default) selects the best quality for the model. GPT Image models support low, medium and high; gpt-image-2.5 and later also support xhigh and max.
file_nameNoOptional base file name; path separators are not allowed. The actual image format determines the extension. When multiple outputs are produced, -1, -2, ... suffixes are appended. Existing files are never overwritten.
backgroundNoAllows to set transparency for the background of the generated image(s). Must be one of transparent, opaque, or auto (default). When using transparent, set the output format to png or webp.
complexityNoComputation spent planning the image, independently of rendering quality. Uses the model's configured default when omitted. For SVG output, controls the reference image rather than the SVG author's reasoning.
moderationNoContent-moderation level for images generated by GPT Image models. 'low' applies less restrictive filtering; 'auto' is the default.
output_dirNoAbsolute directory where the output file is saved. Defaults to IMG_OUTPUT_DIR, or ~/img-output. The directory is created automatically.
frame_countNoNumber of frames for GIF output (2-16). Defaults to 9. Only valid with output_format=gif.
output_formatNoThe format in which the image(s) are saved. This parameter is only supported for GPT image models. Defaults to png.
frame_duration_msNoDelay per GIF frame in milliseconds. Defaults to 200. Only valid with output_format=gif.
safety_identifierNoA stable identifier for an end user in your organization, used for safety monitoring and abuse detection. Hash a username or email address to avoid sending identifying information. Takes precedence over the deprecated user parameter.
output_compressionNoThe compression level (0-100%) for the generated images. Only supported for webp or jpeg output, and defaults to 100.

Output Schema

NameRequiredDescriptionDefault
sizeNo
modelYes
usageNo
imagesYes
createdYesUnix timestamp (in seconds) when the image was created.
qualityNo
svg_usageNo
backgroundNo
output_formatNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.0.1

TDQS

A4/5.0
Behavior4/5

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

Annotations already declare a non-read-only, open-world, non-idempotent but non-destructive operation; the description adds genuinely new behavioral facts: OPENAI_API_KEY is required, bytes are never returned, outputs land on local disk with metadata, and OPENAI_BASE_URL controls gateway routing. It omits cost/rate-limit expectations and any partial-failure semantics when n>1, which keeps it short of a 5.

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

Conciseness5/5

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

Three compact sentences, front-loaded with the action and the most surprising behavior (files, not bytes), followed by prerequisite and configuration defaults. No redundant restatement of schema fields or filler.

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

Completeness4/5

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

For a 17-parameter tool with nested objects, an output schema, and rich annotations, the description covers the essentials an agent needs: auth prerequisite, where output goes, what is returned, and model/base-URL configuration. Remaining gaps (cost, concurrency, multi-image failure handling) are minor given the output schema and full parameter documentation.

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 all 17 parameters including the nested svg object and enums are already documented in structured form; the description adds only the default model name and base-URL environment variable. That is marginal added meaning, so the baseline 3 applies.

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 one or more images with the OpenAI Images API'), names the underlying endpoint, and specifies the non-obvious outcome: files saved to local disk with absolute paths returned rather than image bytes. This clearly separates it from siblings like edit_image or convert_image, which operate on existing images.

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

Usage Guidelines3/5

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

Usage is implied by the purpose (create new images from a text prompt) and reinforced by the operational context of an API key requirement, but there is no explicit when-to-use / when-not-to-use guidance or any pointer to alternatives such as edit_image for modifying existing images. An agent can infer the fit, but must do so itself.

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