Portkey provides a robust and secure gateway to facilitate the integration of various models into your applications, including Jina AI embedding & reranker models.
With Portkey, you can take advantage of features like fast AI gateway access, observability, and more, all while ensuring the secure management of your API keys through a virtual key system.
{% hint style="info" %}
Provider Slug**: jina
**
{% endhint %}
Portkey provides a consistent API to interact with models from various providers. To integrate Jina AI with Portkey:
Add the Portkey SDK to your application to interact with Jina AI's API through Portkey's gateway.
{% tabs %} {% tab title="NodeJS" %}
npm install --save portkey-ai
{% endtab %}
{% tab title="Python" %}
pip install portkey-ai
{% endtab %} {% endtabs %}
Set up Portkey with your virtual key as part of the initialization configuration. You can create a virtual key for Jina AI in the UI.
{% tabs %} {% tab title="NodeJS SDK" %}
import Portkey from 'portkey-ai'
const portkey = new Portkey({
apiKey: "PORTKEY_API_KEY", // defaults to process.env["PORTKEY_API_KEY"]
virtualKey: "JINA_AI_VIRTUAL_KEY" // Your Jina AI Virtual Key
})
{% endtab %}
{% tab title="Python SDK" %}
from portkey_ai import Portkey
portkey = Portkey(
api_key="PORTKEY_API_KEY", # Replace with your Portkey API key
virtual_key="JINA_AI_VIRTUAL_KEY" # Replace with your virtual key for Jina AI
)
{% endtab %} {% endtabs %}
Use the Portkey instance to send your embeddings requests to Jina AI. You can also override the virtual key directly in the API call if needed.
{% tabs %} {% tab title="NodeJS SDK" %}
const embeddings = await portkey.embeddings.create({
input: "embed this",
model: "jina-embeddings-v2-base-es",
});
{% endtab %}
{% tab title="Python SDK" %}
embeddings = portkey.embeddings.create(
input='embed this',
model='jina-embeddings-v2-base-de'
)
{% endtab %} {% endtabs %}
Portkey also supports the Reranker models by Jina AI through the REST API.
{% tabs %} {% tab title="REST API" %}
curl https://api.portkey.ai/v1/rerank \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $JINA_AI_API_KEY" \
-H "x-portkey-provider: jina" \
-d '{
"model": "jina-reranker-v1-base-en",
"query": "Organic skincare products for sensitive skin",
"documents": [
"Eco-friendly kitchenware for modern homes",
"Biodegradable cleaning supplies for eco-conscious consumers",
"Organic cotton baby clothes for sensitive skin"
],
"top_n": 2
}'
{% endtab %} {% endtabs %}
Portkey works with all the embedding & reranker models offered by Jina AI. You can browse the full list of Jina AI models here.
The complete list of features supported in the SDK are available on the link below.
{% content-ref url="../../api-reference/portkey-sdk-client.md" %} portkey-sdk-client.md {% endcontent-ref %}
You'll find more information in the relevant sections: