Skip to main content


This notebook covers how to get started with open source embedding models hosted in the Together AI API.


# install package
%pip install --upgrade --quiet langchain-together

Environment Setupโ€‹

Make sure to set the following environment variables:



First, select a supported model from this list. In the following example, we will use togethercomputer/m2-bert-80M-8k-retrieval.

from langchain_together.embeddings import TogetherEmbeddings

embeddings = TogetherEmbeddings(model="togethercomputer/m2-bert-80M-8k-retrieval")
API Reference:TogetherEmbeddings
embeddings.embed_query("My query to look up")
["This is a content of the document", "This is another document"]
# async embed query
await embeddings.aembed_query("My query to look up")
# async embed documents
await embeddings.aembed_documents(
["This is a content of the document", "This is another document"]

Was this page helpful?

You can also leave detailed feedback on GitHub.