Skip to main content
Glama

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
NameRequiredDescriptionDefault
image_urlYes
modelNo

Implementation Reference

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

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