troviale.
Guides

Migrating from OpenAI

Move existing OpenAI code to Troviale by changing two lines — the base URL and the API key. Then reach Claude, Gemini and more with the same client.

If you already use the OpenAI SDK, migrating to Troviale takes two changes: the base URL and the API key. Your request and response handling stays the same.

The two-line change

Before
from openai import OpenAI

client = OpenAI(api_key="sk-openai-...")
After
from openai import OpenAI

client = OpenAI(
    base_url="https://api.troviale.com/v1",
    api_key="YOUR_TROVIALE_KEY",
)

That is the entire migration. Existing chat.completions.create(...) calls work unchanged.

Now reach every provider

The payoff: the same client now routes to any supported model by ID. No new SDKs, no second billing account.

# These all use the one client and the one key
client.chat.completions.create(model="gpt-4o", messages=msgs)
client.chat.completions.create(model="claude-sonnet-4-6", messages=msgs)
client.chat.completions.create(model="claude-haiku-3.5", messages=msgs)

What carries over

  • Streaming — pass stream=True exactly as before.
  • Tool calling — the OpenAI tool-call schema is preserved.
  • Message formatsystem / user / assistant roles are unchanged.

What to check

  • Model IDs differ from a single provider's catalog — see the model catalog for exact IDs.
  • Provider-specific parameters that have no OpenAI equivalent may be ignored. Stick to the standard Chat Completions fields for portable code.

On this page