You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Model limits from models.dev are parsed for pricing only, so models missing from the capability catalog report no context window #52
/v1/models reports per-model context and output limits only for models described by OpenCode's capability catalog. For every other model the gateway returns no context_window, context_length, max_input or max_output, so discovery clients fall back to their own hardcoded defaults.
Setup for reproduction: opencode2api -> CLIProxyAPI -> Pi. Models served through this gateway show a uniform 128k context / 16k output in Pi, while models reached through CLIProxyAPI's own OpenAI/Google/Anthropic OAuth accounts report their correct per-model limits.
Expected behaviour
/v1/models should expose the real per-model context window and output limit for every routable model, so downstream proxies can forward accurate limits.
Actual behaviour
Models missing from https://models.opencode.ai/api.json expose no limit fields at all. In my catalog 77 of 79 exposed models already carried correct limits, and the remaining ones (jev-1.13, jev-1.13-free) carried none and were rendered with the client default.
The gateway already downloads https://models.dev/api.json every 24 hours, but only reads cost.input, cost.output and deprecated from it. The limit object published there is discarded:
The limits are already present in the data the gateway already fetches; only parsing was missing. Fixing this keeps the client's own defaults out of the picture and lets a model advertised by Zen or Go be advertised with its real size.
Suggested fix
Parse limit.context, limit.input and limit.output into the models.dev metadata cache and use them to fill only the fields the capability catalog omitted. The capability catalog should stay authoritative for both limits and capability flags, so no published value is ever overwritten.
A related detail: decodeModelsDev currently returns on the first provider that has any models, so a model described only by another OpenCode tier (opencode-go) loses its cost, its anonymous eligibility and its limits. Merging the OpenCode providers, with the primary provider winning on duplicate IDs, fixes that as a side effect.
Verification
With the patch in place, /v1/models fills the gaps and CLIProxyAPI forwards the values to Pi; the three configured models match the gateway response exactly. Existing caches written by earlier builds keep their data until the next refresh, so removing config.json.models.dev.json forces an immediate refetch.
Resolved in v1.3.6 through #53 and the release integration.
The metadata parser now merges OpenCode providers and retains limit.context/input/output. The capability catalog remains authoritative; missing limits are filled from metadata. Along with #44, the default metadata source is now https://models.opencode.ai/api.json. Existing .models.dev.json caches remain compatible and are refreshed on startup; failed refreshes preserve cached data.
Validated locally with provider-merging, limit-precedence, cache persistence/failure cases, and the release commit passed all five GitHub Checks jobs. The final source tree omits test files at the maintainer's request.
Activity
发布准备:合入 #36、#46、#48、#49、#50、#53;修复 #42、#44、#51、#52,并添加 GPL-3.0-or-later。
jasonxu114514 commentedon Oct 7, 2026
Resolved in v1.3.6 through #53 and the release integration.
The metadata parser now merges OpenCode providers and retains limit.context/input/output. The capability catalog remains authoritative; missing limits are filled from metadata. Along with #44, the default metadata source is now https://models.opencode.ai/api.json. Existing .models.dev.json caches remain compatible and are refreshed on startup; failed refreshes preserve cached data.
Validated locally with provider-merging, limit-precedence, cache persistence/failure cases, and the release commit passed all five GitHub Checks jobs. The final source tree omits test files at the maintainer's request.