
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
portkey-ai
Advanced tools
npm install portkey-ai
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.
| Unified API Signature If you've used OpenAI, you already know how to use Portkey with any other provider. | Interoperability Write once, run with any provider. Switch between any model from_any provider seamlessly. |
| Automated Fallbacks & Retries Ensure your application remains functional even if a primary service fails. | Load Balancing Efficiently distribute incoming requests among multiple models. |
| Semantic Caching Reduce costs and latency by intelligently caching results. | Virtual Keys Secure your LLM API keys by storing them in Portkey vault and using disposable virtual keys. |
| Request Timeouts Manage unpredictable LLM latencies effectively by setting custom request timeouts on requests. |
| Logging Keep track of all requests for monitoring and debugging. | Requests Tracing Understand the journey of each request for optimization. |
| Custom Metadata Segment and categorize requests for better insights. | Feedbacks Collect and analyse weighted feedback on requests from users. |
| Analytics Track your app & LLM's performance with 40+ production-critical metrics in a single place. |
# Installing the SDK
$ npm install portkey-ai
$ export PORTKEY_API_KEY="PORTKEY_API_KEY"
import OpenAI from 'openai' with import 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();
Get started by checking out Github issues. Email us at support@portkey.ai or just ping on Discord to chat.
FAQs
Node client library for the Portkey API
The npm package portkey-ai receives a total of 103,949 weekly downloads. As such, portkey-ai popularity was classified as popular.
We found that portkey-ai demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.