Skip to main content
Glama

image_generate

Create custom images from text descriptions using the Flux 1.1 Pro AI model for visual content needs.

Instructions

Generate an image using Flux 1.1 Pro AI model ($0.005)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesImage description
widthNo
heightNo

Implementation Reference

  • The tool is executed by calling the `callTool` function, which maps the tool name to an endpoint and makes a fetch request to the IteraTools API. The `CallToolRequestSchema` handler in `index.js` acts as the dispatcher for `image_generate` (and all other tools).
      const tool = TOOLS.find(t => t.name === name);
      if (!tool) {
        return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true };
      }
      
      try {
        const result = await callTool(tool.endpoint, args);
        return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
      } catch (err) {
        return { content: [{ type: 'text', text: `Error: ${err.message}` }], isError: true };
      }
    });
  • index.js:17-17 (registration)
    The `image_generate` tool is registered in the `TOOLS` array in `index.js`.
    { name: 'image_generate', description: 'Generate an image using Flux 1.1 Pro AI model', inputSchema: { type: 'object', properties: { prompt: { type: 'string', description: 'Image description' }, width: { type: 'number', default: 1024 }, height: { type: 'number', default: 1024 } }, required: ['prompt'] }, endpoint: '/image/generate', price: '$0.005' },
  • The `callTool` helper function handles the actual API request to the IteraTools backend.
    async function callTool(endpoint, params) {
      const fetch = (await import('node-fetch')).default;
      const isGet = ['GET'].includes((TOOLS.find(t => t.endpoint === endpoint) || {}).method);
      
      const url = isGet 
        ? `${BASE_URL}${endpoint}?${new URLSearchParams(params)}`
        : `${BASE_URL}${endpoint}`;
      
      const res = await fetch(url, {
        method: isGet ? 'GET' : 'POST',
        headers: {
          'Content-Type': 'application/json',
          'Authorization': `Bearer ${API_KEY}`,
        },
        body: isGet ? undefined : JSON.stringify(params),
      });
      
      const text = await res.text();
      let data;
      try { data = JSON.parse(text); } catch { data = { raw: text }; }
      
      if (!res.ok) {
        if (res.status === 402) {
          throw new Error(`Insufficient credits. Add credits at https://iteratools.com. Cost: ${TOOLS.find(t=>t.endpoint===endpoint)?.price || 'see docs'}`);
        }
        throw new Error(`API error ${res.status}: ${text.substring(0, 200)}`);
      }
      
      return data;
    }

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/fredpsantos33/itera-tools-mcp'

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