Skip to content

feat(models): add Voyage AI embedding, contextualized, multimodal and rerank providers - #5521

Open
fzowl wants to merge 1 commit into
Tencent:mainfrom
fzowl:feat/voyage-ai-integration
Open

fzowl wants to merge 1 commit into
Tencent:mainfrom
fzowl:feat/voyage-ai-integration

Conversation

@fzowl

@fzowl fzowl commented Nov 14, 2026

Copy link
Copy Markdown

Spring AI has no integration for Voyage AI, whose embedding and rerank models are widely used for retrieval.
This adds one: text embeddings, contextualized chunk embeddings, multimodal embeddings and reranking, with auto-configuration, a starter and reference documentation.

Voyage AI has no official Java SDK, so VoyageAiApi is a RestClient based client in the style of the Mistral AI module.
Every request type checks the constraints that Voyage AI documents for it (known model, supported output dimensions, at most 1000 inputs, auto-chunking rules, URL or base64 media) before anything is sent, and the {"detail": ...} body of an error response becomes the exception message.

What is added:

  • VoyageAiEmbeddingModel, an EmbeddingModel for voyage-4-large, voyage-4, voyage-4-lite, voyage-code-4, voyage-3-large, voyage-3.5, voyage-3.5-lite, voyage-code-3, voyage-finance-2 and voyage-law-2. A request of more than 1000 texts is split into several calls and the vectors keep the order of the texts.
  • VoyageAiContextualizedEmbeddingModel for voyage-context-4 and voyage-context-3. Documents are sent as one string each with enable_auto_chunking and a chunk_size of 32000, queries without chunking. The chunk text that Voyage AI returns is available as the documentData of each embedding. It is not an EmbeddingModel, because one document yields several vectors.
  • VoyageAiMultimodalEmbeddingModel, a DocumentEmbeddingModel (like the Vertex AI one) for voyage-multimodal-3.5 and voyage-multimodal-3. Images are given as URLs, base64 or file bytes, voyage-multimodal-3.5 also takes video/mp4. VoyageAiMultimodalInput combines text and media in one input, which a Document cannot express.
  • VoyageAiDocumentReranker, a RAG DocumentPostProcessor for rerank-3, rerank-3-lite, rerank-2.5 and rerank-2.5-lite, with topK. It is independent of DecisionDocumentReranker.
  • spring-ai-autoconfigure-model-voyage-ai and spring-ai-starter-model-voyage-ai, plus the BOM entries and a reference page.

Two decisions worth a look:

  • There is no default model. A missing model, or a model of another Voyage AI endpoint, fails with an error that names the valid ones, and the application does not start without spring.ai.voyageai.embedding.model. The other models are created when their model property is set.
  • A response without usage.total_tokens fails instead of reporting zero tokens.

Voyage AI also limits the tokens of a request (1M, 320K or 120K depending on the model). There is no Java tokenizer for the Voyage AI models, so the client does not count tokens and the API rejects an over-sized request. The reference documentation says so.

Tested with unit tests against a mock server, an auto-configuration test, integration tests (VoyageAiIT, run when VOYAGE_API_KEY is set) and a run of a Spring Boot application through the starter against the live API: every model, dimensions 256 to 2048, query and document input types, batching over 1000 inputs, images by URL, base64 and file, a video, and the invalid cases.

… rerank providers

Register Voyage AI as a built-in provider for embedding and rerank models.

- Text embeddings (voyage-4-large, voyage-4, voyage-4-lite, voyage-code-4,
  voyage-3-large, voyage-3.5, voyage-3.5-lite, voyage-code-3,
  voyage-finance-2, voyage-law-2) on POST /embeddings, with input_type
  (document/query) and output_dimension for the Matryoshka models. The
  fixed-width models send no output_dimension.
- Contextualized embeddings (voyage-context-4, voyage-context-3) on
  POST /contextualizedembeddings. Documents go as a flat list with
  enable_auto_chunking and chunk_size 32000; every text must come back as
  exactly one chunk. Queries go as one-element lists without auto-chunking.
- Multimodal embeddings (voyage-multimodal-3.5, voyage-multimodal-3) on
  POST /multimodalembeddings, with text and base64 image inputs, so they work
  with image vector indexing.
- Rerank (rerank-3, rerank-3-lite, rerank-2.5, rerank-2.5-lite) on POST /rerank,
  with optional top_k and return_documents.
- Voyage's {"detail": "..."} error body is surfaced as the error message.
- Catalog entries carry dimensions, context windows and per-million-token
  prices. The model is never defaulted; the rerank factory now refuses an empty
  model name, as the embedding factory already did.
- There is no official Go SDK, so the protocols are REST clients over the
  shared endpoint, retry and placement helpers. Requests are split only at the
  documented 1000 inputs; tokens are not estimated.

This branch has not been deployed

No deployments
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.

1 participant