How to switch OpenRouter API keys without breaking your app

Move the base URL and credential together, then verify that an old deployment can be retired safely.

Treat a gateway credential and its destination as a pair. Separate environment variables are convenient, but a partial rollout can send the wrong credential to the wrong destination. Store both values in the same versioned deployment configuration.

Rehearse the cutover

In staging, send a fictional request with a fresh, narrowly scoped credential. Verify the destination, model and billing project. Roll out to one worker, then increase traffic after checking error rates. Remove the retired credential after old workers finish and confirm the application no longer uses it.

Open the TrustedRouter migration guide · How to test streaming when switching from OpenRouter