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 Training Setting Re-Enabled? Two Switches to CheckDevelopers report Codex model training turning itself back on. What OpenAI documents, the second "Include environments" switch most people miss, and a five-minute check.
- OpenAI Pando: The Git Backend Built for Codex-Scale PushesOpenAI built Pando, a Git-compatible backend, after Codex flooded its monorepo with pushes. What it changed, the trade-offs, and what it means for your agent fleet.
- GPT-6.1 Terra: $1/$5 Pricing, Benchmarks, and When to Pick ItGPT-6.1 Terra is OpenAI's new $1/$5 per million token model: 50.3% on Terminal-Bench 4.0 (vendor-reported), half Sol's price, and who should route to it.
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.