Skip to content

feat(voyage): add multimodal embedding support for voyage-multimodal-3/3.5 - #24972

Merged
1 commit merged into
BerriAI:litellm_ishaan_april7_2from
silencedoctor:feat/voyage-multimodal-embedding
Apr 8, 2026
Merged

1 commit merged into
BerriAI:litellm_ishaan_april7_2from
silencedoctor:feat/voyage-multimodal-embedding

Conversation

@silencedoctor

Copy link
Copy Markdown
Contributor

Summary

Voyage multimodal embedding models (voyage-multimodal-3, voyage-multimodal-3.5) currently route to the standard /v1/embeddings endpoint, which does not support multimodal inputs (images, videos). This PR adds proper support by:

  • Creating VoyageMultimodalEmbeddingConfig that routes to the correct /v1/multimodalembeddings endpoint
  • Transforming inputs to the Voyage multimodal format (supporting text, image_url, image_base64, video_url, video_base64 content types)
  • Converting OpenAI-style image_url content blocks (with nested {"url": "..."}) to Voyage's flat format
  • Automatically detecting base64 data URIs in image_url blocks and converting them to image_base64 type
  • Adding voyage-multimodal-3.5 to the model pricing registry

Fixes #24957

Changes

File Description
litellm/llms/voyage/embedding/transformation_multimodal.py New VoyageMultimodalEmbeddingConfig class
litellm/utils.py Route multimodal models to new config
litellm/__init__.py Register new config export
litellm/_lazy_imports_registry.py Register lazy import
litellm/model_prices_and_context_window_backup.json Add voyage-multimodal-3.5, add supports_vision flag
tests/test_litellm/llms/voyage/embedding/test_voyage_multimodal_embedding.py 32 unit tests

Usage

import litellm

# Text-only input
response = litellm.embedding(
    model="voyage/voyage-multimodal-3",
    input=["Hello world"],
)

# Multimodal input (text + image)
response = litellm.embedding(
    model="voyage/voyage-multimodal-3",
    input=[{
        "content": [
            {"type": "text", "text": "A photo of a cat"},
            {"type": "image_url", "image_url": "https://example.com/cat.jpg"},
        ]
    }],
)

# OpenAI-style image_url format also supported
response = litellm.embedding(
    model="voyage/voyage-multimodal-3.5",
    input=[{
        "content": [
            {"type": "text", "text": "Describe this"},
            {"type": "image_url", "image_url": {"url": "https://example.com/img.png"}},
        ]
    }],
)

PR Checklist

  • Tests added (tests/test_litellm/llms/voyage/embedding/test_voyage_multimodal_embedding.py - 32 tests)
  • All unit tests pass
  • Linting passes
  • PR scope is isolated - only adds Voyage multimodal embedding support

What type of PR is this?

🆕 New Feature

Reference

…3/3.5

Route voyage-multimodal-* models to the correct /v1/multimodalembeddings
endpoint and transform inputs to the Voyage multimodal format. Supports
text, image_url, image_base64, video_url, and video_base64 content types.

Fixes BerriAI#24957

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Apr 2, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Apr 2, 2026 6:53am

Request Review

@codspeed

codspeed Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 16 untouched benchmarks


Comparing silencedoctor:feat/voyage-multimodal-embedding (4ca6258) with main (d1df4e8)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds proper multimodal embedding support for Voyage's voyage-multimodal-3 and voyage-multimodal-3.5 models by introducing VoyageMultimodalEmbeddingConfig, which routes requests to the /v1/multimodalembeddings endpoint and transforms OpenAI-style multimodal content blocks into Voyage's input format. The approach is well-structured and consistent with how the existing VoyageContextualEmbeddingConfig is integrated.

Key changes:

  • New VoyageMultimodalEmbeddingConfig class with input transformation, URL routing, and response parsing
  • voyage-multimodal-3.5 pricing entry added to the model backup JSON; supports_vision flag added to voyage-multimodal-3
  • Routing wired into get_optional_params_embeddings and ProviderConfigManager.get_provider_embedding_config in utils.py
  • 32 unit tests, all mocked (no live network calls)

Issues found:

  • An empty list [] passed as input falls through the type dispatch and is silently converted to a single-item request containing the string "[]", which may produce an unexpected embedding instead of an error
  • Mixed-type lists (e.g. first element is a str but later elements are dicts) are processed entirely according to the first element's type, silently corrupting the later items
  • is_multimodal_embeddings uses a hardcoded substring check ("multimodal" in model.lower()), which deviates from the team rule that model-specific routing flags should live in the model JSON and be read via get_model_info; this follows existing precedent in VoyageContextualEmbeddingConfig but is worth aligning
  • prompt_tokens in the Usage object is set to total_tokens rather than text_tokens, conflating text and image pixel costs

Confidence Score: 4/5

  • Safe to merge after addressing the empty-list silent mis-transformation, which can produce an unexpected embedding result rather than an error.
  • One P1 logic bug exists: passing an empty list silently produces a payload containing the string "[]" instead of returning an empty result or raising. The remaining findings are P2 style/quality issues. The core feature logic is sound, tests are comprehensive and mock-only, and the routing integration follows established codebase patterns.
  • litellm/llms/voyage/embedding/transformation_multimodal.py — specifically the _convert_input_to_multimodal method's empty-list handling and mixed-type list behavior.

Important Files Changed

Filename Overview
litellm/llms/voyage/embedding/transformation_multimodal.py New VoyageMultimodalEmbeddingConfig class — routes to /v1/multimodalembeddings endpoint; has a silent empty-list bug and mixed-type list issue in input conversion, and conflates prompt_tokens with total_tokens in usage.
litellm/utils.py Adds multimodal routing in get_optional_params_embeddings and ProviderConfigManager.get_provider_embedding_config — consistent with existing contextual pattern.
litellm/model_prices_and_context_window_backup.json Adds voyage-multimodal-3.5 pricing entry and adds supports_vision flag to voyage-multimodal-3; pricing matches voyage-multimodal-3.
tests/test_litellm/llms/voyage/embedding/test_voyage_multimodal_embedding.py 32 unit tests with mocked HTTP responses covering URL generation, param mapping, input conversion, response parsing, and config routing — no live network calls.
litellm/init.py TYPE_CHECKING export for VoyageMultimodalEmbeddingConfig added correctly.
litellm/_lazy_imports_registry.py Lazy import registry entries for VoyageMultimodalEmbeddingConfig added correctly.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["litellm.embedding(model='voyage/...')"] --> B{Provider = VOYAGE?}
    B -- Yes --> C{is_contextualized_embeddings?}
    C -- Yes --> D[VoyageContextualEmbeddingConfig\n/v1/contextualizedembeddings]
    C -- No --> E{is_multimodal_embeddings?}
    E -- Yes --> F[VoyageMultimodalEmbeddingConfig\n/v1/multimodalembeddings]
    E -- No --> G[VoyageEmbeddingConfig\n/v1/embeddings]
    F --> H[_convert_input_to_multimodal]
    H --> I{input type?}
    I -- str --> J[Wrap in text content block]
    I -- "List[str]" --> K[Wrap each in text content block]
    I -- "List[dict]" --> L[Convert each block via\n_convert_content_block]
    I -- "empty list []" --> M["⚠️ Falls through to str(input) = '[]'"]
    L --> N{block type?}
    N -- text --> O[Pass through]
    N -- image_url str --> P[Voyage image_url]
    N -- "image_url {url:...}" --> Q[Extract URL → Voyage image_url]
    N -- "data: URI" --> R[Convert to image_base64]
    N -- video_url/video_base64 --> S[Pass through]
Loading

Reviews (1): Last reviewed commit: "feat(voyage): add multimodal embedding s..." | Re-trigger Greptile

Comment on lines +117 to +134
if isinstance(input, list) and len(input) > 0:
if isinstance(input[0], str):
return [{"content": [{"type": "text", "text": text}]} for text in input]

if isinstance(input[0], dict):
inputs = []
for item in input:
if "content" in item:
content = item["content"]
converted = []
for block in content:
converted.append(_convert_content_block(block))
inputs.append({"content": converted})
else:
inputs.append({"content": [_convert_content_block(item)]})
return inputs

return [{"content": [{"type": "text", "text": str(input)}]}]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Empty list silently produces wrong payload

When input is an empty list ([]), the guard len(input) > 0 is False, so the function falls through to the catch-all at line 134:

return [{"content": [{"type": "text", "text": str(input)}]}]

This returns [{"content": [{"type": "text", "text": "[]"}]}] — a single-element request containing the literal string "[]". Depending on the API, this may silently return an embedding for that string rather than raising an error, which is unexpected behavior.

Suggested change
if isinstance(input, list) and len(input) > 0:
if isinstance(input[0], str):
return [{"content": [{"type": "text", "text": text}]} for text in input]
if isinstance(input[0], dict):
inputs = []
for item in input:
if "content" in item:
content = item["content"]
converted = []
for block in content:
converted.append(_convert_content_block(block))
inputs.append({"content": converted})
else:
inputs.append({"content": [_convert_content_block(item)]})
return inputs
return [{"content": [{"type": "text", "text": str(input)}]}]
if isinstance(input, list):
if len(input) == 0:
return []
if isinstance(input[0], str):
return [{"content": [{"type": "text", "text": text}]} for text in input]
if isinstance(input[0], dict):
inputs = []
for item in input:
if "content" in item:
content = item["content"]
converted = []
for block in content:
converted.append(_convert_content_block(block))
inputs.append({"content": converted})
else:
inputs.append({"content": [_convert_content_block(item)]})
return inputs
return [{"content": [{"type": "text", "text": str(input)}]}]

if block_type == "image_base64":
return {
"type": "image_base64",
"image_base64": block.get("image_base64", ""),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Hardcoded model-detection flag should live in model JSON

is_multimodal_embeddings hard-codes routing logic by doing "multimodal" in model.lower(). Per the team's rule on model-specific flags, this logic should instead be expressed as a field in model_prices_and_context_window_backup.json (e.g. "litellm_multimodal_embedding": true) and resolved at runtime via get_model_info. That way future multimodal Voyage models are handled automatically without a code change.

Note that the existing VoyageContextualEmbeddingConfig.is_contextualized_embeddings uses the same substring-match pattern, so this is following established codebase precedent — but the custom rule flags both as the preferred pattern to migrate away from.

Rule Used: What: Do not hardcode model-specific flags in the ... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +117 to +132
if isinstance(input, list) and len(input) > 0:
if isinstance(input[0], str):
return [{"content": [{"type": "text", "text": text}]} for text in input]

if isinstance(input[0], dict):
inputs = []
for item in input:
if "content" in item:
content = item["content"]
converted = []
for block in content:
converted.append(_convert_content_block(block))
inputs.append({"content": converted})
else:
inputs.append({"content": [_convert_content_block(item)]})
return inputs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Mixed-type list only inspects first element

The type-dispatch checks isinstance(input[0], str) / isinstance(input[0], dict), meaning the type of the first element governs how all elements are processed. A mixed list like ["plain text", {"content": [...]}] will silently stringify the dict by passing it through the str-branch list comprehension. Consider validating that all elements are the same type, or raising an explicit error for heterogeneous lists.

Comment on lines +155 to +163
logging_obj: LiteLLMLoggingObj,
api_key: Optional[str] = None,
request_data: dict = {},
optional_params: dict = {},
litellm_params: dict = {},
) -> EmbeddingResponse:
try:
raw_response_json = raw_response.json()
except Exception:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 prompt_tokens conflated with total_tokens

The Voyage multimodal usage response includes text_tokens and image_pixels fields. Both prompt_tokens and total_tokens are currently set to total_tokens, which already includes pixel-based image cost. Setting prompt_tokens to text_tokens would be more semantically accurate for multimodal usage accounting.

@codecov

codecov Bot commented Apr 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.63158% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...llms/voyage/embedding/transformation_multimodal.py 92.63% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

lgtm

@ghost
ghost changed the base branch from main to litellm_ishaan_april7_2 April 8, 2026 04:14
@ghost
ghost merged commit efcadef into BerriAI:litellm_ishaan_april7_2 Apr 8, 2026
54 of 61 checks passed
@silencedoctor

Copy link
Copy Markdown
Contributor Author

Hi @ishaan-berri, sorry to bother you — just wanted to gently flag something in case it's helpful.

I noticed this PR is marked merged, but it looks like it went into the litellm_ishaan_april7_2 staging branch rather than main, and that staging branch doesn't seem to have been merged forward yet:

  • The squash commit efcadef6ed doesn't appear on main or in any *-stable tag
  • The only ref containing it is upstream/litellm_ishaan_april7_2

Totally possible I'm missing context here — would you mind taking a quick look when you get a chance? Happy to re-open this against main or rebase if that would make things easier on your side. Thanks so much for all your work on the project!

@silencedoctor

Copy link
Copy Markdown
Contributor Author

Hi @ishaan-berri, sorry to bother you — just wanted to gently flag something in case it's helpful.

I noticed this PR is marked merged, but it looks like it went into the litellm_ishaan_april7_2 staging branch rather than main, and that staging branch doesn't seem to have been merged forward yet:

  • The squash commit efcadef6ed doesn't appear on main or in any *-stable tag
  • The only ref containing it is upstream/litellm_ishaan_april7_2

Totally possible I'm missing context here — would you mind taking a quick look when you get a chance?

In the meantime, I rebuilt the video-support delta on top of the current main (which already has the base multimodal config from #30193) as #32228. Happy to iterate on that one if the approach looks right, or close it if you'd rather forward-merge litellm_ishaan_april7_2 instead. Thanks so much for all your work on the project!

silencedoctor added a commit to silencedoctor/litellm that referenced this pull request Jul 30, 2026
Voyage's multimodal embeddings API supports MP4 video via `video_url`
and `video_base64` content blocks in addition to text and image. The
existing `VoyageMultimodalEmbeddingConfig` added in BerriAI#30193 does not
handle these — video blocks fall through to the identity branch, so
OpenAI-style nested `{"url": ...}` dicts are not unwrapped and
`data:video/mp4;base64,...` data URIs are not converted to the
`video_base64` shape Voyage expects.

Extend `_normalize_content_item` with a `video_url` branch that mirrors
the existing `image_url` logic:

- unwrap `{"url": ...}` dicts (OpenAI-style)
- convert `data:video/mp4;base64,...` URIs to `video_base64` blocks
- raise `ValueError` on missing/empty video URLs
- pass explicit `video_base64` blocks through unchanged

6 new unit tests cover each path plus an end-to-end request transform
with mixed text + video content.

Refs BerriAI#24957 — this complements BerriAI#30193 by closing the video gap that
was in the original BerriAI#24972 draft but never landed on main.
This pull request was closed.

This branch was successfully deployed

1 active deployment
Preview — 4ca62588 Deployed Apr 2, 2026 by vercel[bot]
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.

[Bug]: Voyage multimodal embedding models (voyage-multimodal-3/3.5) route to wrong API endpoint

1 participant