Skip to content

v2: OpenAI OAuth credential saved but provider never materializes (ProviderNotFoundError) #55516

Closed as duplicate

Description

@yturkkan

Summary

OpenAI OAuth login succeeds and the credential is saved + refreshed, but the openai provider never materializes: /api/provider/openai returns ProviderNotFoundError, opencode models lists zero openai/* models, and opencode run -m openai/<model> fails with Model unavailable.

Environment

  • opencode version: 2.0.29
  • OS: Darwin 27.0.0 (darwin arm64)
  • Terminal: TERM_PROGRAM=Apple_Terminal, TERM=xterm-256color, COLORTERM=truecolor
  • Shell: /bin/zsh
  • Install/channel: latest (release)
  • Active plugins: @hueyexe/opencode-ensemble@0.18.0, opencode-tps-meter@latest (a broken local plugins/model-panel was removed during diagnosis; opencode-codex@0.3.3 was tried and removed again because it fails to load on V2: PluginModule.LoadError: Plugin must export a default definition...)

Reproduction

  1. Remove all OpenAI credentials (opencode auth logout openai <id> for each, verified 0 remaining via /api/credential).
  2. In TUI run /connect → select OpenAI → choose Sign in with ChatGPT (chatgpt-token-sharing).
  3. opencode auth list shows OpenAI / OpenAI / stored; /api/credential shows the new credential active=true, method chatgpt-token-sharing, fresh 1h expiry, auto-refresh working (credential updated events in log, no token-exchange errors).
  4. opencode models | grep openai → empty (56 total models, all from opencode-go/opencode/console-nvidia).
  5. opencode api get /api/provider → only ['opencode-go', 'opencode', 'console-nvidia']; GET /api/provider/openai → {"_tag":"ProviderNotFoundError","providerID":"openai"}, HTTP 404.
  6. Repeat steps 1–2 with Codex browser (legacy) (chatgpt-browser) and Codex device code (legacy) (chatgpt-headless) methods: credential saves cleanly each time, provider still never appears.
  7. Same result with --standalone (private server), so it is not a shared-service issue.

Expected Behavior

After a successful OpenAI OAuth login, the openai provider should appear with its (Codex-eligible) models, and openai/<model> should be usable.

Actual Behavior

Credential persists and refreshes with no errors, but no openai provider or models ever appear. opencode run -m openai/gpt-5 ... → Error: Model unavailable: openai/gpt-5.

Additional Context

  • OPENCODE_DISABLE_DEFAULT_PLUGINS is not set; /api/integration lists all 3 OAuth methods for openai, so method registration itself works — provider activation does not.
  • Log shows hundreds of historical Failed to fetch models.dev (ENOTFOUND models.opencode.ai, timeouts, self signed certificate), but the endpoint currently returns HTTP 200 and the catalog contains openai, so this does not explain the persistent absence after restarts.
  • No OPENAI_API_KEY env var is set (intentional — ChatGPT subscription path is the goal, API key is not an option).
  • V2.0.20 changelog added ChatGPT token-sharing sign-in (feat(core): add separate ChatGPT token-sharing OAuth method #52147); on 2.0.29 (latest, opencode upgrade reports nothing newer) the saved token is never wired to a provider. Consistent reproduction, not intermittent.

Activity

  1. opencode-agent commented on Oct 14, 2026

    @opencode-agent
    Contributor

    Thanks for the very thorough report! I think this is a duplicate of #52363.

    Possible duplicates and related issues, ordered from most to least likely:

    If you want to confirm, you could disconnect OpenCode Zen/Go for a moment and check whether openai/* models show up. Please add any results to #52363.

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.

  2. yturkkan commented on Oct 14, 2026

    @yturkkan
    Author

    Follow-up with a version-regression datapoint — please keep this open, I don't think it's the same as #52363.

    • It worked until yesterday. Server logs show version=2.0.26 up to this morning; version=2.0.29 first appears today at 12:36 UTC, which is exactly when the openai provider disappeared. No config/plugin change on my side at that time (only change today was an automatic update to 2.0.29).
    • Against the coexistence theory: my console credentials (opencode-go API key, opencode Personal, console-nvidia) were created Sept 21–26 and unchanged since. OpenAI OAuth worked alongside them on ≤2.0.26 and broke on 2.0.29 with zero credential/config changes. So coexistence alone doesn't explain it — something in the 2.0.26→2.0.29 delta drops the openai provider record.
    • Also tried since: removed all plugins (plugin list → none), removed the broken local model-panel plugin + its agents/commands/cache, retried all 3 OAuth methods (chatgpt-token-sharing, chatgpt-browser, chatgpt-headless) — credential saves + refreshes cleanly every time, provider still 404. Same result with --standalone.
    • opencode upgrade reports 2.0.29 as latest, so no fix available yet.

    Happy to run OPENCODE_LOG_LEVEL=DEBUG traces or any one-repro probe on request.

  3. yturkkan commented on Oct 14, 2026

    @yturkkan
    Author

    Correction to my previous comment on the regression window:

    • Last known good: 2.0.23 (Oct 7 logs; user confirms OpenAI OAuth worked on .23).
    • Broken by: 2.0.26 at the latest (Oct 10 logs show 2.0.26; 2.0.24 seen Oct 6–7 and 2.0.27 on Oct 12 also ran on this machine, exact break day unknown).

    So the regression window is 2.0.23 → 2.0.26 (candidates: .24/.26/.27), not .26→.29 as I wrote before. Console providers (opencode-go, opencode, console-nvidia) were connected since Sept 21–26 throughout, so this is a version regression independent of provider coexistence.

  4. opencode-agent commented on Oct 14, 2026

    @opencode-agent
    Contributor

    Thanks for the version timing. It suggests this is not the same as #52363, so I've kept this open and looked at what changed between 2.0.26 and 2.0.29.

    I couldn't reproduce it here, because it needs a real ChatGPT sign-in and your OpenCode Console account. With plain API keys for OpenAI and OpenCode, 2.0.29 lists openai/* models next to opencode/opencode-go as expected.

    One change in 2.0.29 could explain it, though this is unconfirmed: OpenCode now applies organization policies sent by the connected OpenCode Console in a new place in the Console's response. Before 2.0.29 those were ignored. A policy that denies a provider removes it without any message, which would give exactly the ProviderNotFoundError / Model unavailable you see, starting right after the upgrade.

    If you'd like to help narrow it down:

    1. Temporarily disconnect the OpenCode Console (opencode / Personal) credential and restart the service (opencode service restart), then check opencode models | grep ^openai/. If OpenAI comes back, the Console connection is what removes it.
    2. Check whether your Console organization has any provider policies or allowed-provider settings.

    A maintainer with Console access will need to look at the rest.

  5. yturkkan commented on Oct 15, 2026

    @yturkkan
    Author

    Test result — theory confirmed.

    Steps taken (on 2.0.23, after removing all plugins and all OpenAI creds):

    1. /connect → OpenAI → Sign in with ChatGPT → credential saved, active=true, no errors — but openai still absent (ProviderNotFoundError, 0 models).
    2. opencode auth logout opencode <Personal-credential-id> (dropped the Console connection), then opencode service restart.
    3. Result: GET /api/provider now includes openai, opencode models | grep ^openai/ lists 16 models (gpt-5.6/6/6.1 sol/luna/terra/astra + fast variants).
    4. End-to-end check: opencode run -m openai/gpt-6.1-sol-fast "reply with the single word: ok" → ok. Works through the ChatGPT subscription token.

    So on this install the Console (opencode/Personal) connection is exactly what removes the openai provider — matches #52363. Note this reproduces with OAuth only (no API key involved, no OPENAI_API_KEY env set), and opencode-go + console-nvidia connections were left in place without blocking it.

  6. yturkkan commented on Oct 18, 2026

    @yturkkan
    Author

    Retest on v2.0.32 (macOS, latest channel, binary installed 2026-10-18) — still broken, same signature as the 2.0.23 repro.

    Steps:

    1. Baseline (no Console connection): OpenAI connected via ChatGPT-subscription OAuth. opencode models lists 16 openai/ models; opencode run -m openai/gpt-6.1-sol-fast "ok" → ok.
    2. Connected Console: opencode auth login opencode --method device (user code approved in browser). Log: "Connected to OpenCode Console".
    3. Result: openai/ drops 16 → 0 while the OpenAI credential stays in opencode auth list (OpenAI | OpenAI | stored). Model call: Error: Model unavailable: openai/gpt-6.1-sol-fast; server log: SessionRunnerModel.ModelUnavailableError at session start. Console side effects observed simultaneously: opencode/ free list grows 10 → 20 (managed config delivered) and the Console MCP server appears in session tools.
    4. Rollback: opencode auth logout opencode <label> + opencode service restart → openai/ back to 16/16, end-to-end call returns ok, Console MCP removed.

    Expected per docs: local providers should co-exist with a Console connection ("Managed providers only" is opt-in and off in my setup). The desired state — Console workspace connection while still using the local ChatGPT-subscription OpenAI provider — is currently impossible.

  7. neriousy commented on Oct 23, 2026

    @neriousy
    Member

    Closing as a duplicate of #52363. The deterministic v2.0.32 reproduction showing OpenAI models dropping from 16 to 0 when OpenCode Console is connected has been transferred to that canonical issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions