OpenAI
The OpenAI provider authenticates the Codex agent — and the opencode agent when it runs OpenAI models — with an OpenAI API key from your own OpenAI account. Usage is billed by OpenAI directly.
If you're new to configuring providers, start with the LLM Providers overview — it covers where the settings live, how keys are stored, and how rotation works for every provider.
Adding an OpenAI key
- Create a key at platform.openai.com/api-keys.
- In the dashboard, go to Organization Settings → Agents → LLM Providers.
- On the OpenAI Direct card, paste the key into the API key field. It starts with
sk-. - Click Save.
You'll get an "OpenAI Direct saved" confirmation, and the field collapses to a masked display.
Rotating
Click Replace next to the masked key, paste the new one, and save. The existing key stays active until the new one is saved — see Rotating a key. Remove deletes the credential entirely.
Troubleshooting
- "API key looks too short" — you probably copied a partial value. Re-copy the whole key from the OpenAI console.
- A Task fails with an authentication error — the saved key may have been revoked or may have hit a spend limit. Check the key's status in the OpenAI console, then rotate it using Replace.
- Runs fail after switching agents — the OpenAI key serves the Codex agent, and opencode on OpenAI models. If you've switched to the Claude Code agent or an Anthropic model, configure Anthropic as well; agents never fall back to another provider's key.