Skip to content

Migrating from OpenAI

If you're already using the OpenAI API, switching to TrustedRails takes two changes: the base URL and the API key.

from openai import OpenAI
client = OpenAI(
api_key="tr-prx-your-api-key", # ← your TrustedRails key
base_url="https://proxy.trustedrails.com/v1", # ← TrustedRails endpoint
)
# Everything else stays exactly the same
response = client.chat.completions.create(
model="Qwen/Qwen3-235B-A22B-Instruct-2507-FP8",
messages=[{"role": "user", "content": "Hello!"}],
)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "tr-prx-your-api-key", // ← your TrustedRails key
baseURL: "https://proxy.trustedrails.com/v1", // ← TrustedRails endpoint
});
// Everything else stays exactly the same
const response = await client.chat.completions.create({
model: "Qwen/Qwen3-235B-A22B-Instruct-2507-FP8",
messages: [{ role: "user", content: "Hello!" }],
});

Many projects read the API key and base URL from environment variables. A clean way to migrate:

.env
OPENAI_API_KEY=tr-prx-your-api-key
OPENAI_BASE_URL=https://proxy.trustedrails.com/v1

If your OpenAI client reads these variables automatically (the official Python and JS SDKs do), no code changes are needed at all.

Replace your OpenAI model name with a TrustedRails-supported model. See Supported Models for the full list.

Common mappings:

| Instead of | Try | |---|---| | gpt-4o | Qwen/Qwen3-235B-A22B-Instruct-2507-FP8 | | gpt-3.5-turbo | Check Supported Models for smaller models |

What about streaming, function calling, etc.?

Section titled “What about streaming, function calling, etc.?”

TrustedRails supports the same features as the OpenAI Chat Completions API, including streaming and tool calling. See API Compatibility for details on supported parameters.