Skip to main content
This file contains the JinaEncoder class which is used to encode text using Jina

jina_to_list

Convert a Jina embedding response to a list of embeddings. Arguments:
  • embeds (CreateEmbeddingResponse): The embedding response returned by the Jina API.
Returns: list[list[float]]: One embedding per input document.

JinaEncoder Objects

Class to encode text using Jina. Requires a Jina API key from https://jina.ai/api-keys/ Jina exposes an OpenAI-compatible embeddings endpoint, so this encoder drives it with the OpenAI SDK pointed at https://api.jina.ai/v1 rather than depending on LiteLLM.

__init__

Initialize the JinaEncoder. Arguments:
  • name (str): The name of the embedding model to use such as “jina-embeddings-v3”.
  • api_key (str): The Jina API key, can also be set via the JINA_API_KEY or JINA_AI_API_KEY environment variable.
  • score_threshold (float): The score threshold for the embeddings.
  • base_url (str): Override the Jina API base URL, can also be set via the JINA_BASE_URL or JINA_AI_API_BASE environment variable.
Raises:
  • ValueError: If no API key is provided or found in the environment.

__call__

Encode a list of text documents into embeddings using Jina. Arguments:
  • docs (list[Any]): List of text documents to encode.
Returns: list[list[float]]: List of embeddings for each document.

acall

Encode a list of text documents into embeddings using Jina asynchronously. Arguments:
  • docs (list[Any]): List of text documents to encode.
Returns: list[list[float]]: List of embeddings for each document.