Skip to main content

Together AI

The TogetherAIEmbeddings class uses the Together AI API to generate embeddings for a given text.

Setup

In order to use the Together API you'll need an API key. You can sign up for a Together account and create an API key here.

You'll first need to install the @langchain/community package:

npm install @langchain/community

Usage

import { TogetherAIEmbeddings } from "@langchain/community/embeddings/togetherai";

const embeddings = new TogetherAIEmbeddings({
apiKey: process.env.TOGETHER_AI_API_KEY, // Default value
model: "togethercomputer/m2-bert-80M-8k-retrieval", // Default value
});

const res = await embeddings.embedQuery(
"What would be a good company name a company that makes colorful socks?"
);
console.log({ res });

API Reference:


Was this page helpful?


You can also leave detailed feedback on GitHub.