OPENROUTER_API_KEY stored anywhere, and usage is billed to the API key the federation policy acts as, as if that key made the request.
Workload identity federation is available on OpenRouter’s Business and Enterprise plans, under
Settings, Workload identity.
Configure OpenRouter
An organization admin sets this up under Settings, Workload identity (set up trust):- Add an issuer. Set Issuer URL to the issuer URL copied from the dashboard and leave JWKS URL empty: OpenRouter reads the keys from the issuer’s discovery document.
- Add a policy for that issuer:
- Subject: the complete subject copied from the dashboard. It must match exactly.
- Audience: any value, for example
https://openrouter.ai. It’s required, and your task must request the same one. - Acts as API key: the workspace API key your tasks use today. A workspace key grants the
inferencescope.
Call OpenRouter in your task
/trigger/openrouter-chat.ts
400 with invalid_grant whichever claim failed, so compare the issuer, subject and audience with the policy when it does.
Remove the old credential
Once runs in every deployed environment authenticate this way, deleteOPENROUTER_API_KEY from those environments on the Environment Variables page. The key itself stays: the policy acts as it. To stop anyone using it directly, create a new workspace key for the policy and delete the old one in OpenRouter.
Local Development runs can’t mint OIDC tokens. Use your own OpenRouter API key there when ctx.environment.type === "DEVELOPMENT".
