Skip to main content
Glama
xujfcn
by xujfcn

generate_image

Create AI-generated images from text descriptions using models like DALL-E 3, Midjourney, or Stable Diffusion. Specify size, quantity, and model to produce custom visuals.

Instructions

Generate images using AI models via Crazyrouter. Supports DALL-E 3, Midjourney, Flux, Stable Diffusion, and more.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesText description of the image to generate
modelNoImage generation model to use (default: dall-e-3). Options: dall-e-3, midjourney, flux-pro-1.1-ultra, flux-kontext-pro, sd3.5-large, imagen-4.0-generate-001dall-e-3
sizeNoImage size. For DALL-E 3: 1024x1024, 1024x1792, 1792x1024.
nNoNumber of images to generate (1-4, default: 1)

Implementation Reference

  • The 'generate_image' tool is registered and implemented in src/index.ts. It uses the 'apiRequest' helper to interact with the Crazyrouter API.
    // --- Tool: generate_image ---
    server.tool(
      "generate_image",
      "Generate images using AI models via Crazyrouter. Supports DALL-E 3, Midjourney, Flux, Stable Diffusion, and more.",
      {
        prompt: z.string().describe("Text description of the image to generate"),
        model: z
          .string()
          .default(DEFAULT_IMAGE_MODEL)
          .describe(`Image generation model to use (default: ${DEFAULT_IMAGE_MODEL}). Options: dall-e-3, midjourney, flux-pro-1.1-ultra, flux-kontext-pro, sd3.5-large, imagen-4.0-generate-001`),
        size: z.string().optional().describe("Image size. For DALL-E 3: 1024x1024, 1024x1792, 1792x1024."),
        n: z.number().min(1).max(4).optional().describe("Number of images to generate (1-4, default: 1)"),
      },
      async ({ prompt, model, size, n }) => {
        try {
          const body: Record<string, unknown> = { model, prompt };
          if (size) body.size = size;
          if (n) body.n = n;
    
          const result = (await apiRequest("/images/generations", {
            method: "POST",
            body,
          })) as { data?: Array<{ url?: string; b64_json?: string; revised_prompt?: string }> };
    
          if (!result.data || result.data.length === 0) {
            return { content: [{ type: "text" as const, text: "No images were generated. Please try a different prompt." }] };
          }
    
          const images = result.data;
          let text = `🎨 Generated ${images.length} image(s) with ${model}:\n\n`;
          for (let i = 0; i < images.length; i++) {
            const img = images[i];
            if (img.url) text += `**Image ${i + 1}:** ${img.url}\n`;
            if (img.revised_prompt) text += `*Revised prompt:* ${img.revised_prompt}\n`;
            text += "\n";
          }
    
          return { content: [{ type: "text" as const, text }] };
        } catch (error) {
          const message = error instanceof Error ? error.message : "Unknown error occurred";
          return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true };
        }
      }
    );
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the service provider ('Crazyrouter') and lists supported models, but doesn't describe what happens during generation (e.g., processing time, rate limits, authentication needs, cost implications, or what the output looks like). For a generative AI tool with zero annotation coverage, this leaves significant behavioral gaps.

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 a single, efficient sentence that communicates the core purpose and lists key supported models. It's appropriately sized and front-loaded with the main action. However, it could be slightly more structured by separating purpose from model examples for better readability.

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

Completeness2/5

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

For a generative AI tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (image URLs, binary data, metadata), processing behavior, error conditions, or usage constraints. The lack of output schema means the description should ideally cover return values, but it doesn't.

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 the schema already documents all four parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema. It mentions model names but doesn't provide guidance on when to use specific models or size options. Baseline 3 is appropriate when the schema does the heavy lifting.

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?

The description clearly states the action ('Generate images') and the resource ('using AI models via Crazyrouter'), and lists specific model examples. It distinguishes from sibling 'generate_video' by specifying images, but doesn't explicitly contrast with 'chat' or 'list_models'. The purpose is clear but could be more specific about what distinguishes it from other tools.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'generate_video' or 'chat'. It mentions supported models but doesn't explain when to choose one model over another or any prerequisites. There's no explicit when/when-not usage context or comparison to sibling tools.

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

Install Server

Other Tools

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/xujfcn/crazyrouter-mcp'

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