Skip to main content


The CohereEmbeddings class uses the Cohere API to generate embeddings for a given text.


npm install cohere-ai @langchain/cohere
import { CohereEmbeddings } from "@langchain/cohere";

/* Embed queries */
const embeddings = new CohereEmbeddings({
apiKey: "YOUR-API-KEY", // In Node.js defaults to process.env.COHERE_API_KEY
batchSize: 48, // Default value if omitted is 48. Max value is 96
model: "embed-english-v3.0",
const res = await embeddings.embedQuery("Hello world");
/* Embed documents */
const documentRes = await embeddings.embedDocuments(["Hello world", "Bye bye"]);
console.log({ documentRes });

API Reference:

Was this page helpful?

You can also leave detailed feedback on GitHub.