Skip to main content

AI21Embeddings

This notebook covers how to get started with AI21 embedding models.

Installationโ€‹

!pip install -qU langchain-ai21

Environment Setupโ€‹

Weโ€™ll need to get a AI21 API key and set the AI21_API_KEY environment variable:

import os
from getpass import getpass

os.environ["AI21_API_KEY"] = getpass()

Usageโ€‹

from langchain_ai21 import AI21Embeddings

embeddings = AI21Embeddings()

API Reference:

embeddings.embed_query("My query to look up")
embeddings.embed_documents(
["This is a content of the document", "This is another document"]
)

Help us out by providing feedback on this documentation page: