Skip to main content
Glama

Generate an image with OpenAI

openai_generate_image

Generate images from text prompts and save them to disk. Specify size, quality, background, and format to get files saved locally with paths returned.

Instructions

Create one or more images from a text prompt and write them to disk.

Images are never returned inline — the tool saves each file and reports its absolute path, so the agent's context stays small.

Args:

  • prompt (string, required): what the image should show

  • model (string): image model ID, defaults to OPENAI_DEFAULT_IMAGE_MODEL

  • n (number): 1-4 images (default 1)

  • size ('auto'|'1024x1024'|'1536x1024'|'1024x1536'|'512x512'|'256x256'): default 'auto'

  • quality ('auto'|'low'|'medium'|'high'): default 'auto'

  • background ('auto'|'transparent'|'opaque'): default 'auto'; 'transparent' needs png or webp

  • output_format ('png'|'jpeg'|'webp'): default 'png'

  • output_dir (string): absolute target directory, defaults to OPENAI_MCP_OUTPUT_DIR

  • response_format ('markdown'|'json'): default 'markdown'

Returns (JSON format): { "model": string, "count": number, "images": [ { "index": number, "path": string, "bytes": number } ], "revised_prompt": string | null // prompt rewrite the model applied, when reported }

Examples:

  • Use when: "Draw a logo of a blue fox" -> prompt="minimalist blue fox logo, flat vector"

  • Use when: you need a transparent sticker -> background="transparent", output_format="png"

  • Don't use when: you want to modify an existing picture (use openai_edit_image)

Error Handling:

  • "Error: Access to ... is not permitted" means output_dir is outside OPENAI_MCP_ALLOWED_DIRS

  • "Error: OpenAI rejected the request as invalid" often means size or quality is unsupported by that model

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nNoHow many images to generate
sizeNoOutput resolutionauto
modelNoImage model ID. Defaults to OPENAI_DEFAULT_IMAGE_MODEL.
promptYesDescription of the image to create
qualityNoRendering quality; higher costs more and takes longerauto
backgroundNoBackground handling; "transparent" requires png or webp outputauto
output_dirNoAbsolute directory to write the images into. Defaults to OPENAI_MCP_OUTPUT_DIR. Must be inside an allowed directory.
output_formatNoFile format of the generated imagepng
response_formatNoOutput format: 'markdown' or 'json'markdown

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
countYes
modelYes
imagesYes
revised_promptYes

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv1.0.0

TDQS

A4.9/5.0
Behavior5/5

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

Annotations declare readOnlyHint=false, so the write behavior is expected, but the description adds substantial context beyond that: images 'are never returned inline — the tool saves each file and reports its absolute path', the rationale ('agent's context stays small'), environment-variable defaults, and a dedicated Error Handling section explaining what specific error strings mean (allowed-dir violations, unsupported size/quality combinations). 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.

Conciseness5/5

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

The most important behavioral fact (saves to disk, never inline) is front-loaded in the first sentence. The remaining sections — Args, Returns, Examples, Error Handling — are each clearly headed and earn their place: the arg list is a fast reference, examples give actionable usage, and error strings turn failures into diagnosable conditions. No 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 9-parameter tool with an output schema and annotations, this description is complete: it explains the core behavior, the return shape (paths, byte counts, revised_prompt semantics), the allowed environment constraints, when not to use it, and how to interpret common failures. Nothing an agent needs to invoke it correctly is missing.

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 baseline is 3, but the description adds real value: it flags the cross-parameter constraint that 'transparent' requires png/webp output, documents env-var defaults for model and output_dir, and ties size/quality to model-specific rejection in the error section. It consolidates all 9 params into a scan-friendly list with constraints, going slightly beyond the schema's per-parameter descriptions.

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?

The description opens with a specific verb-resource pair ('Create one or more images from a text prompt') plus the distinguishing behavior 'write them to disk'. It explicitly contrasts itself with openai_edit_image in the examples, so an agent can tell this tool apart from its closest sibling without inspecting schemas.

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

Usage Guidelines5/5

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

Provides explicit 'Use when' examples with concrete prompt transformations, a conditional example (transparent sticker -> background='transparent', output_format='png'), and an explicit 'Don't use when' exclusion that names the alternative tool (openai_edit_image). This is exactly the when/when-not/alternatives guidance the rubric asks for.

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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/piorkowskim79/openai-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server