clients/new-js/packages/ai-embeddings/voyageai/README.md
This package provides a Voyage AI embedding provider for Chroma.
npm install @chroma-core/voyageai
import { ChromaClient } from 'chromadb';
import { VoyageAIEmbeddingFunction } from '@chroma-core/voyageai';
// Initialize the embedder
const embedder = new VoyageAIEmbeddingFunction({
apiKey: 'your-api-key', // Or set VOYAGE_API_KEY env var
modelName: 'voyage-2',
});
// Create a new ChromaClient
const client = new ChromaClient({
path: 'http://localhost:8000',
});
// Create a collection with the embedder
const collection = await client.createCollection({
name: 'my-collection',
embeddingFunction: embedder,
});
// Add documents
await collection.add({
ids: ["1", "2", "3"],
documents: ["Document 1", "Document 2", "Document 3"],
});
// Query documents
const results = await collection.query({
queryTexts: ["Sample query"],
nResults: 2,
});
Set your Voyage AI API key as an environment variable:
export VOYAGE_API_KEY=your-api-key
Get your API key from Voyage AI.
VOYAGE_API_KEY)Voyage AI offers high-quality embedding models:
voyage-2 - Latest and most capable modelvoyage-large-2 - Larger model for maximum performancevoyage-code-2 - Optimized for code and technical contentvoyage-lite-02-instruct - Lightweight instruction-following modelCheck the Voyage AI documentation for the complete list of available models and their specifications.