Skip to main content
Glama
phuihock
by phuihock

generate_image

Create images from text descriptions using AI-powered image generation. Transform written prompts into visual content through the DeepInfra API.

Instructions

Generate an image from a text prompt using DeepInfra OpenAI-compatible API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The generate_image tool handler, registered with @app.tool(), generates an image URL from a text prompt using DeepInfra's OpenAI-compatible images.generate API.
    @app.tool()
    async def generate_image(prompt: str) -> str:
        """Generate an image from a text prompt using DeepInfra OpenAI-compatible API."""
        model = DEFAULT_MODELS["generate_image"]
        try:
            response = await client.images.generate(
                model=model,
                prompt=prompt,
                n=1,
            )
            if response.data:
                return f"Generated image URL: {response.data[0].url}"
            else:
                return "No image generated"
        except Exception as e:
            return f"Error generating image: {type(e).__name__}: {str(e)}"
  • Global DEFAULT_MODELS dictionary providing the default model ('Bria/Bria-3.2') for the generate_image tool.
    DEFAULT_MODELS = {
        "generate_image": os.getenv("MODEL_GENERATE_IMAGE", "Bria/Bria-3.2"),
        "text_generation": os.getenv("MODEL_TEXT_GENERATION", "meta-llama/Llama-2-7b-chat-hf"),
        "embeddings": os.getenv("MODEL_EMBEDDINGS", "sentence-transformers/all-MiniLM-L6-v2"),
        "speech_recognition": os.getenv("MODEL_SPEECH_RECOGNITION", "openai/whisper-large-v3"),
        "zero_shot_image_classification": os.getenv("MODEL_ZERO_SHOT_IMAGE_CLASSIFICATION", "openai/gpt-4o-mini"),
        "object_detection": os.getenv("MODEL_OBJECT_DETECTION", "openai/gpt-4o-mini"),
        "image_classification": os.getenv("MODEL_IMAGE_CLASSIFICATION", "openai/gpt-4o-mini"),
        "text_classification": os.getenv("MODEL_TEXT_CLASSIFICATION", "microsoft/DialoGPT-medium"),
        "token_classification": os.getenv("MODEL_TOKEN_CLASSIFICATION", "microsoft/DialoGPT-medium"),
        "fill_mask": os.getenv("MODEL_FILL_MASK", "microsoft/DialoGPT-medium"),
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the API source but lacks details on rate limits, authentication needs, output format, quality constraints, or error handling. For a tool that likely involves external API calls and image generation, this is a significant gap in transparency.

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?

The description is a single, efficient sentence that front-loads the core functionality ('Generate an image from a text prompt') and adds necessary context ('using DeepInfra OpenAI-compatible API'). There is no wasted text, making it highly concise and well-structured.

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

Completeness3/5

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

Given the tool's complexity (image generation via external API), no annotations, and an output schema that likely handles return values, the description is minimally complete. It covers the basic purpose but lacks usage guidelines, behavioral details, and parameter semantics, leaving gaps that could hinder effective tool selection and invocation.

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?

The description adds minimal meaning beyond the input schema, which has 0% coverage. It implies the 'prompt' parameter is a text input for image generation but doesn't elaborate on format, length, or content guidelines. With one parameter and low schema coverage, the description partially compensates but leaves key details unspecified, aligning with the baseline for moderate coverage.

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 an image') and the resource ('from a text prompt'), specifying the API source ('DeepInfra OpenAI-compatible API'). It distinguishes from siblings like text_generation or image_classification by focusing on image creation rather than text processing or analysis. However, it doesn't explicitly contrast with all siblings, such as zero_shot_image_classification, which also involves images.

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. It doesn't mention scenarios like creative image generation, limitations compared to other tools, or prerequisites. For example, it doesn't clarify if this is for artistic prompts versus technical diagrams, or how it differs from text_generation for visual content.

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/phuihock/mcp-deeinfra'

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