Improve docs for max image sizes

This commit is contained in:
Richard Feldman 2025-07-02 16:23:20 -04:00
parent fe905f1fd2
commit 97c1abbeae
No known key found for this signature in database
10 changed files with 33 additions and 1 deletions

View file

@ -438,6 +438,9 @@ impl LanguageModel for AnthropicModel {
}
fn max_image_size(&self) -> u64 {
// Anthropic documentation: https://docs.anthropic.com/en/docs/build-with-claude/vision#faq
// FAQ section: "Is there a limit to the image file size I can upload?"
// "API: Maximum 5MB per image"
5_242_880 // 5 MiB - Anthropic's stated maximum
}

View file

@ -703,6 +703,8 @@ impl LanguageModel for CloudLanguageModel {
if self.model.supports_images {
// Use a conservative limit that works across all providers
// Anthropic has the smallest limit at 5 MiB
// Anthropic documentation: https://docs.anthropic.com/en/docs/build-with-claude/vision#faq
// "API: Maximum 5MB per image"
5_242_880 // 5 MiB
} else {
0

View file

@ -218,6 +218,9 @@ impl LanguageModel for CopilotChatLanguageModel {
fn max_image_size(&self) -> u64 {
if self.model.supports_vision() {
// OpenAI documentation: https://help.openai.com/en/articles/8983719-what-are-the-file-upload-size-restrictions
// "For images, there's a limit of 20MB per image."
// GitHub Copilot uses OpenAI models under the hood
20_971_520 // 20 MB - GitHub Copilot uses OpenAI models
} else {
0

View file

@ -351,6 +351,9 @@ impl LanguageModel for GoogleLanguageModel {
fn max_image_size(&self) -> u64 {
if self.model.supports_images() {
// Google Gemini documentation: https://ai.google.dev/gemini-api/docs/image-understanding
// "Note: Inline image data limits your total request size (text prompts, system instructions, and inline bytes) to 20MB."
// "For larger requests, upload image files using the File API."
20_971_520 // 20 MB - Google Gemini's file API limit
} else {
0

View file

@ -412,6 +412,10 @@ impl LanguageModel for LmStudioLanguageModel {
fn max_image_size(&self) -> u64 {
if self.model.supports_images {
// LM Studio documentation: https://lmstudio.ai/docs/typescript/llm-prediction/image-input
// While not explicitly stated, LM Studio uses a standard 20MB limit
// matching OpenAI's documented limit: https://help.openai.com/en/articles/8983719-what-are-the-file-upload-size-restrictions
// "For images, there's a limit of 20MB per image."
20_971_520 // 20 MB - Default limit for local models
} else {
0

View file

@ -319,6 +319,10 @@ impl LanguageModel for MistralLanguageModel {
fn max_image_size(&self) -> u64 {
if self.model.supports_images() {
// Mistral documentation: https://www.infoq.com/news/2025/03/mistral-ai-ocr-api/
// "The API is currently limited to files that do not exceed 50MB in size or 1,000 pages"
// Also confirmed in https://github.com/everaldo/mcp-mistral-ocr/blob/master/README.md
// "Maximum file size: 50MB (enforced by Mistral API)"
52_428_800 // 50 MB - Mistral's OCR API limit
} else {
0

View file

@ -367,6 +367,8 @@ impl LanguageModel for OllamaLanguageModel {
fn max_image_size(&self) -> u64 {
if self.model.supports_vision.unwrap_or(false) {
// Ollama documentation: https://github.com/ollama/ollama/releases/tag/v0.1.15
// "Images up to 100MB in size are supported."
104_857_600 // 100 MB - Ollama's documented API limit
} else {
0

View file

@ -303,8 +303,11 @@ impl LanguageModel for OpenAiLanguageModel {
}
fn max_image_size(&self) -> u64 {
0 // OpenAI models don't currently support images in this implementation
// OpenAI documentation: https://help.openai.com/en/articles/8983719-what-are-the-file-upload-size-restrictions
// "For images, there's a limit of 20MB per image."
// Note: OpenAI models don't currently support images in this implementation
// When enabled, OpenAI supports up to 20MB (20_971_520 bytes)
0
}
fn supports_tool_choice(&self, choice: LanguageModelToolChoice) -> bool {

View file

@ -409,6 +409,10 @@ impl LanguageModel for OpenRouterLanguageModel {
fn max_image_size(&self) -> u64 {
if self.model.supports_images.unwrap_or(false) {
// OpenRouter documentation: https://openrouter.ai/docs/features/images-and-pdfs
// While not explicitly stated, OpenRouter appears to follow OpenAI's standard
// which is documented at: https://help.openai.com/en/articles/8983719-what-are-the-file-upload-size-restrictions
// "For images, there's a limit of 20MB per image."
20_971_520 // 20 MB - OpenRouter's default limit
} else {
0

View file

@ -306,6 +306,10 @@ impl LanguageModel for VercelLanguageModel {
}
fn max_image_size(&self) -> u64 {
// Vercel AI SDK uses standard provider limits. Since it supports multiple providers,
// we use a conservative 20MB limit which matches OpenAI's documented limit:
// https://help.openai.com/en/articles/8983719-what-are-the-file-upload-size-restrictions
// "For images, there's a limit of 20MB per image."
20_971_520 // 20 MB - Default limit for Vercel AI SDK
}