Skip to main content
Glama

Generate image

generate_image

Generate images offline from detailed text prompts, optionally using reference images for people, products, or styles, and save the result as a PNG.

Instructions

Generate an image from a text prompt with the local Qwen-Image 2.1 model, optionally using reference images (a person, a product, a style) in a new scene. Write the full, detailed prompt yourself (see the prompt field): it is used as is. Dimensions are chosen automatically (aspect ratio can be inferred from the prompt, e.g. '16:9 hero image') unless width/height or aspect_ratio are given. Returns the absolute path of the saved PNG. Runs fully offline; typically 45 s–4 min.

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
seedNoSeed for reproducible results; omit or -1 for random
widthNoOutput width in pixels (needs height too). Omit to choose automatically.
heightNoOutput height in pixels (needs width too).
promptYesThe final prompt, written by you in English and used as is (Kokon does not rewrite it): one paragraph of about 60-200 words describing the finished image: medium and style first, the subject and what it does, the setting and background, composition and camera view, and the light. Copy any text to show exactly, in double quotes. No quality tags or sizes. With reference_images: refer to them as image 1, image 2..., say what to take from each (a person's face and look, a product with its shape, colours and logo, a style) and describe the new scene around them; never ask to keep a reference unchanged.
qualityNoAll run Qwen-Image 2.1 Turbo (8 steps): fast = ~1 MP (the default, fastest); balanced = ~1.5K; quality = native 2K (slowest; edits share 2K with their references)
output_pathNoOptional destination (absolute, or relative to the project). Must be inside the project or the app output folder. Existing files are never overwritten; a numbered name is used instead.
aspect_ratioNoAspect ratio such as 1:1, 4:3, 3:4, 16:9, 9:16, or auto (inferred from the prompt)
include_previewNoAlso return a small JPEG preview in the tool result. Default false: images stay local and are not sent to the model.
reference_imagesNoOptional images the new image uses (a person, a product, a place, a style), in order; refer to them as image 1, image 2, ... in the prompt. The output is sized like any new image, not like the references. To change an image instead, use edit_image or edit_images.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.10.2
    • changedInput schema / properties / prompt / description
      Previous value: -"What to generate, in natural language"New value: +"The final prompt, written by you in English and used as is (Kokon does not rewrite it): one paragraph of about 60-200 words describing the finished image: medium and style first, the subject and what it does, the setting and background, composition and camera view, and the light. Copy any text to show exactly, in double quotes. No quality tags or sizes. With reference_images: refer to them as image 1, image 2..., say what to take from each (a person's face and look, a product with its shape, colours and logo, a style) and describe the new scene around them; never ask to keep a reference unchanged."
    • addedInput schema / properties / reference_images
      Added value: +{
      +  "description": "Optional images the new image uses (a person, a product, a place, a style), in order; refer to them as image 1, image 2, ... in the prompt. The output is sized like any new image, not like the references. To change an image instead, use edit_image or edit_images.",
      +  "items": {
      +    "minLength": 1,
      +    "type": "string"
      +  },
      +  "maxItems": 10,
      +  "type": "array"
      +}
  2. First observedv0.9.3

TDQS

A4.6/5.0
Behavior4/5

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

Beyond the annotations it discloses that generation runs fully offline, takes roughly 45 s–4 min, auto-selects dimensions, and returns the absolute path of the saved PNG. Overwrite protection is described only in the output_path schema rather than the description, a minor remaining gap given the non-destructive annotation is already present.

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?

Four front-loaded sentences covering purpose, prompt authoring, sizing policy, and output/latency, with no filler. Some sentences restate schema content (path return, prompt-as-is), but each still earns its place as a calling instruction.

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?

With no output schema, the description supplies the return value (absolute PNG path) and runtime expectation, and it explains the sizing and quality tradeoffs an agent needs to call the tool correctly. Nothing material is missing for a 9-parameter generation tool.

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 cross-parameter meaning the schema does not: dimensions are inferred from prompts like '16:9 hero image' unless width/height or aspect_ratio are supplied, and the prompt is passed through unchanged. The quality tiers and reference-image ordering are also framed behaviorally.

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 plus the exact engine ('Generate an image from a text prompt with the local Qwen-Image 2.1 model'), and it distinguishes the reference-image mode from the editing siblings by pointing to edit_image/edit_images for changes to an existing image.

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?

Gives explicit selection rules: use this for a new scene, use edit_image or edit_images to change an image, and only set width/height/aspect_ratio when automatic dimensioning is not wanted. It also instructs the agent to write the prompt itself and explains how to cite reference images.

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