Skip to main content
Glama

generate_image

Create custom images from text descriptions using AI image generation. Transform your ideas into visual content by providing descriptive prompts.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelNo
promptYes

Implementation Reference

  • The core handler function for the 'generate_image' tool. It is decorated with @app.tool() for automatic MCP registration and schema inference. Uses DeepInfra's OpenAI-compatible images.generate API to create an image from text prompt and returns the image URL.
    @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)}"
  • Configuration for the default model used by the generate_image tool.
    "generate_image": os.getenv("MODEL_GENERATE_IMAGE", "Bria/Bria-3.2"),
  • The @app.tool() decorator registers the generate_image function as an MCP tool.
    @app.tool()
  • Function signature and docstring define the input schema (prompt: str) and output (str), used by FastMCP for tool schema.
    async def generate_image(prompt: str) -> str: """Generate an image from a text prompt using DeepInfra OpenAI-compatible API."""

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