Prerequisites
Before you can configure the OpenAI SDK to use the Connect AI LLM Gateway, you must register a provider, create a routing rule, create a project, and issue a virtual key. See LLM Gateway for details.A Connect AI Personal Access Token (PAT) is not accepted by the LLM Gateway. Only a virtual key authenticates requests.
Install the SDK
- Python
- JavaScript
Send a Request
Setbase_url (Python) or baseURL (JavaScript) to the Connect AI LLM Gateway endpoint and pass your virtual key as api_key or apiKey. The gateway selects the provider and model based on your project’s routing rule.
- Python
- JavaScript
Configure with Environment Variables
As an alternative to passing connection details in code, you can set environment variables. The OpenAI SDK reads these automatically.- macOS / Linux
- Windows (PowerShell)
- Python
- JavaScript