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:AI21Embeddings
embeddings.embed_query("My query to look up")
embeddings.embed_documents(
["This is a content of the document", "This is another document"]
)

Was this page helpful?


You can leave detailed feedback on GitHub.