Skip to main content
Glama

generate_image

Generate or edit images from text prompts with xAI's Grok model, choosing aspect ratio, resolution, and output format; persist files when needed.

Instructions

Generate images with xAI. Model and quality affect cost. URLs are temporary unless persisted with storage_options. b64_json returns inline image content.

Input Schema

NameRequiredDescriptionDefault
nNoNumber of output images (default: 1)
modelNoOverrides XAI_IMAGE_MODEL (default: grok-imagine-image). Choose grok-imagine-image-2.0 for quality control and up to 5 inputs
promptYesDescribe the image to generate or the desired edits
qualityNoImage 2.0 only. Auto uses low for generation and medium for editing; billing follows the served quality
resolutionNoOutput resolution (default: 1k)
aspect_ratioNoGeneration defaults to auto; editing follows the first input. 21:9 and 5:2 require image 2.0
response_formatNourl returns temporary links (default); b64_json returns MCP image content
storage_optionsNoPersist outputs in the Files API; private unless public_url is explicitly enabled

Output Schema

NameRequiredDescriptionDefault
modelNo
usageNo
imagesYes
qualityNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed13 schema fields changedv1.1.0
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • removedInput schema / additionalProperties
      Removed value: -false
    • changedInput schema / properties / aspect_ratio / description
      Previous value: -"Aspect ratio of the generated image (default: auto)"New value: +"Generation defaults to auto; editing follows the first input. 21:9 and 5:2 require image 2.0"
    • changedInput schema / properties / aspect_ratio / enum
      Previous value: -[
      -  "1:1",
      -  "16:9",
      -  "9:16",
      -  "4:3",
      -  "3:4",
      -  "3:2",
      -  "2:3",
      -  "2:1",
      -  "1:2",
      -  "19.5:9",
      -  "9:19.5",
      -  "20:9",
      -  "9:20",
      -  "auto"
      -]New value: +[
      +  "1:1",
      +  "16:9",
      +  "9:16",
      +  "4:3",
      +  "3:4",
      +  "3:2",
      +  "2:3",
      +  "2:1",
      +  "1:2",
      +  "19.5:9",
      +  "9:19.5",
      +  "20:9",
      +  "9:20",
      +  "21:9",
      +  "5:2",
      +  "auto"
      +]
    • addedInput schema / properties / model
      Added value: +{
      +  "description": "Overrides XAI_IMAGE_MODEL (default: grok-imagine-image). Choose grok-imagine-image-2.0 for quality control and up to 5 inputs",
      +  "enum": [
      +    "grok-imagine-image",
      +    "grok-imagine-image-2.0"
      +  ],
      +  "type": "string"
      +}
    • changedInput schema / properties / n / description
      Previous value: -"Number of images to generate (1-10, default 1)"New value: +"Number of output images (default: 1)"
    • changedInput schema / properties / prompt / description
      Previous value: -"Text description of the image to generate"New value: +"Describe the image to generate or the desired edits"
    • addedInput schema / properties / prompt / minLength
      Added value: +1
    • addedInput schema / properties / quality
      Added value: +{
      +  "description": "Image 2.0 only. Auto uses low for generation and medium for editing; billing follows the served quality",
      +  "enum": [
      +    "low",
      +    "medium",
      +    "auto"
      +  ],
      +  "type": "string"
      +}
    • changedInput schema / properties / resolution / description
      Previous value: -"Resolution of the generated image (default: 1k)"New value: +"Output resolution (default: 1k)"
    • addedInput schema / properties / response_format
      Added value: +{
      +  "description": "url returns temporary links (default); b64_json returns MCP image content",
      +  "enum": [
      +    "url",
      +    "b64_json"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / storage_options
      Added value: +{
      +  "description": "Persist outputs in the Files API; private unless public_url is explicitly enabled",
      +  "properties": {
      +    "expires_after": {
      +      "description": "File lifetime in seconds; omitted means permanent storage",
      +      "maximum": 2592000,
      +      "minimum": 3600,
      +      "type": "integer"
      +    },
      +    "filename": {
      +      "description": "Filename for the stored image, e.g. landscape.jpg",
      +      "minLength": 1,
      +      "type": "string"
      +    },
      +    "public_url": {
      +      "anyOf": [
      +        {
      +          "type": "boolean"
      +        },
      +        {
      +          "properties": {
      +            "expires_after": {
      +              "maximum": 2592000,
      +              "minimum": 3600,
      +              "type": "integer"
      +            }
      +          },
      +          "type": "object"
      +        }
      +      ],
      +      "description": "Explicitly create a public link; omitted means private storage"
      +    }
      +  },
      +  "required": [
      +    "filename"
      +  ],
      +  "type": "object"
      +}
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "https://json-schema.org/draft/2020-12/schema",
      +  "additionalProperties": false,
      +  "properties": {
      +    "images": {
      +      "items": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "file_output": {
      +            "anyOf": [
      +              {
      +                "additionalProperties": false,
      +                "properties": {
      +                  "expires_at": {
      +                    "type": "number"
      +                  },
      +                  "file_id": {
      +                    "minLength": 1,
      +                    "type": "string"
      +                  },
      +                  "filename": {
      +                    "type": "string"
      +                  },
      +                  "public_url": {
      +                    "type": "string"
      +                  },
      +                  "public_url_error": {
      +                    "type": "string"
      +                  },
      +                  "public_url_expires_at": {
      +                    "type": "number"
      +                  }
      +                },
      +                "required": [
      +                  "file_id"
      +                ],
      +                "type": "object"
      +              },
      +              {
      +                "type": "null"
      +              }
      +            ]
      +          },
      +          "inline": {
      +            "description": "Image bytes are in the corresponding MCP image content block",
      +            "type": "boolean"
      +          },
      +          "mime_type": {
      +            "anyOf": [
      +              {
      +                "minLength": 1,
      +                "type": "string"
      +              },
      +              {
      +                "type": "null"
      +              }
      +            ]
      +          },
      +          "respect_moderation": {
      +            "type": "boolean"
      +          },
      +          "revised_prompt": {
      +            "type": [
      +              "string",
      +              "null"
      +            ]
      +          },
      +          "url": {
      +            "anyOf": [
      +              {
      +                "minLength": 1,
      +                "type": "string"
      +              },
      +              {
      +                "type": "null"
      +              }
      +            ]
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "minItems": 1,
      +      "type": "array"
      +    },
      +    "model": {
      +      "type": "string"
      +    },
      +    "quality": {
      +      "type": [
      +        "string",
      +        "null"
      +      ]
      +    },
      +    "usage": {
      +      "additionalProperties": {},
      +      "propertyNames": {
      +        "type": "string"
      +      },
      +      "type": "object"
      +    }
      +  },
      +  "required": [
      +    "images"
      +  ],
      +  "type": "object"
      +}
  2. First observedv1.0.0

TDQS

A3.8/5.0
Behavior4/5

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

Annotations only declare the safety profile (write, open-world, non-idempotent, non-destructive). The description adds genuinely useful behavior beyond that: cost varies with model/quality, generated URLs are ephemeral unless persisted via storage_options, and b64_json returns inline content. It stops short of noting auth requirements or rate limits.

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?

Four short, front-loaded sentences with no filler. The core action comes first and the cost and output-format caveats follow in order of importance.

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?

An output schema exists, so return values need not be explained, and annotations cover the safety profile. The description is complete for invoking the tool, with the only real gap being the lack of explicit routing versus edit_image.

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%, with rich enum docs for model, quality, aspect_ratio, response_format, and storage_options, so the schema carries the parameter burden. The description reinforces the cost and persistence implications of those parameters but adds little syntax or format detail beyond what the schema already states.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Generate images with xAI'), which is clear and actionable. It does not, however, explicitly contrast itself with the sibling edit_image, so an agent must infer the generation-vs-editing split from the verb alone.

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?

The description gives conditional guidance on output handling (temporary URLs vs. persisted storage vs. inline b64_json), which implies usage. It never says when to choose this tool over edit_image or when persistence is required, so the when-to-use-vs-alternative guidance is only implied.

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

Deploy Server

Other Tools