Skip to main content
Because Portrix implements the full OpenAI API specification, the official OpenAI SDKs work with Portrix out of the box — no monkey-patching, no custom wrappers. Point the client at Portrix’s base URL, swap in your Portrix API key, and every model on the platform becomes available through the same interface you already know.

Python

Install the openai package if you haven’t already:
Change the two highlighted lines to redirect all SDK calls through Portrix:

JavaScript / TypeScript

Install the openai npm package if you haven’t already:
Apply the same two-line change in your TypeScript or JavaScript project:

What changes and what doesn’t

Model names use the provider/model format in Portrix — for example, openai/gpt-4o, anthropic/claude-3-5-sonnet, or google/gemini-2.0-flash. Pass these directly as the model field in your request.

Migrating existing code

1

Install or update the OpenAI SDK

Make sure you are on a recent version of the SDK. Portrix is compatible with openai >= 1.0.0 for Python and openai >= 4.0.0 for Node.js.
2

Set your Portrix API key

Store your key in an environment variable so it never appears in source code:
Add this to your .env file for local development and configure it as a secret in your deployment environment.
3

Update the client initialization

Replace your existing client constructor with the Portrix-configured version:
Everything else in your codebase — method calls, parameters, response parsing — stays exactly the same.
Use an environment variable for the base URL as well as the API key. Set OPENAI_BASE_URL=https://api.portrix.ai/v1 and OPENAI_API_KEY=$PORTRIX_API_KEY locally, and the OpenAI SDK will pick them up automatically — letting you switch between OpenAI and Portrix without touching a single line of application code.