# API key

> A secret string that identifies your account to an AI provider's API, billed per token rather than by subscription.

_Updated November 23, 2026_

Agents read API keys from environment variables (`ANTHROPIC_API_KEY`, `CODEX_API_KEY`, `GEMINI_API_KEY` and others) or from their own login command. The variable name matters: Codex 0.157.1 ignores `OPENAI_API_KEY` and answers "Missing bearer or basic authentication in header".

Keep keys out of repositories and out of shared machines, and prefer a subscription login where the agent supports one. In an EnvHaven workspace, the Vars pane and the Launch menu's **Set key** store keys write-only and export them into every new shell, where the agents pick them up.

## Keep reading

- [Bring your own key (BYOK)](https://envhaven.com/glossary/byok)
- [Device code login](https://envhaven.com/glossary/device-code-login)
- [Rate limit](https://envhaven.com/glossary/rate-limit)

Source: https://envhaven.com/glossary/api-key
