Keys / Portkey
PORTKEY_API_KEY
The Portkey API key your app calls models through the Portkey AI Gateway with. It goes in the x-portkey-api-key header.
- Expires
- optional; you choose, up to your organization's maximum if set
- API
- create, list, update, rotate and delete, with an admin or workspace API key
Get it
Create one on app.portkey.ai/api-keys. The steps aren't recorded yet.
Set it
PORTKEY_API_KEY=...
The Python and Node.js SDKs read it from this variable when you don't pass a key. Or keep it out of .env with keypin: keypin run -- npm run dev
Replace it
- Rotate the key with
POST /v2/api-keys/{id}/rotate. It keeps the key's ID, budgets and config, and the old secret works for the transition period you set, at least 30 minutes. - Deploy the new secret everywhere that reads
PORTKEY_API_KEYbefore the transition ends. The old secret then stops on its own; don't delete the key. - Or create a new key with the same type, workspace, scopes, limits, default config and Config Override setting. Deploy it, then delete the old key.
Set rotate_every on the key in keypin.toml and a rotated date on its vault item, and keypin status shows when it's due.