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

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"),
    }

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