Access any custom provider endpoint through Portkey API
This feature is available on all Portkey plans.
Portkey API has first-class support for monitoring and routing your requests to 10+ provider endpoints, like /chat/completions, /audio, /embeddings, etc. We also make these endpoints work across 250+ different LLMs.However, there are still many endpoints like Cohere’s /rerank or Deepgram’s /listen that are uncommon or have niche use cases.With the Gateway to Other APIs feature, you can route to any custom provider endpoint using Portkey (including the ones hosted on your private setups) and get complete logging & monitoring for all your requests.
Portkey Gateway base URL remains same: https://api.portkey.ai/v1
Append your custom endpoint at the end of the URL: https://api.portkey.ai/v1/{provider-endpoint}
curl --request POST \ --url https://api.portkey.ai/v1/rerank \ --header 'Content-Type: application/json' \ --header 'x-portkey-api-key: $PORTKEY_API_KEY' \ --header 'x-portkey-provider: @cohere-prod' \ --data '{ "model": "rerank-english-v2.0", "query": "What is machine learning?", "documents": [ "Machine learning is a branch of AI focused on building systems that learn from data.", "Data science involves analyzing and interpreting complex data sets." ] }'
The SDK fully supports all HTTP methods: POST, GET, PUT, and DELETE.
from portkey_ai import Portkeyportkey = Portkey( api_key="PORTKEY_API_KEY", provider="@PROVIDER")response = portkey.post( '/rerank', model="rerank-english-v2.0", query="What is machine learning?", documents=[ "Machine learning is a branch of AI focused on building systems that learn from data.", "Data science involves analyzing and interpreting complex data sets." ])
from portkey_ai import Portkeyportkey = Portkey( api_key="PORTKEY_API_KEY", provider="@PROVIDER")response = portkey.get('/collections')
from portkey_ai import Portkeyportkey = Portkey( api_key="PORTKEY_API_KEY", provider="@PROVIDER")response = portkey.delete('/collections/my-collection')
The SDK fully supports all HTTP methods: POST, GET, PUT, and DELETE.
import Portkey from 'portkey-ai';const portkey = new Portkey({ apiKey: "PORTKEY_API_KEY", provider: "@cohere-prod"});const response = await portkey.post('/rerank', { model: "rerank-english-v2.0", query: "What is machine learning?", documents: [ "Machine learning is a branch of AI focused on building systems that learn from data.", "Data science involves analyzing and interpreting complex data sets." ]});
import Portkey from 'portkey-ai';const portkey = new Portkey({ apiKey: "PORTKEY_API_KEY", provider: "@cohere-prod"});const response = await portkey.get('/collections');
A complete example showing document reranking with Cohere:
from portkey_ai import Portkeyportkey = Portkey( api_key="PORTKEY_API_KEY", provider="@COHERE_VIRTUAL_KEY")response = portkey.post( '/rerank', return_documents=False, max_chunks_per_doc=10, model="rerank-english-v2.0", query="What is the capital of the United States?", documents=[ "Carson City is the capital city of the American state of Nevada.", "Washington, D.C. is the capital of the United States.", "Capital punishment has existed in the United States since before its founding." ])
AWS Bedrock Rerank Integration
A complete example showing document reranking with Cohere models on AWS Bedrock:
For Bedrock providers, pass the complete ARN along with the model name in the model field to make a successful request.
curl --location 'https://api.portkey.ai/v1/rerank' \--header 'x-portkey-api-key: $PORTKEY_API_KEY' \--header 'x-portkey-provider: @BEDROCK_PROVIDER_SLUG' \--header 'Content-Type: application/json' \--data '{ "model": "arn:aws:bedrock:us-east-1::foundation-model/cohere.rerank-v3-5:0", "query": "What is the capital of the United States?", "top_n": 3, "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.", "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.", "Capital punishment has existed in the United States since before the United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states." ]}'
from portkey_ai import Portkeyportkey = Portkey( api_key="PORTKEY_API_KEY", provider="@BEDROCK_PROVIDER_SLUG")response = portkey.post( '/rerank', model="arn:aws:bedrock:us-east-1::foundation-model/cohere.rerank-v3-5:0", query="What is the capital of the United States?", top_n=3, 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.", "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.", "Capital punishment has existed in the United States since before the United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states." ])
import Portkey from 'portkey-ai';const portkey = new Portkey({ apiKey: "PORTKEY_API_KEY", provider: "@BEDROCK_PROVIDER_SLUG"});const response = await portkey.post('/rerank', { model: "arn:aws:bedrock:us-east-1::foundation-model/cohere.rerank-v3-5:0", query: "What is the capital of the United States?", top_n: 3, 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.", "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.", "Capital punishment has existed in the United States since before the United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states." ]});