Skip to main content
APIYI provides powerful image understanding capabilities, supporting deep analysis and understanding of images using various advanced AI models. Through a unified OpenAI API format, you can easily implement image recognition, scene description, OCR text recognition, and other functions.
🔍 Intelligent Visual Analysis Supports various visual tasks including object recognition, scene understanding, text extraction, sentiment analysis, and more, enabling AI to truly “understand” images.

🌟 Core Features

  • 🎯 Multi-Model Support: Top multimodal models like the Gemini 3, GPT-5, and Claude 4 series
  • 📸 Flexible Input: Supports URL links and Base64 encoded images
  • 🌏 Chinese Optimization: Perfect support for Chinese scene understanding and text recognition
  • ⚡ Fast Response: High-performance inference with second-level results
  • 💰 Cost Control: Multiple model options to meet different budget requirements

📋 Supported Vision Models

The following are current mainstream multimodal recommendations. Model IDs may change with new releases — always defer to the console.
Most chat models now support multimodal image input: the table above lists common recommendations, not the full set. Mainstream models including the GPT-5, Gemini 3, Claude 4 series, Grok 4, Qwen, GLM, and Kimi mostly accept image input.

🚀 Quick Start

1. Basic Example - Image URL

2. Local Image Example - Base64 Encoding

3. Advanced Example - Multi-Image Comparison

4. cURL Example (Command Line)

Image URL method:
Local image Base64 method (encode the image to Base64, then embed it in the request body):
Prefer Base64 upload for reliability: with the image URL method, the server has to download the image in real time first — if the image host responds slowly or restricts access, the download fails. Base64 embeds the image data directly in the request body, with no dependency on any external download, so it is more stable. Both methods are officially supported. Base64 is about 1.33x the size of the original image, so consider compressing large images before encoding.

5. Common Error: Image URL Download Timeout

When using the image URL method, you may receive an error like this:
This means the server timed out while downloading the image from the URL — it has nothing to do with the model, your API key, or your quota. Common causes:
  1. The image host / origin server responds slowly, or is unfriendly to certain network regions
  2. The image is too large and the download exceeds the time limit
  3. The URL has hotlink protection, requires login, or is not a public direct link
Solutions:
  • Switch to Base64 (data URI) upload (recommended, see Example 2 above) — the image data is submitted directly in the request body, completely bypassing the download step, which is the most stable option
  • Use a faster, publicly accessible direct image link
  • Compress the image and retry

6. Common Error: invalid base64 data (URL Mistakenly Placed in the Base64 Field)

If you receive a 400 error like the following (Claude-series wording shown here; other model series phrase it slightly differently, but the key signature is invalid base64 data):
It usually means an image URL was pasted into the Base64 data slot of the data URI:
Whatever follows the data:image/...;base64, prefix must be the Base64-encoded content of the image file itself, not an image link. The URL method and the Base64 method are two mutually exclusive ways of passing an image — they cannot be mixed. A common cause: the client code always goes through a data URI concatenation path, so remote image URLs also get concatenated in. Correct usage, side by side:
Self-check: decide by the image source before sending — if the string starts with http, use the URL method; only Base64-encode and build a data URI otherwise. Also, a valid Base64 string never contains characters like :// or ? — if you see them after base64,, a link was almost certainly concatenated in.

7. Common Error: Declared Media Type Doesn’t Match the Actual Image Format

If you receive a 400 error like the following (the key signature is The image was specified using the image/png media type, but the image appears to be a image/jpeg image):
What it means: this error comes from the upstream model service’s input validation (Bedrock Runtime: InvokeModel, ValidationException in the example indicates the request reached a Claude-series upstream channel and was rejected at the parameter-validation stage). The message is remarkably literal:
  • Your data URI declares the image as PNG (data:image/png;base64,...)
  • But after decoding the Base64, the upstream inspected the file header (magic bytes) and found the actual content is JPEG
  • Declaration and content disagree → 400. The Base64 encoding itself is fine — the media type in the prefix is what’s wrong
Common causes:
  1. MIME type inferred from the file extension, but the extension lies — the file is named xxx.png but is really a JPEG with a renamed extension (download tools, chat apps, and screenshot tools all do this)
  2. image/png (or image/jpeg) hardcoded in the client code, with every image getting the same prefix regardless of format
  3. The image went through a processing pipeline that changed its format, but the filename stayed the same
Fix: never trust the extension — sniff the real MIME type from the file’s magic bytes before building the data URI:
Alternatively, re-encode with PIL — this guarantees declaration matches content in one step (and lets you compress and strip odd frames along the way):
Self-check: file xxx.png (macOS / Linux command line) reveals a file’s true format in one second; in Python, Image.open(path).format does the same. Model series differ in how strictly they validate the media type — some let mismatches through, while the Claude series (especially via the Bedrock channel) is the strictest. Write your code so the declaration always matches the content, and you’ll be safe on every model.
GPT-5 series parameter differences: if you switch the examples to a GPT-5 series model such as gpt-5.5 / gpt-5.4, note that:
  1. Use max_completion_tokens instead of max_tokens
  2. temperature only supports 1 (leave it at the default — do not pass other values)
  3. Do not pass the top_p parameter
The Gemini and Claude series have no such restrictions and work normally with max_tokens, temperature, etc.

🎯 Common Use Cases

1. Product Recognition and Analysis

2. Document OCR Recognition

3. Medical Imaging Assistance

4. Security Surveillance Analysis

💡 Best Practices

Image Preprocessing Recommendations

  1. Format Support: Mainstream formats like JPEG, PNG, GIF, WebP
  2. Size Limit: Recommended single image under 20MB
  3. Resolution: Higher resolution images achieve better recognition
  4. Compression: Moderate compression to improve transfer speed

Prompt Optimization

Error Handling

🔧 Advanced Features

1. Streaming Output

For lengthy analyses, streaming output provides better user experience:

2. Multi-turn Conversation

Maintain context for in-depth analysis:

3. Combined with Function Calling

📊 Performance Comparison

🚨 Important Notes

  1. Privacy Protection: Do not upload images containing sensitive information
  2. Compliant Usage: Follow relevant laws and regulations, do not use for illegal purposes
  3. Result Verification: AI analysis results are for reference only, important decisions require manual review
  4. Cost Control: Choose models reasonably to avoid unnecessary expenses
💡 Pro Tip: Test first with cost-effective models like Gemini 3.5 Flash or Gemini 2.5 Flash, then switch to advanced models like Gemini 3.1 Pro or GPT-5.5 for production once you’ve confirmed quality. For more available models, see Popular Models or the console model list.