image_classification
Identify and categorize image content using AI-powered classification to analyze visual data and extract meaningful information from photographs or digital images.
Instructions
Classify an image using DeepInfra OpenAI-compatible API with multimodal model.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image_url | Yes | ||
| model | No |
Implementation Reference
- src/mcp_deepinfra/server.py:184-214 (handler)The handler function for the 'image_classification' tool. It is registered via @app.tool() decorator when enabled, takes an image_url, uses a vision-capable LLM to classify the image contents, and returns JSON-formatted classification.if "all" in ENABLED_TOOLS or "image_classification" in ENABLED_TOOLS: @app.tool() async def image_classification(image_url: str) -> str: """Classify an image using DeepInfra OpenAI-compatible API with multimodal model.""" model = DEFAULT_MODELS["image_classification"] try: response = await client.chat.completions.create( model=model, messages=[ { "role": "user", "content": [ { "type": "text", "text": "Analyze this image and classify what it shows. Provide the main categories and objects visible in the image with confidence scores. Format as JSON." }, { "type": "image_url", "image_url": {"url": image_url} } ] } ], max_tokens=500, ) if response.choices: return response.choices[0].message.content else: return "Unable to classify image" except Exception as e: return f"Error classifying image: {type(e).__name__}: {str(e)}"
- src/mcp_deepinfra/server.py:38-38 (helper)Helper configuration defining the default model ('openai/gpt-4o-mini') for the image_classification tool, configurable via environment variable."image_classification": os.getenv("MODEL_IMAGE_CLASSIFICATION", "openai/gpt-4o-mini"),
- src/mcp_deepinfra/server.py:186-187 (schema)Function signature and docstring defining the input schema (image_url: str) and output (str), used by MCP for tool schema.async def image_classification(image_url: str) -> str: """Classify an image using DeepInfra OpenAI-compatible API with multimodal model."""