Skip to main content

Jina AI

https://jina.ai/embeddings/

Supported endpoints:

  • /embeddings
  • /rerank

API Keyโ€‹

# env variable
os.environ['JINA_AI_API_KEY']

Sample Usage - Embeddingโ€‹

from litellm import embedding
import os

os.environ['JINA_AI_API_KEY'] = ""
response = embedding(
model="jina_ai/jina-embeddings-v3",
input=["good morning from litellm"],
)
print(response)

Sample Usage - Rerankโ€‹

from litellm import rerank
import os

os.environ["JINA_AI_API_KEY"] = "sk-..."

query = "What is the capital of the United States?"
documents = [
"Carson City is the capital city of the American state of Nevada.",
"The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
"Washington, D.C. is the capital of the United States.",
"Capital punishment has existed in the United States since before it was a country.",
]

response = rerank(
model="jina_ai/jina-reranker-v2-base-multilingual",
query=query,
documents=documents,
top_n=3,
)
print(response)

Supported Modelsโ€‹

All models listed here https://jina.ai/embeddings/ are supported

Supported Optional Rerank Parametersโ€‹

All cohere rerank parameters are supported.

Supported Optional Embeddings Parametersโ€‹

dimensions

Provider-specific parametersโ€‹

Pass any jina ai specific parameters as a keyword argument to the embedding or rerank function, e.g.

response = embedding(
model="jina_ai/jina-embeddings-v3",
input=["good morning from litellm"],
dimensions=1536,
my_custom_param="my_custom_value", # any other jina ai specific parameters
)