AI21Embeddings#
- class langchain_ai21.embeddings.AI21Embeddings[source]#
 Bases:
Embeddings,AI21BaseAI21 embedding model.
To use, you should have the ‘AI21_API_KEY’ environment variable set or pass as a named parameter to the constructor.
Example
from langchain_ai21 import AI21Embeddings embeddings = AI21Embeddings() query_result = embeddings.embed_query("Hello embeddings world!")
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- param api_host: str | None = None#
 
- param api_key: SecretStr | None = None#
 - Constraints:
 type = string
writeOnly = True
format = password
- param batch_size: int = 128#
 Maximum number of texts to embed in each batch
- param num_retries: int | None = None#
 
- param timeout_sec: float | None = None#
 
- async aembed_documents(texts: List[str]) List[List[float]]#
 Asynchronous Embed search docs.
- Parameters:
 texts (List[str]) – List of text to embed.
- Returns:
 List of embeddings.
- Return type:
 List[List[float]]
- async aembed_query(text: str) List[float]#
 Asynchronous Embed query text.
- Parameters:
 text (str) – Text to embed.
- Returns:
 Embedding.
- Return type:
 List[float]