Skip to main content
Portkey is the Control Panel for AI apps. With it’s popular AI Gateway and Observability Suite, hundreds of teams ship reliable, cost-efficient, and fast apps.

Quickstart

Since Portkey is fully compatible with the OpenAI signature, you can connect to the Portkey AI Gateway through OpenAI Client.
  • Set the base_url as PORTKEY_GATEWAY_URL
  • Add default_headers to consume the headers needed by Portkey using the createHeaders helper method.
Install the OpenAI and Portkey SDK
Create the client

Examples

OpenAI Chat Completion

Provider: openai Model being tested here: gpt-4o-mini

Anthropic

Provider: anthropic Model being tested here: claude-3-5-sonnet-20240620 PythonJS/TScURL

Mistral AI

Provider: mistral-ai Model being tested here: mistral-medium

Together AI

Provider: together-ai Model being tested here: togethercomputer/llama-2-70b-chat

Portkey Supports other Providers

Portkey supports 30+ providers and all the models within those providers. To use these different providers and models with OpenAI’s SDK, you just need to change the provider and model names in your code with their respective auth keys. It’s that easy! If you want to see all the providers Portkey works with, check out the list of providers.

OpenAI Embeddings

PythonNodeJS

OpenAI Function Calling

OpenAI NodeJSOpenAI PythonNodeJSPythonREST

OpenAI Chat-Vision

Images

OpenAI Audio

Here’s an example of Text-to-Speech

OpenAI Batch - Create Batch

Files - Upload File