Skip to content

[Bug]: ocx opencode reads the management route GET /api/models with the data-plane admission key and exits 401 #4315

Description

@cortes-ventures

Client or integration

Other (the ocx opencode launcher for the OpenCode CLI)

Area

CLI

Summary

ocx opencode reads the model catalog from GET /api/models with the data-plane admission key. That route is part of the management API, which requireManagementAuth (src/server/management-auth.ts:539, gated at src/server/index.ts:1289) admits only with the admin credential. On a hardened install the proxy therefore answers 401 {"error":"opencodex admin token required"}, the launcher prints ❌ Could not fetch the model catalog from the proxy: … and returns 1, and OpenCode is never launched.

Verified against a live 2.51.0 proxy on 127.0.0.1:10100 with an admin-api-token present:

$ curl -s -o /dev/null -w '%{http_code}\n' -H 'X-OpenCodex-API-Key: <data-plane admission key>' http://127.0.0.1:10100/api/models
401
{"error":"opencodex admin token required"}

$ curl -s -o /dev/null -w '%{http_code}\n' -H 'X-OpenCodex-API-Key: <admin token from ~/.opencodex/admin-api-token>' http://127.0.0.1:10100/api/models
200

Every other headless management caller already sends the admin credential — runningProxyUpdateHeaders in src/oauth/login-cli.ts, src/cli/claude.ts, and the GUI. cmdOpencode is the outlier: it calls fetchOpencodeProxyModels(live, apiKey) where apiKey = opencodeApiKey(startupConfig) resolves the admission key that is handed to the child OpenCode process.

Expected: the launcher authenticates its one management read with the configured admin token, keeping the admission key for the child process (and as a fallback for a host that truly has no admin credential).

Reproduction

  1. Use a hardened install where ocx start has minted ~/.opencodex/admin-api-token.
  2. With the proxy running, execute ocx opencode.
  3. Observe ❌ Could not fetch the model catalog from the proxy: and exit code 1; OpenCode never starts.

Code path: src/cli/opencode.tsconst apiKey = opencodeApiKey(startupConfig); then fetchOpencodeProxyModels(live, apiKey).

The same request with the admin token returns 200 and the catalog, which is what the launcher needs.

Version

@bitkyc08/opencodex 2.51.0 installed; the call site is unchanged on dev at 7a0513c (2.52.0).

Operating system

macOS 26.6.2 arm64 (proxy on loopback, port 10100).

Provider and model

Not provider-specific. The failing request is the management catalog read performed by the ocx opencode launcher.

Logs or error output

$ ocx opencode
❌ Could not fetch the model catalog from the proxy: GET /api/models responded 401: {"error":"opencodex admin token required"}

Screenshots and supporting files

A fix with regression coverage is linked below as a pull request.

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, personal data, local paths, session IDs, and request IDs.

Activity

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

    account-poolOAuth, credentials, Codex pool, quota, failover, plansbugSomething isn't workingcatalogModel catalog, slugs, visibility, routed entriescliCLI, config inject, packaging flagsproxyHTTP proxy, routing, reverse-proxy / management auth

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions