Use an OpenAI API key in your coding agents
To use an OpenAI API key in Codex, opencode, pi and eight more agents, run yoink add, pick the openai preset, paste the key and tick the agents. It is the only preset with an OpenAI Responses endpoint, so it is the only one Codex accepts. Claude Code and Claude Desktop are left out: they need Anthropic Messages.
On this page
At a glance
| Fact | Value |
|---|---|
| Preset id | openai |
openai-responses endpoint | https://api.openai.com/v1 |
openai-chat endpoint | https://api.openai.com/v1 |
| API keys page | https://platform.openai.com/api-keys |
| Harnesses it reaches | 11 of 13 |
| Add command | yoink add --external --name <name> --preset openai |
| Harness | With this preset |
|---|---|
| Claude Code | not offered: needs anthropic-messages |
| pi | uses openai-chat |
| omp | uses openai-chat |
| opencode | uses openai-chat |
| codex | uses openai-responses |
| Qwen Code | uses openai-chat |
| Kilo Code | uses openai-chat |
| Droid | uses openai-responses |
| Crush | uses openai-chat |
| Goose | uses openai-chat |
| Zed | uses openai-chat |
| Continue | uses openai-chat |
| Claude Desktop | not offered: needs anthropic-messages |
Generated from the yoink CLI source and docs/providers.md (presets.ts).
One base URL, two protocols
The openai preset saves two endpoints at the same address, https://api.openai.com/v1: OpenAI Responses first, then OpenAI Chat Completions. The other six presets offer Chat Completions with Anthropic Messages, or Chat Completions alone. Because Responses comes first, the interactive model picker is built from https://api.openai.com/v1/models through that endpoint.
Which protocol an agent receives depends on its own preference order, not on the preset. Two agents end up on Responses:
- codex speaks nothing else to custom providers.
- Droid prefers Anthropic Messages, which this preset lacks, so it takes Responses next and yoink writes its
customModelsentries withprovider: "openai".
pi, omp, opencode, Qwen Code, Kilo Code, Crush, Goose, Zed and Continue all put Chat Completions first and get that. The pi page explains why that shows up as openai-completions in models.json.
Add it, and name it something other than openai
Interactively, yoink add suggests the profile id openai, taken from the preset label. Change it before you connect Codex. Codex ships a built-in provider with the id openai, and when it merges [model_providers] from config.toml it keeps a built-in entry over a user entry with the same id (source). A table yoink writes as [model_providers.openai] would then be ignored, and Codex would fall back to its built-in OpenAI provider and its own credentials instead of your key. Any other id, such as openai-api, avoids the clash.
yoink add
echo "$OPENAI_API_KEY" | yoink add --external --name openai-api --preset openai \
--models gpt-5.2,gpt-5.2-codex --connect pi,codex --default gpt-5.2-codex --token-stdin
yoink connect openai-api --to opencode,crush,droidFor Codex, yoink writes one table and, with --default, the two root keys:
model = "gpt-5.2-codex"
model_provider = "openai-api"
[model_providers.openai-api]
name = "OpenAI"
base_url = "https://api.openai.com/v1"
wire_api = "responses"
experimental_bearer_token = "<your key>"Codex: ChatGPT login or API key
Setting model_provider makes Codex send its requests with the API key instead of your ChatGPT login. If ~/.codex/auth.json holds a ChatGPT login when you connect, yoink prints this notice under the result (path shortened):
Codex is set to model_provider = "openai-api" in ~/.codex/config.toml, which overrides the ChatGPT login.
Run `yoink disconnect openai-api --from codex` or remove model_provider from that file to use ChatGPT.Disconnecting removes the table and clears model and model_provider only when they point at this provider. Switching between several ChatGPT logins is a separate feature that rewrites auth.json; see Subscriptions.
Why Claude Code is not offered
Claude Code and Claude Desktop accept only Anthropic Messages. yoink connect openai-api --to claude-code stops with "openai-api" has no Anthropic-compatible endpoint, which Claude Code requires. and writes nothing. To run an OpenAI-hosted model in Claude Code you need a gateway that answers /v1/messages, added as a custom provider.
Rotate or narrow the key
yoink edit openai-api re-writes a new key into every connected agent, including the experimental_bearer_token line in config.toml. yoink models openai-api --set gpt-5.2 trims the model list and re-syncs the same set of agents.
echo "$NEW_OPENAI_API_KEY" | yoink edit openai-api --token-stdinFAQ
Can I keep my ChatGPT login and an OpenAI API key in Codex at the same time?
Both can be saved, but Codex uses one at a time. While model_provider points at the yoink provider, Codex uses the key. Run yoink disconnect openai-api --from codex to go back to the ChatGPT login.
Why does Droid get the Responses endpoint when pi gets Chat Completions?
Droid's order is Anthropic Messages, then Responses, then Chat Completions. This preset has no Anthropic endpoint, so Responses is the first match. pi lists Chat Completions first.
Related
- Use any provider in pi
Connect any OpenAI- or Anthropic-compatible provider to pi. yoink writes ~/.pi/agent/models.json with model limits from models.dev and sets the default.
- Subscriptions
Save and switch ChatGPT (Codex), Kimi Code, Gemini and GitHub Copilot logins with yoink, each inside its own tool, with the live login re-saved first.
- Harnesses
What yoink writes into pi, omp, opencode, codex, Claude Code, Qwen Code, Kilo, Droid, Crush, Continue, Goose, Zed and Claude Desktop: paths and keys.
- Use a Kimi Code API key in your coding agents
The kimi-code preset points Claude Code at api.kimi.com/coding and opencode, pi or Crush at api.kimi.com/coding/v1. Distinct from switching Kimi logins.
- Use the Moonshot AI API in your coding agents
Connect a Moonshot AI platform key to Claude Code via api.moonshot.ai/anthropic, and to opencode, pi, Qwen Code or Crush via api.moonshot.ai/v1.
- Use OpenRouter in your coding agents
Add your OpenRouter key once and yoink writes it into Claude Code, opencode, pi, Qwen Code, Crush and 7 more. Codex is not supported: no Responses endpoint.