Skip to content

Conversation

Sameerlite
Copy link
Collaborator

Title

Add image URL to base64 conversion for Anthropic Messages API

Relevant issues

Fixes LIT-1068

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🆕 New Feature

Changes

  • Added image URL to base64 conversion for Anthropic Messages API endpoints
  • Anthropic provider: Keeps image URLs as-is (no conversion needed)
  • Bedrock provider: Converts image URLs to base64 format
  • Vertex AI provider: Converts image URLs to base64 format
  • Added process_image_content() method to Bedrock and Vertex AI config classes
  • Added comprehensive tests for all three providers in test_anthropic_experimental_pass_through_messages_handler.py
  • Follows same pattern as existing completions endpoint image handling
image

This ensures image URLs work correctly across all providers in the Anthropic Messages API flow, matching the behavior of the completions endpoint.

Copy link

vercel bot commented Oct 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
litellm Error Error Oct 13, 2025 8:13am

Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed

# Check if source has a URL that needs conversion
if isinstance(source, str) and (source.startswith("http://") or source.startswith("https://")):
try:
base64_data = convert_url_to_base64(source)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for async requests please use async_convert_url_to_base64.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image The async handler is using all the sync methods. Can't add a async method inside a sync method. Else I will have to make everything async

Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed on call, waiting on async version of this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants