Multimodal Understanding
Pass images (URLs or inline Base64 data URIs), PDFs, and multi-image sequences to frontier vision models for OCR, diagram analysis, UI auditing, and structured extraction.
Image Input via OpenAI Chat Protocol
Pass content as an array of text and image_url parts. Use "detail": "low" for fast classification or "high" for dense OCR and code screenshots.
python
import base64, os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["VANIX_API_KEY"],
base_url="https://api.vanix.io/v1",
)
with open("invoice.png", "rb") as f:
b64 = base64.b64encode(f.read()).decode("utf-8")
resp = client.chat.completions.create(
model="gpt-4o",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "Extract vendor, invoice date, and total amount as JSON."},
{
"type": "image_url",
"image_url": {
"url": f"data:image/png;base64,{b64}",
"detail": "high",
},
},
],
}
],
)
print(resp.choices[0].message.content)bash
curl https://api.vanix.io/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $VANIX_API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "Summarize the architecture diagram in 3 bullets."},
{"type": "image_url", "image_url": {"url": "https://example.com/diagram.png", "detail": "high"}}
]
}]
}'Native Anthropic & Gemini Multimodal
- Anthropic (
/v1/messages): Supports{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "..."}}and native{"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "..."}}blocks. - Gemini (
/v1beta/models/*): SupportsinlineData(image/*,application/pdf,audio/*,video/*) insidecontents[].parts.
Image Payload Limits
Resize oversized photographs to <= 2048px on the long edge and prefer JPEG/WebP (quality 85) to minimize input token cost and upload latency.