analyze_image
Analyze images by uploading a URL and asking questions. Identify objects, read text, describe scenes, or analyze compositions using AI.
Instructions
Analyze an image using Gemini Vision AI.
Upload an image and ask questions about it. Can identify objects, read text, describe scenes, analyze compositions, and more. Cost: ~2 credits.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image_url | Yes | URL of the image to analyze | |
| prompt | No | Question or instruction about the image (e.g., "What product is shown?", "Read the text in this image") | Describe this image in detail |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/yaparai/tools/ai.py:39-62 (handler)The core handler function for the 'analyze_image' tool. It accepts `image_url` (str) and `prompt` (str, default 'Describe this image in detail'), creates a YaparAIClient, and calls `gemini_analyze_image` to send the request to the Gemini Vision AI API.
async def analyze_image( image_url: str, prompt: str = "Describe this image in detail", ) -> dict: """ Analyze an image using Gemini Vision AI. Upload an image and ask questions about it. Can identify objects, read text, describe scenes, analyze compositions, and more. Cost: ~2 credits. Args: image_url: URL of the image to analyze prompt: Question or instruction about the image (e.g., "What product is shown?", "Read the text in this image") Returns: Dict with analysis text and details. """ client = YaparAIClient() return await client.gemini_analyze_image({ "image_url": image_url, "prompt": prompt, }) - src/yaparai/tools/ai.py:39-62 (schema)The function signature and docstring define the input schema: `image_url: str` (required) and `prompt: str` (optional, defaulting to 'Describe this image in detail'). The return is a dict with analysis text and details.
async def analyze_image( image_url: str, prompt: str = "Describe this image in detail", ) -> dict: """ Analyze an image using Gemini Vision AI. Upload an image and ask questions about it. Can identify objects, read text, describe scenes, analyze compositions, and more. Cost: ~2 credits. Args: image_url: URL of the image to analyze prompt: Question or instruction about the image (e.g., "What product is shown?", "Read the text in this image") Returns: Dict with analysis text and details. """ client = YaparAIClient() return await client.gemini_analyze_image({ "image_url": image_url, "prompt": prompt, }) - src/yaparai/server.py:145-147 (registration)Registration of the tool via `mcp.tool(analyze_image)` in the FastMCP server under the '# AI Tools (2)' section.
# AI Tools (2) mcp.tool(generate_text) mcp.tool(analyze_image) - src/yaparai/client.py:185-187 (helper)The API client method `gemini_analyze_image` that sends the POST request to '/v1/ai/gemini/analyze-image' with the payload containing image_url and prompt.
async def gemini_analyze_image(self, payload: dict) -> dict: """Gemini Vision image analysis.""" return await self._request("POST", "/v1/ai/gemini/analyze-image", json=payload) - src/yaparai/server.py:55-58 (helper)Import of the `analyze_image` function from `yaparai.tools.ai` into the main server module.
from yaparai.tools.ai import ( generate_text, analyze_image, )