Setup guide - Documented by OpenCode
Use OpenAI in OpenCode
OpenCode includes OpenAI in its provider and model catalog (from models.dev). Run /connect, choose OpenAI and enter its credentials, then run /models to select a model. A ChatGPT Plus or Pro plan can be used instead of an OpenAI API key via Sign in with ChatGPT.
Last verified 4 steps2 official sources
Steps
- Step 1.
Run /connect, choose OpenAI, and enter its credentials. Then run /models to select one of its models.
Snippet/connect /models - Step 2.
To use a ChatGPT Plus or Pro plan instead of an OpenAI API key: connect OpenAI, then choose Sign in with ChatGPT or one of the legacy Codex sign-in methods. Usage counts against your plan, so these models show no cost.
- Step 3.
Optionally add or override OpenAI models in opencode.jsonc. The map key is the model ID used by OpenCode; modelID changes the ID sent to the provider (example verbatim from OpenCode's docs).
JSON{ "$schema": "https://opencode.ai/config.json", "model": "openai/coding", "providers": { "openai": { "models": { "coding": { "modelID": "gpt-6.1-sol", "name": "GPT-6.1 Sol Coding", }, }, }, }, } - Step 4.
To send a catalog provider through a proxy or compatible endpoint, override settings.baseURL for that provider in the providers section of the config; its existing package, models and connection still apply.
Caveats
- OpenCode's providers page uses gpt-6.1-sol in its OpenAI examples; the other ids shown are from OpenAI's model catalog (developers.openai.com/api/docs/models). Pick them from /models.
- With ChatGPT sign-in, OpenCode caps the context window by default to match Codex defaults: 500,000 input tokens for GPT-6.1 Sol and newer, 272,000 for older models. To opt out, disable the cap plugin with "plugins": ["-opencode.provider.openai-context-caps"].
- For an OpenAI-compatible API not in the catalog, OpenCode documents a custom provider using the @opencode/ai/providers/openai-compatible package.
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.
- Droid vs Codex (2026): Factory vs OpenAI for Terminal Coding AgentsFactory Droid vs OpenAI Codex compared on models, pricing, headless CI, multi-agent work, extensibility and openness, with a clear recommendation for each kind of developer.
- The One Number That Predicts What AI Can Do NextOpenAI's chief scientist Jakub Pachocki says perplexity, how well a model predicts the next token, tracks every big jump in AI, and wants every lab to publish it.
- Codex CLI 0.171: codex exec --remote, Workspace On by DefaultCodex CLI 0.171.0 adds codex exec --remote to run headless sessions on an existing app server, turns on the TUI workspace by default and picks GPT-6.2 Sol.
FAQ
How do I use OpenAI in OpenCode?
OpenCode includes OpenAI in its provider and model catalog (from models.dev). Run /connect, choose OpenAI and enter its credentials, then run /models to select a model. A ChatGPT Plus or Pro plan can be used instead of an OpenAI API key via Sign in with ChatGPT.
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 November 8, 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.