Skip to main content
Glama

ai_generate_image

Need a hero, product image, social card, thumbnail, or draft visual? ai_generate_image creates it from a text prompt without wiring a separate image provider. Returns image bytes (base64) or a stored path plus cost.

Two managed models, priced in ai_catalog. Which model: omit model for fast, low-cost drafts (@cf/black-forest-labs/flux-1-schnell, fixed 1024×1024, billed per tile and step); gpt-image-2.5-flare suits final assets, legible text, UI mockups or a transparent background (reserves balance up front; a successful call uses reported token usage capped at that reservation, or the calculator estimate when usage is missing). Failed GPT Image calls return the reservation; an unconfirmed return is reported as settlement: 'unconfirmed'. Earlier retired managed models are refused with a message naming the default. For any other model, bring your own provider: store the vendor's key as a project secret and call the vendor from your own function; there is no managed AI charge on that path (the vendor bills you directly; your function's ordinary platform usage still applies).

Inline rendering: Pass inline: true to get the image as an MCP image content block alongside the JSON result. An MCP client that supports image content blocks can render it directly. Default inline: false keeps the response lightweight (base64 only when not stored).

Example:

{
  "project_id": "my-saas",
  "prompt": "A minimalist logo for a fitness app, clean lines, blue and white",
  "inline": true
}

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": {
      "project_id": "<project_id>",
      "prompt": "<prompt>"
    },
    "name": "ai_generate_image"
  }
}

Input Schema

NameRequiredDescriptionDefault
modelNoOptional. @cf/black-forest-labs/flux-1-schnell (default) or gpt-image-2.5-flare; other ids are refused with a typed error.
stepsNoDefault model only: inference steps, 1-8 (default 4).
widthNogpt-image-2.5-flare: with height, picks the shape (wider 1536×1024, taller 1024×1536, else 1024×1024). Ignored by the default model, which renders 1024×1024.
heightNogpt-image-2.5-flare: with width, picks the shape. Ignored by the default model.
inlineNoWhen true, the image comes back as an MCP image content block that supporting clients render inline. Default false.
promptYesImage description (max 2000 chars).
qualityNogpt-image-2.5-flare only (default medium). Refused on the default model.
storageNoOptional storage path like /images/hero.png. When set, saves to the project filesystem.
backgroundNogpt-image-2.5-flare only (default auto); transparent returns a PNG with alpha. Refused on the default model.
project_idYesProject ID (UUID), subdomain, or slug — resolved server-side, no UUID lookup needed. 'default' also works when the account has exactly one project; multi-project accounts must name one (the error lists them).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Beyond the sparse annotations, the description discloses billing behavior, balance reservation and settlement semantics, failed-call reservation returns, unconfirmed settlements, retired-model refusal, BYO-provider billing, and inline rendering behavior. These are material operational details for a non-read-only, open-world generation tool.

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?

The description is front-loaded with the core purpose and use cases, then uses bold section labels and a concrete example to organize the model and rendering details. It is necessarily dense for a 10-parameter tool with billing complexity, but some clauses about settlement and reservation are verbose enough to keep it below maximum conciseness.

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?

There is no output schema, but the description explains the return forms (base64 bytes or stored path plus cost), the inline image content block behavior, and the settlement reporting. It also covers provider-key setup for external models and project-id resolution, making it complete enough for an agent to call the tool correctly.

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 input schema already documents the parameters thoroughly. The description adds meaningful context beyond the schema by explaining model tradeoffs, billing implications, default-model resolution, and inline rendering behavior, though some model-specific parameters remain primarily schema-described.

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 states a specific verb and resource: it creates an image from a text prompt. It immediately lists concrete use cases (hero, product image, social card, thumbnail, draft visual) and distinguishes the output modes (base64 bytes or stored path), so an agent can identify the tool's role without inspecting siblings.

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?

It gives explicit model-selection guidance: omit model for fast low-cost drafts, use gpt-image-2.5-flare for final assets, legible text, UI mockups, or transparent backgrounds, and use a BYO provider for any other model. It also states exclusions and refusal behavior for retired models, leaving little ambiguity about when to use each path.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources