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
asPORTKEY_GATEWAY_URL
- Add
default_headers
to consume the headers needed by Portkey using thecreateHeaders
helper method.
- Python
- JavaScript / TypeScript
- cURL
- Other SDKs
Install the OpenAI and Portkey SDKCreate the client
Examples
OpenAI Chat Completion
Provider:openai
Model being tested here: gpt-4o-mini
- Python
- JavaScript / TypeScript
- cURL
Anthropic
Provider:anthropic
Model being tested here: claude-3-5-sonnet-20240620
PythonJS/TScURL
- Python
- JavaScript / TypeScript
- cURL
Mistral AI
Provider:mistral-ai
Model being tested here: mistral-medium
- Python
- JavaScript / TypeScript
- curl
Together AI
Provider:together-ai
Model being tested here: togethercomputer/llama-2-70b-chat
- Python
- JavaScript / TypeScript
- curl
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 theprovider
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- Python
- NodeJS
OpenAI Function Calling
OpenAI NodeJSOpenAI PythonNodeJSPythonREST- OpenAI NodeJS
- OpenAI Python
- NodeJS
- Python
- cURL
OpenAI Chat-Vision
- OpenAI NodeJS
- OpenAI Python
- NodeJS
- Python
- cURL
Images
- OpenAI NodeJS
- OpenAI Python
- NodeJS
- Python
- cURL
OpenAI Audio
Here’s an example of Text-to-Speech- OpenAI NodeJS
- OpenAI Python
- cURL
OpenAI Batch - Create Batch
- OpenAI Node
- OpenAI Python
- Portkey Node
- Portkey Python
- cURL
Files - Upload File
- OpenAI Node
- OpenAI Python
- Portkey Node
- Portkey Python
- cURL