Supported image formats
The proxy accepts images in three formats:Base64 JPEG
Raw base64-encoded JPEG data without a data URL prefix
Data URL
Complete data URL with JPEG base64 encoding
HTTP(S) URL
Public URL to a JPEG image (fetched automatically)
Currently, only JPEG images are supported. The proxy converts all formats to
data:image/jpeg;base64,... for compatibility with vision models.How it works
The proxy implements vision support through two key functions:Image conversion: toJpegDataUrl
Located in src/index.js:35-58, this function converts images to JPEG data URLs:
Message building: buildOpenAIImageBlocksFromOllama
Located in src/index.js:60-100, this function converts Ollama-format messages with images to content blocks:
Usage examples
Simple prompt with image (generate API)
Use the/api/generate endpoint with a top-level images array:
Chat with images (chat API)
Use the/api/chat endpoint with images in individual messages:
Using HTTP URLs
The proxy automatically fetches and converts images from URLs:Multiple images
You can include multiple images in a single request:Streaming with images
Vision requests work with streaming responses:Vision-capable models
Not all models support vision. The following default models have vision capabilities:- OpenAI:
gpt-4o,gpt-4o-mini - Google:
gemini-2.5-flash,gemini-2.5-flash-lite
Implementation details
The vision detection logic is insrc/index.js:416-421:
- Converts all images to JPEG data URLs using
toJpegDataUrl - Builds content blocks with both text and image parts
- Sends the structured content to the AI provider
- Returns the response in Ollama format
Error handling
The proxy handles common image errors:Unsupported image type
Unsupported image type
Error:
Unsupported image typeCause: Image is not a string (e.g., binary data, object)Solution: Ensure images are base64 strings, data URLs, or HTTP(S) URLsFailed to fetch image
Failed to fetch image
Error:
failed to fetch image: 404Cause: HTTP URL returned an error statusSolution:- Verify the URL is correct and publicly accessible
- Check that the image exists at the URL
- Ensure no authentication is required
Only JPEG base64 strings or http(s) URLs are supported
Only JPEG base64 strings or http(s) URLs are supported
Error:
Only JPEG base64 strings or http(s) URLs are supportedCause: Image format not recognized (e.g., file:// path, PNG data URL)Solution:- Convert the image to JPEG format
- Use base64 encoding without scheme, with
data:image/jpeg;base64,prefix, or HTTP(S) URL - For local files, read and base64-encode them before sending
Next steps
Supported Models
See which models support vision capabilities
API Reference
Explore the complete API documentation
