API Key Rotation
Programmatic key lifecycle for secure operations
Treat API key rotation as a routine operation. TheRouter.ai supports create, deploy, verify, and revoke workflows.
Overview
This page mirrors the OpenRouter workflow and adapts it for TheRouter.ai. Use TheRouter.ai as your OpenAI-compatible endpoint and keep model IDs in `provider/model` format.
Installation
Install the required SDKs and keep your TheRouter.ai key in environment variables.
install.sh
curl -X POST https://api.therouter.ai/v1/keys -H "Authorization: Bearer $THEROUTER_MANAGEMENT_KEY" -H "Content-Type: application/json" -d '{"name":"prod-rotated-2026-02","limit":2500}'Configuration
Set TheRouter.ai base URL overrides and pass your API key. Add attribution headers when your app should appear in rankings.
TypeScript
const newKey = await fetch("https://api.therouter.ai/v1/keys", {
method: "POST",
headers: { Authorization: "Bearer <THEROUTER_MANAGEMENT_KEY>", "Content-Type": "application/json" },
body: JSON.stringify({ name: "prod-rotated-2026-02", limit: 2500 }),
});Caveats
Integration note
Never revoke the old key before confirming all workloads read the new secret from your secret manager.
For production rollouts, pin SDK versions and validate model compatibility in staging before broad rollout.