OpenAI SDK
The OpenAI Node.js SDK is the official SDK for working with LLMs provided by OpenAI as well as other OpenAI compatible models from other provider in Node.js.
Prerequisites
In order to use the AI Gateway with any OpenAI SDK powered application you will need to complete these steps first:
-
Create a new provider in the AI Gateway for OpenAI
-
Create a new app to use specifically with the OpenAI SDK and assign it to the team you created
-
Copy the API Key for the app you created, as well as the Gateway URL
Configure the OpenAI SDK
To route all OpenAI SDK requests through Zuplo instead of directly to the OpenAI
API, you must set the API baseUrl
in the SDK configuration.
For example, if your Zuplo application is hosted at https://my-ai-gateway.zuplo.app, you can change the base URL in your API client to https://my-ai-gateway.zuplo.app/v1.
Additionally, change the value of apiKey
to the API key of the app you have
configured in Zuplo
Code
When configured in this way, the SDK will switch from using the default OpenAI APIs to using Zuplo's AI Gateway for all requests.