Because the inference surface is byte-compatible with OpenAI, adopting Routeplane is a base-URL change, not a rewrite. Point the SDK at your gateway, pass your virtual key, and your existing calls keep working.
Steps
- Set the SDK's
base_urltohttps://<gateway-host>/v1. - Set
api_keyto your Routeplane virtual key (rp_-prefixed). - Pass any
x-routeplane-*headers through the SDK's default-headers option.
pythonopenai SDK
from openai import OpenAI
client = OpenAI(
base_url="https://<gateway-host>/v1",
api_key="rp_...", # your Routeplane virtual key
default_headers={"x-routeplane-provider": "openai,anthropic"},
)
resp = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
How the key is read. The OpenAI SDK sends its key as a bearer token by default; Routeplane reads the virtual key from
x-routeplane-api-key. Most SDKs let you set that header via default_headers, or send the key in both places during migration. Full notes in OpenAI compatibility.
Next: make it resilient with a fallback chain.