from portkey_ai import Portkey# 1. Install: pip install portkey-ai# 2. Add @voyage provider in model catalog# 3. Use it:portkey = Portkey(api_key="PORTKEY_API_KEY")embedding = portkey.embeddings.create( model="@voyage/voyage-3", input="Name the tallest buildings in Hawaii")print(embedding.data[0].embedding)
import Portkey from 'portkey-ai'// 1. Install: npm install portkey-ai// 2. Add @voyage provider in model catalog// 3. Use it:const portkey = new Portkey({ apiKey: "PORTKEY_API_KEY"})const embedding = await portkey.embeddings.create({ model: "@voyage/voyage-3", input: "Name the tallest buildings in Hawaii"})console.log(embedding.data[0].embedding)
from openai import OpenAIfrom portkey_ai import PORTKEY_GATEWAY_URL# 1. Install: pip install openai portkey-ai# 2. Add @voyage provider in model catalog# 3. Use it:client = OpenAI( api_key="PORTKEY_API_KEY", # Portkey API key base_url=PORTKEY_GATEWAY_URL)embedding = client.embeddings.create( model="@voyage/voyage-3", input="Name the tallest buildings in Hawaii")print(embedding.data[0].embedding)
import OpenAI from "openai"import { PORTKEY_GATEWAY_URL } from "portkey-ai"// 1. Install: npm install openai portkey-ai// 2. Add @voyage provider in model catalog// 3. Use it:const client = new OpenAI({ apiKey: "PORTKEY_API_KEY", // Portkey API key baseURL: PORTKEY_GATEWAY_URL})const embedding = await client.embeddings.create({ model: "@voyage/voyage-3", input: "Name the tallest buildings in Hawaii"})console.log(embedding.data[0].embedding)
# 1. Add @voyage provider in model catalog# 2. Use it:curl https://api.portkey.ai/v1/embeddings \ -H "Content-Type: application/json" \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ -d '{ "model": "@voyage/voyage-3", "input": "Name the tallest buildings in Hawaii" }'
Tip: You can also set provider="@voyage" in Portkey() and use just model="voyage-3" in the request.
from portkey_ai import Portkeyportkey = Portkey(api_key="PORTKEY_API_KEY", provider="@voyage") response = portkey.post( "/rerank", model="rerank-2-lite", 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.", "Washington, D.C. is the capital of the United States.", "Capital punishment has existed in the United States since before it was a country." ] ) print(response)
import Portkey from 'portkey-ai';const portkey = new Portkey({ apiKey: 'PORTKEY_API_KEY', provider: '@voyage'});const response = await portkey.post( "/rerank", { model: "rerank-2-lite", 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.", "Washington, D.C. is the capital of the United States.", "Capital punishment has existed in the United States since before it was a country." ] });console.log(response);