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)
Tip: You can also set provider="@voyage" in Portkey() and use just model="voyage-3" in the request.
Portkey supports Voyage AI’s reranking models through a unified /v1/rerank endpoint.
curl https://api.portkey.ai/v1/rerank \ -H "Content-Type: application/json" \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ -d '{ "model": "@voyage-ai-prod/rerank-2", "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. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states." ], "top_n": 3 }'
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)