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
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | ||
| prompt | Yes |
Implementation Reference
- src/mcp_deepinfra/server.py:47-62 (handler)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)}"
- src/mcp_deepinfra/server.py:32-32 (helper)Configuration for the default model used by the generate_image tool."generate_image": os.getenv("MODEL_GENERATE_IMAGE", "Bria/Bria-3.2"),
- src/mcp_deepinfra/server.py:47-47 (registration)The @app.tool() decorator registers the generate_image function as an MCP tool.@app.tool()
- src/mcp_deepinfra/server.py:48-49 (schema)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."""