Tasks

Point an OpenAI SDK at the gateway

Adopt Routeplane with a base-URL change, your existing OpenAI SDK calls keep working unchanged.

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

  1. Set the SDK's base_url to https://<gateway-host>/v1.
  2. Set api_key to your Routeplane virtual key (rp_-prefixed).
  3. 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.