docs/opencode.md
opencode.ai.GET https://opencode.ai/zen/go/v1/usage, authenticated by OPENCODE_API_KEY or
providers[].apiKey.~/.local/share/opencode/opencode.db on macOS and Linux.POST https://opencode.ai/_server with server function IDs:
workspaces (def39973159c7f0483d8793a822b8dbb10d067e12c65455fcb4608459ba0234f)subscription.get (7abeebee372f304e050aaaf92be863f4a86490e382f8c79db68fd94040d691b4)usage.rolling/weekly/monthly.percent in percentage units (0...100): 1 means 1%, and
0.5 means 0.5%. Generic dashboard JSON still accepts fractional usage values (0...1).rollingUsage.usagePercent, rollingUsage.resetInSec).weeklyUsage.usagePercent, weeklyUsage.resetInSec).now + resetInSec.Codex account quota and local token/cost history are separate data sources. The Codex provider reads session and weekly quota from the signed-in account's remote usage endpoint; those percentages do not come from local session logs.
If OpenCode holds your Codex OAuth session, the explicitly enabled External Codex OAuth sources setting can
reuse its openai OAuth entry for remote quota. Native Codex credentials take precedence, and an explicit
CODEX_HOME prevents external fallback. External credentials stay read-only; stale credentials fail closed, and
API-key entries are ignored. See Codex external OAuth sources.
This does not import OpenCode sessions into Codex token or spend totals. The base OpenCode provider tracks its web
dashboard, while the local SQLite reader described here selects only opencode-go assistant records for OpenCode Go.
Ordinary OpenCode sessions using OpenAI/Codex are not currently included in local cost history. OpenAI API-platform
usage is a separate OpenAI provider, not Codex subscription quota.
text/javascript with serialized objects; parse via regex.CODEXBAR_OPENCODE_WORKSPACE_ID to skip workspace lookup and force a specific workspace.wrk_… ID or a full https://opencode.ai/workspace/... URL.com.steipete.codexbar.cache (account cookie.opencode, source + timestamp). Browser
import only runs when the cached cookie fails.opencode-go assistant costs first,
overlays authoritative API windows when an API key is configured, then falls back through the API and legacy web
sources when local history is unavailable. Auto stays web-first when a token account, manual cookie, or workspace
override scopes the request, because local history is device-wide.dataConfidence: "estimated".
Estimated quota keeps its percentages and reset dates but does not show pace, reserve, or run-out advice in the
menu, menu-bar layouts, or CLI; device-local costs cannot establish account-wide consumption or the billing cycle.opencode.ai has no daily-granularity endpoint, so per-day cost/request buckets
come from local opencode-go assistant costs in opencode.db, keyed by device-local calendar day. Successful web
usage remains workspace-scoped and is never blended with device-wide local costs, so it does not show cost history.
Explicit Web mode never reads the local database either.modelID
(the real model behind the constant opencode-go Zen proxy providerID). This lets the shared Cost history
chart show a per-model breakdown for OpenCode Go the same way it already does for Claude (see the "Cost usage"
section in docs/claude.md). Rows with no modelID are grouped under an "unknown" bucket instead of
being dropped.