Skip to content

auth: opencode-go uses the Console credential instead of its own, causing spurious GoUsageLimitError #52374

Closed

Description

@julienamory-commits

Description

With both an opencode (Console) credential and an opencode-go credential stored, opencode-go requests authenticate with the Console key and carry x-opencode-org-id of the Console workspace — instead of using their own oc_sk_… key with no org header.

That Console workspace has its Go monthly quota at 100%, so every Go call fails with:

429 {"error":{"type":"GoUsageLimitError","message":"Go usage limit exceeded"},
     "metadata":{"limitName":"monthly"}}

while the same call made manually with the Go key succeeds (/zen/go/v1/usage → monthly 38%).

Capture of the real outgoing request (via a local server set as provider.opencode-go.options.baseURL), running opencode run --standalone --model opencode-go/deepseek-v4.1-flash:

Credentials in store Authorization sent by opencode-go x-opencode-org-id
opencode-go only Bearer oc_sk_… ✅ absent
opencode-go + opencode Bearer sk-… ❌ wrk_…

Presence of the Console credential alone triggers it.

Not affected by: provider.opencode-go.options.apiKey (global or project — ignored), OPENCODE_API_KEY env set to the Go key (ignored), credential.active = 0 on the Console credential, credential label ordering, or opencode auth switch opencode-go.

Happens consistently. Both integrations declare the same env: ["OPENCODE_API_KEY"] in the models.dev catalog, which may be why the resolution falls back to the Console credential.

Workaround: opencode auth logout opencode "API key" — after that, opencode run --model opencode-go/deepseek-v4.1-flash "OK" succeeds. Free Zen models keep working without the Console credential, but there's currently no way to keep the Console credential and use opencode-go.

Plugins

None

OpenCode version

v2.0.20 (channel: latest)

Steps to reproduce

  1. Store two credentials: opencode (Console, sk-…) and opencode-go (oc_sk_…).
  2. Verify the Go key has quota: curl -s https://opencode.ai/zen/go/v1/usage -H "Authorization: Bearer oc_sk_…" → 200, monthly ~38%.
  3. Verify the Console key's Go quota is exhausted: same request with sk-… → monthly {"status":"rate-limited","percent":100}.
  4. opencode run --standalone --model opencode-go/deepseek-v4.1-flash "OK" → Go usage limit exceeded.
  5. Optionally point provider.opencode-go.options.baseURL at a local capture server to see the wrong Authorization + x-opencode-org-id.

Screenshot and/or share link

Unavailable: no share link, this is a local capture of the outgoing request headers.

Operating System

Nobara 44 (Fedora-based), Linux 7.2.0-200.nobara.fc44.x86_64

Terminal

xterm-256color, COLORTERM=truecolor (via SSH/agent shell)

Activity

  1. github-actions commented on Sep 30, 2026

    @github-actions
    Contributor

    This issue might be related to an existing issue. Please check:

    • #50611: OpenCode Go requests use the Console credential instead of a Go credential; that report focuses on the Desktop connection flow, while this issue reproduces the credential selection problem in the CLI.
  2. vaprdev commented on Oct 1, 2026

    @vaprdev
    Contributor

    hey, we need to make the console/go authentication a bit clearer.

    but you can use /connect -> opencode console to authenticate any console workspace, and it will include your go subs in the authentication. then you can use /connect again to switch between the two workspaces and make calls (including go calls) from either.

    in v2 you don't need a go api key (the opencode go auth method is a bit redundant currently)

  3. djbclark commented on Oct 29, 2026

    @djbclark

    Still reproduces on opencode v2.2.1 (macOS), so this looks closed without a code change.

    With both an opencode (Console OAuth) credential and an opencode-go key credential stored, opencode-go/* requests always authenticate with the active Console credential. Making the opencode-go key active (opencode auth switch opencode-go <label>) and reloading the server (POST /api/location/reload) has no effect. We found this because a Console workspace hit its weekly GoUsageLimitError while the active Go key belonged to a different account with quota left. The only thing that moved traffic was switching the active Console credential.

    Understood that v2 intends Go to ride on the Console sign-in (#50267, and the /connect → opencode console advice above). If so, two things would help:

    1. Make that explicit: don't let opencode auth switch opencode-go (or the Go key flow) look like it selects a credential that's then ignored, or warn when it's shadowed by a Console login.
    2. Show which credential/workspace served a request (also Title: Improve diagnostics when stored credentials or background service environment override API keys #52891). The error gave no hint that a different account than the active Go key was being billed.

    #57155 looks like it may cover both. Happy to test it.

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

Metadata

Metadata

Assignees

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