Skip to main content

langchain-voyageai

This package contains the LangChain integrations for VoyageAI through their voyageai client package.

Installation and Setup

  • Install the LangChain partner package
pip install langchain-voyageai
  • Get an VoyageAI api key and set it as an environment variable (VOYAGE_API_KEY) or use the API key as a parameter in the Client.

Text Embedding Model

See a usage example

from langchain_voyageai import VoyageAIEmbeddings

Voyage-4 Family Models

The latest generation of VoyageAI embedding models with improved quality and flexibility:

# voyage-4: Balanced model for general-purpose and multilingual retrieval
embeddings = VoyageAIEmbeddings(model="voyage-4")

# voyage-4-lite: Optimized for latency and cost, highest batch throughput (1M tokens/batch)
embeddings = VoyageAIEmbeddings(model="voyage-4-lite")

# voyage-4-large: Best retrieval quality for demanding applications
embeddings = VoyageAIEmbeddings(model="voyage-4-large")

All voyage-4 family models support flexible output dimensions (256, 512, 1024, 2048):

embeddings = VoyageAIEmbeddings(
    model="voyage-4",
    output_dimension=512  # Choose from: 256, 512, 1024, 2048
)

Code Embeddings

voyage-code-4 is optimized for code retrieval and supports flexible output dimensions (256, 512, 1024, 2048):

# voyage-code-4: optimized for code retrieval
embeddings = VoyageAIEmbeddings(model="voyage-code-4")

embeddings = VoyageAIEmbeddings(
    model="voyage-code-4",
    output_dimension=512  # Choose from: 256, 512, 1024, 2048
)

Contextualized Chunk Embeddings

voyage-context-4 produces contextualized chunk embeddings, where each chunk is embedded in the context of the other chunks from the same document:

# voyage-context-4: contextualized chunk embeddings for document-aware retrieval
embeddings = VoyageAIEmbeddings(model="voyage-context-4")

It also supports flexible output dimensions (256, 512, 1024, 2048):

embeddings = VoyageAIEmbeddings(
    model="voyage-context-4",
    output_dimension=512  # Choose from: 256, 512, 1024, 2048
)

Custom API Endpoint

You can specify a custom API endpoint using the base_url parameter:

embeddings = VoyageAIEmbeddings(
    model="voyage-3.5",
    base_url="https://ai.mongodb.com/v1"
)

This is useful for MongoDB Atlas users or custom deployments.

Metadata

Release files for langchain-voyageai 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-voyageai 0.4.1
File Size Uploaded
langchain_voyageai-0.4.1.tar.gz 14.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-voyageai 0.4.1
File Interpreter ABI Platform
langchain_voyageai-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 22.2 kB

Release files / langchain_voyageai-0.4.1.tar.gz

Download URL langchain_voyageai-0.4.1.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
294293b35f6973a965b521e51a1d1423d467921fc74ccfac2568ca92775201d1
BLAKE2b-256 checksum
How to use checksums
7621b24ec7cb5d6f8f87b01abfcf183f88365e55ab6a18bf1a50c7467185e3f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / langchain_voyageai-0.4.1-py3-none-any.whl

Download URL langchain_voyageai-0.4.1-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a9c22da5f2e4a48ad2c7108f01d221a6660438d8cfcd587f073d96610d19f8c
BLAKE2b-256 checksum
How to use checksums
aa8f7155079af6e924acd17238a14b6cd07e357eca27c55981628ec5065e2e87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page