Setup guide - Documented by OpenCode
Use OpenAI in OpenCode
OpenCode has a built-in OpenAI provider. Run /connect, choose OpenAI, then either sign in with ChatGPT Plus/Pro in the browser or paste an OpenAI API key; OpenAI models then appear under /models.
Last verified 4 steps2 official sources
Steps
- Step 1.
Run the /connect command and select OpenAI.
Snippet/connect - Step 2.
Select ChatGPT Plus/Pro to authenticate in the browser, or Manually enter API Key.
Snippet┌ Select auth method │ │ ChatGPT Plus/Pro │ Manually enter API Key └ - Step 3.
All OpenAI models should now be available from the /models command.
Snippet/models - Step 4.
Keys added with /connect are stored in ~/.local/share/opencode/auth.json. A base URL can be customised per provider with the baseURL option in the provider section of the OpenCode config (useful for proxies).
Caveats
- OpenCode's OpenAI section does not list model ids; the ids shown are from OpenAI's model catalog (developers.openai.com/api/docs/models). Pick them from /models.
- OpenCode's docs recommend a ChatGPT Plus or Pro subscription for this path; the API key path bills your OpenAI Platform account.
- For custom providers, OpenCode notes @ai-sdk/openai-compatible targets /v1/chat/completions and @ai-sdk/openai should be used for models that use /v1/responses.
More setup guides
Same tool, other providers
Related reading
- GPT-6 Astra Release Guide: Benchmarks, $10/$50 Pricing, and How to Run It in Codex and OpenCodeGPT-6 Astra release guide: OpenAI's max-capability model, its $10/$50 pricing and 1.05M context, what the benchmarks do and do not say, and commands to try it.
- Grok 4.6: xAI's Agent-Focused Update Matches GPT-5.6 Sol at the Same $2/$6 PriceGrok 4.6 release guide: xAI's agent-focused update matches GPT-5.6 Sol on the AA index at the same $2/$6 pricing, and runs in Cursor and OpenCode.
- GLM 5.2 in 9 Minutes: The Open-Weight Rival to GPT-5.5GLM 5.2 in 9 minutes: a companion guide to the video on the open-weight GPT-5.5 rival, covering benchmarks, pricing and a live OpenCode demo.
- Codex CLI 0.163: Instant Steering Is Now the DefaultCodex CLI 0.163.0 makes mid-response steering the default and adds searchable /config and a leader key. What changed and what to check before upgrading.
- Tool Calling Under the Hood: Claude Messages vs OpenAI ResponsesHow tool calling works on the wire: JSON schema tools, parallel calls, tool_choice, strict mode and streaming deltas in Claude Messages vs OpenAI Responses.
- Codex 'gpt-5.5 Model Is Not Supported' Error: The FixCodex says gpt-5.5 is not supported with a ChatGPT account because OpenAI retired it from ChatGPT sign-in on October 14. The fix and what still works.
FAQ
How do I use OpenAI in OpenCode?
OpenCode has a built-in OpenAI provider. Run /connect, choose OpenAI, then either sign in with ChatGPT Plus/Pro in the browser or paste an OpenAI API key; OpenAI models then appear under /models.
Which OpenAI model ids work in OpenCode?
The official docs read for this guide list gpt-6.1-sol, gpt-6-astra and gpt-6-luna.
Is this an official OpenAI and OpenCode setup?
OpenCode documents this setup in its own docs. It was last checked against 2 official pages on October 17, 2026.
Sources
Last verified against 2 official pages.
- opencode.aihttps://opencode.ai/docs/providers
- developers.openai.comhttps://developers.openai.com/api/docs/models
Newsletter
New models, set up the day they ship
One email per week. New model releases, the coding tools that support them and how to wire them up.