Skip to main content

Voyage AI

The VoyageEmbeddings class uses the Voyage AI REST API to generate embeddings for a given text.

The inputType parameter allows you to specify the type of input text for better embedding results. You can set it to query, document, or leave it undefined (which is equivalent to None).

  • query: Use this for search or retrieval queries. Voyage AI will prepend a prompt to optimize the embeddings for query use cases.
  • document: Use this for documents or content that you want to be retrievable. Voyage AI will prepend a prompt to optimize the embeddings for document use cases.
  • None (default): The input text will be directly encoded without any additional prompt.
import { VoyageEmbeddings } from "@langchain/community/embeddings/voyage";

const embeddings = new VoyageEmbeddings({
apiKey: "YOUR-API-KEY", // In Node.js defaults to process.env.VOYAGEAI_API_KEY
inputType: "document", // Optional: specify input type as 'query', 'document', or omit for None / Undefined / Null
});

Was this page helpful?


You can leave detailed feedback on GitHub.