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.

Provider Slug. jina

Portkey SDK Integration with Jina AI Models

Portkey provides a consistent API to interact with models from various providers. To integrate Jina AI with Portkey:

1. Install the Portkey SDK

Add the Portkey SDK to your application to interact with Jina AI’s API through Portkey’s gateway.

npm install --save portkey-ai

2. Initialize Portkey with the Virtual Key

To use JinaAI with Portkey, get your API key from here, then add it to Portkey to create the virtual key.

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
})

3. Invoke Embeddings with Jina AI

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.

const embeddings = await portkey.embeddings.create({
    input: "embed this",
    model: "jina-embeddings-v2-base-es",
});

Using Jina AI Reranker Models

Portkey also supports the Reranker models by Jina AI through the 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
}'

Supported Models

Portkey works with all the embedding & reranker models offered by Jina AI. You can browse the full list of Jina AI models here.

Next Steps

The complete list of features supported in the SDK are available on the link below.

SDK

You’ll find more information in the relevant sections:

  1. Add metadata to your requests
  2. Add gateway configs to your Jina AI requests
  3. Tracing Jina AI requests
  4. Setup a fallback from OpenAI Embeddings to Jina AI