Skip to main content
Watch: Anthropic Just Hit the Brakes on Its Next AI Model

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

  1. Step 1.

    Run /connect, choose OpenAI, and enter its credentials. Then run /models to select one of its models.

    Snippet
    /connect
    /models
  2. 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.

  3. 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",
            },
          },
        },
      },
    }
  4. 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.

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.

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.