portkey-ai
v1.5.3
Published
Node client library for the Portkey API
Downloads
120,672
Readme
Control Panel for AI Apps
npm install portkey-ai
Features
The Portkey SDK is built on top of the OpenAI SDK, allowing you to seamlessly integrate Portkey's advanced features while retaining full compatibility with OpenAI methods. With Portkey, you can enhance your interactions with OpenAI or any other OpenAI-like provider by leveraging robust monitoring, reliability, prompt management, and more features - without modifying much of your existing code.
AI Gateway
Observability
Usage
Prerequisites
- Sign up on Portkey and grab your Portkey API Key
- Add your OpenAI key to Portkey's Virtual Keys page and keep it handy
# Installing the SDK
$ npm install portkey-ai
$ export PORTKEY_API_KEY="PORTKEY_API_KEY"
Making a Request to OpenAI
- Portkey fully adheres to the OpenAI SDK signature. You can instantly switch to Portkey and start using our production features right out of the box.
- Just replace
import OpenAI from 'openai'
withimport Portkey from 'portkey-ai'
:
import Portkey from 'portkey-ai';
const portkey = new Portkey({
virtualKey: "VIRTUAL_KEY"
})
async function main() {
const chatCompletion = await portkey.chat.completions.create({
messages: [{ role: 'user', content: 'Say this is a test' }],
model: 'gpt-4',
});
console.log(chatCompletion.choices);
};
main();
Check out Portkey docs for the full list of supported providers
Contributing
Get started by checking out Github issues. Email us at [email protected] or just ping on Discord to chat.