Skip to content

1.18 CLI: fresh 'opencode run' fails 'Invalid credential'; 'auth login opencode' fails 'fetch() URL is invalid' #50593

Closed as not planned

Description

@Aymen104

Description

1.18-series CLI (choco-installed 1.18.31, verified also on a fresh 1.18.32 win-x64 binary) can no longer authenticate for fresh opencode run invocations. The gateway rejects with "Invalid credential", and opencode auth login opencode itself is broken with "Failed to load auth provider metadata from opencode: fetch() URL is invalid".

Desktop 2.0.11 works fine (device-flow OAuth), and the already-running 1.18 server/TUI still works (holds an in-memory session credential) — only a non-interactive fresh run spawns a new server that fails. This makes opencode run unusable from scripts/CI on 1.18.

Expected Behavior

opencode run --model opencode/big-pickle "..." with a valid stored opencode API key in auth.json should succeed, as it did before ~Sep 21 2026.

Actual Behavior

  1. opencode run --model opencode/big-pickle "Reply OK" →
    AI_APICallError: Upstream request failed: Invalid credential (exit 1)
  2. opencode auth login opencode →
    Error: Failed to load auth provider metadata from opencode: fetch() URL is invalid (exit 1)
    — same on 1.18.31 and freshly downloaded 1.18.32 (tested in isolation).

Diagnostics collected

  • Shared auth.json (C:\Users\pc.local\share\opencode\auth.json) contains a valid-looking legacy opencode API key (67-char sk-9h0V…).
  • Direct POST https://opencode.ai/zen/v1/chat/completions with that key → HTTP 400 {"error":{"type":"server_error","message":"Upstream request failed: Model is unavailable."}} — note this is not 401, so the key itself authenticates; the failure is upstream model routing on the zen route.
  • POST https://opencode.ai/zen/go/v1/chat/completions with same key → HTTP 400 MissingSessionID (documented go route behavior).
  • The 1.18 auth login opencode provider-metadata fetch URL is invalid — "fetch() URL is invalid" implies the 1.18 binary resolves an auth endpoint that no longer exists / was renamed server-side.
  • Root metrics on 1.18 CLI auth list: only opencode (api key) + deepseek; the desktop 2.0.11 stores its working credential as a device-flow OAuth token in opencode.db (credential table, label "Default") which 1.18 does not read.

Cause hypothesis: the "opencode" provider's auth metadata / zen model-routing endpoints changed around Sep 21 2026 (the same window as #50282 / #50084), breaking the 1.18 zen api-key path while the 2.0.11 console-OAuth path keeps working.

Environment

  • OpenCode version: 1.18.31 (choco) and 1.18.32 (downloaded release)
  • OS: Windows 10 x64
  • auth storage: C:\Users\pc.local\share\opencode\auth.json
  • Desktop 2.0.11 works; only 1.18 fresh runs fail

Activity

  1. github-actions commented on Sep 22, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. opencodejr commented on Oct 28, 2026

    @opencodejr

    Thanks for the detailed report and diagnostics!

    You're on OpenCode v1 (1.18.x). v1 only gets fixes for critical problems such as data loss, security issues or crashes with no workaround, so this is unlikely to be fixed there. Since Desktop 2.0.11 already works for you, the best path is to upgrade to v2. For scripts and CI, the v2 CLI is the npm package @opencode/cli, which installs the opencode command. You can sign in there with opencode auth login and then use opencode run.

    Some notes that may help:

    Related issues, ordered by likelihood:

    If you think this is critical, or you see the same failure on v2, please reply here with your v2 version and the exact command and error.

  3. opencodejr commented on Oct 29, 2026

    @opencodejr

    Closing this as not planned. It's about OpenCode v1 (1.18.x), which only gets critical fixes, and we haven't heard back that this also happens on v2. Desktop 2.0.11 already works for you, so the way forward for scripts and CI is the v2 CLI (@opencode/cli): sign in with opencode auth login, then use opencode run.

    If you see Invalid credential or the auth login failure on v2, please open a new issue with your v2 version, the exact command and the full error. #54833 and #59706 track the same Invalid credential error on v2 and may be useful to follow. Thanks again for the detailed diagnostics!

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions