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()
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: