Take an app that calls OpenAI directly and put Routeplane in front of it, gaining a fallback chain and a single audited entry point, without touching application logic. About five minutes. You'll need a running gateway (run the image locally) and a virtual key.
1. Point the SDK at Routeplane
Change only the base_url and the key. Your existing OpenAI calls keep working.
# Before: talking to OpenAI directly
# client = OpenAI(api_key="sk-...")
# After: same SDK, pointed at your gateway
from openai import OpenAI
client = OpenAI(
base_url="https://<gateway-host>/v1",
api_key="rp_...", # Routeplane virtual key
)
2. Add a fallback chain
Declare "OpenAI first, Anthropic if it fails" once, in default headers, no per-call changes.
client = OpenAI(
base_url="https://<gateway-host>/v1",
api_key="rp_...",
default_headers={"x-routeplane-provider": "openai,anthropic"},
)
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Summarise this ticket."}],
)
print(resp.choices[0].message.content)
3. Confirm what happened
Every response carries Routeplane headers telling you which provider served the call and whether a cache or fallback was hit, so you can verify the chain is live without changing your code.
Where to go next
From here, layer on governance the same way, one header, no rewrite:
- Enforce data residency for regulated traffic.
- Add a guardrail for PII or prompt-injection.
- Set a budget so spend can't run away.