This December, we’re pushing out some exciting new updates to Portkey’s SDKs, APIs, and Configs.
Portkey’s SDKs are upped to major version 1.0 bringing parity with the new OpenAI SDK structure and adding Portkey production features to it. We are also bringing native Langchain & Llamaindex integrations inside the SDK. This is a Breaking Change that Requires Migration.
Portkey’s APIsare upgraded with new endpoints, making it simpler to do /chat/completions and /completions calls and adding Portkey’s production functionalities to them.
This is a Breaking Change that Requires Migration.
Configs are upgraded to version2.0, bringing nested gateway strategies with granular handling. For Configs saved in the Portkey dashboard, this is NOT a Breaking Change and we will Auto Migrate your old Configs. For Configs directly defined at the time of making a call, through the old SDKs or old APIS, they will fail on the new APIs & SDKs and require migration.
API (Old) /v1/proxy /v1/complete /v1/chatComplete /v1/embed /v1/prompts/ID/generate
SDK (Old) SDK (New) Configs (Old) Configs (New)
Q2 ‘24
API (New) /v1 /v1/completions /v1/chat/completions /v1/embeddings /v1/prompts/ID/completions
SDK (Old) SDK (New) Configs (Old) Configs (New)
-
SDK Version < 1 (Old)
API (Old) API (New) Configs (Old) Configs (new)
Q2 ‘24
SDK Version = 1 (New)
API (Old) API (New) Configs (Old) Configs (new)
-
Configs 1.0 (Old)
API (Old) API (New) SDK (Old) SDK (new) === Configs saved through the Portkey UI will be auto migrated.
Q2 ‘24
Configs 2.0 (New)
API (Old) API (New) SDK (Old) SDK (new)
-
We recommend upgrading to these new versions promptly to take full advantage of their capabilities. While your existing code will continue to work until the deprecation date around Q2 ‘24, transitioning now ensures you stay ahead of the curve and avoid any future service interruptions. Follow along with this guide!
from portkey_ai import Portkeyportkey = Portkey( api_key="PORTKEY_API_KEY", Authorization="OPENAI_KEY")response = portkey.chat.completions.create( messages=[{'role': 'user', 'content': 'Say this is a test'}], model='gpt-3.5-turbo')print(response)
from portkey_ai import Portkeyportkey = Portkey( api_key="PORTKEY_API_KEY", Authorization="OPENAI_KEY")response = portkey.chat.completions.create( messages=[{'role': 'user', 'content': 'Say this is a test'}], model='gpt-3.5-turbo')print(response)
Installing the New SDK,
pip install -U portkey-ai
FROM
import { Portkey } from "portkey-ai";const portkey = new Portkey({ mode: "single", llms: [{ provider: "openai", virtual_key: "open-ai-xxx" }]});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();
TO
import Portkey from 'portkey-ai';// Initialize the Portkey clientconst portkey = new Portkey({ apiKey: "PORTKEY_API_KEY", // Replace with your Portkey API key Authorization: "OPENAI_KEY"});// Generate a chat completionasync function getChatCompletion() { const chatCompletion = await portkey.chat.completions.create({ messages: [{ role: 'user', content: 'Say this is a test' }], model: 'gpt-3.5-turbo', }); console.log(chatCompletion);}getChatCompletion();