Jina AI
支持的端点
- /embeddings
- /rerank
API Key
# env variable
os.environ['JINA_AI_API_KEY']
示例用法 - Embedding
- SDK
- 代理
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)
- 添加到 config.yaml
model_list:
- model_name: embedding-model
litellm_params:
model: jina_ai/jina-embeddings-v3
api_key: os.environ/JINA_AI_API_KEY
- 启动代理
litellm --config /path/to/config.yaml
# RUNNING on http://0.0.0.0:4000/
- 测试一下!
curl -L -X POST 'http://0.0.0.0:4000/embeddings' \
-H 'Authorization: Bearer sk-1234' \
-H 'Content-Type: application/json' \
-d '{"input": ["hello world"], "model": "embedding-model"}'
示例用法 - Rerank
- SDK
- 代理
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)
- 添加到 config.yaml
model_list:
- model_name: rerank-model
litellm_params:
model: jina_ai/jina-reranker-v2-base-multilingual
api_key: os.environ/JINA_AI_API_KEY
- 启动代理
litellm --config /path/to/config.yaml
- 测试一下!
curl -L -X POST 'http://0.0.0.0:4000/rerank' \
-H 'Authorization: Bearer sk-1234' \
-H 'Content-Type: application/json' \
-d '{
"model": "rerank-model",
"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."
],
"top_n": 3
}'
支持的模型
这里列出的所有模型 https://jina.ai/embeddings/ 都受支持
支持的可选 Rerank 参数
所有 cohere rerank 参数都受支持。
支持的可选 Embeddings 参数
dimensions
特定于提供商的参数
将任何 Jina AI 特定参数作为关键字参数传递给 embedding
或 rerank
函数,例如:
- SDK
- 代理
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
)
curl -L -X POST 'http://0.0.0.0:4000/embeddings' \
-H 'Authorization: Bearer sk-1234' \
-H 'Content-Type: application/json' \
-d '{"input": ["good morning from litellm"], "model": "jina_ai/jina-embeddings-v3", "dimensions": 1536, "my_custom_param": "my_custom_value"}'