New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

portkey-ai

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

portkey-ai

Node client library for the Portkey API

  • 1.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
36K
decreased by-3.25%
Maintainers
1
Weekly downloads
 
Created
Source

Ship Ambitious Gen AI Apps with Portkey's full-stack LLMOps Platform

npm install portkey-ai

💡 Features

🚪 AI Gateway:

  • 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 & A/B Testing: Efficiently distribute incoming requests among multiple models and run A/B tests at scale.
  • Semantic Caching: Reduce costs and latency by intelligently caching results.

🔬 Observability:

  • Logging: Keep track of all requests for monitoring and debugging.
  • Requests Tracing: Understand the journey of each request for optimization.
  • Custom Tags: Segment and categorize requests for better insights.

🚀 Quick Start

First, install the SDK & export Portkey API Key

Get Portkey API key here.

$ npm install portkey-ai
$ export PORTKEY_API_KEY="PORTKEY_API_KEY"
Now, let's make a request with GPT-4
import Portkey from 'portkey-ai';

// Construct a client with a virtual key
const portkey = new Portkey({
    apiKey: "PORTKEY_API_KEY",
    virtualKey: "VIRTUAL_KEY"
})

async function main() {
    const chatCompletion = await portkey.chat.completions.create({
        messages: [{ role: 'user', content: 'Say this is a test' }],
        model: 'gpt-3.5-turbo',
    });

    console.log(chatCompletion.choices);
};

main();

Portkey fully adheres to the OpenAI SDK signature. This means that you can instantly switch to Portkey and start using Portkey's advanced production features right out of the box.

📔 List of Portkey Features

You can set all of these features while constructing your LLMOptions object.

FeatureConfig KeyValue(Type)Required
API Key OR Virtual Keyapi_key OR virtual_keystring✅ Required
Provider Nameprovideropenai, cohere, anthropic, azure-openai✅ Required
Model NamemodelThe relevant model name from the provider. For example, gpt-3.5-turbo OR claude-2❔ Optional
Weight (For Loadbalance)weightinteger❔ Optional
Cache Typecache_statussimple, semantic❔ Optional
Force Cache Refreshcache_force_refreshTrue, False (Boolean)❔ Optional
Cache Agecache_ageinteger (in seconds)❔ Optional
Trace IDtrace_idstring❔ Optional
Retriesretryinteger [0,5]❔ Optional
Metadatametadatajson object More info❔ Optional
All Model ParamsAs per the model/providerThis is params like top_p, temperature, etc❔ Optional

🤝 Supported Providers

ProviderSupport StatusSupported Endpoints
OpenAI✅ Supported/completion, /chatcompletion
Azure OpenAI✅ Supported/completion, /chatcompletion
Anthropic✅ Supported/complete
Cohere✅ Supportedgenerate

📝 Full Documentation | 🛠️ Integration Requests |

follow on Twitter Discord

🛠️ Contributing

Get started by checking out Github issues. Feel free to open an issue, or reach out if you would like to add to the project!

FAQs

Package last updated on 24 Jan 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc