/models.
Verified with OpenCode 1.19.0, October 2026.
Prerequisites
- A Token Factory API key. See Authentication.
- OpenCode 1.19.0 or later.
- A model from the Token Factory catalog.
Context window and compaction
OpenCode does not read limits from the endpoint, so each model declares them underlimit:
limit.contextis the model’scontext_window.limit.outputis the model’smax_output_tokens. OpenCode sendsmax_tokens= the smaller of this and its built-in 32,000-token cap.limit.inputsets where OpenCode compacts: it summarizes the conversation once a request reacheslimit.inputminus 20,000 tokens (its defaultcompaction.reservedwhile the output cap is at least 20,000). Withoutlimit.input, OpenCode compacts only atlimit.context − max_tokens, with no headroom.
(context_window − max_tokens) / 1.15, rounded down, and limit.input is
that value plus 20,000:
GET /v1/models reports each model’s current context_window and
max_output_tokens.
1
Store the API key
Export the key in your shell profile. The configuration below reads it with
You can instead run
{env:CORVEX_API_KEY}./connect in OpenCode, select Other, enter corvex
as the provider ID, and paste the key; then omit apiKey below.2
Add the provider configuration
Add the provider to
~/.config/opencode/opencode.json for global use, or to
opencode.json in the project root:opencode.json
cost is in US dollars per million tokens and only affects OpenCode’s cost
display; see Pricing for current rates.3
Select and test a model
Start OpenCode in your repository and run
/models. Select a model under
Corvex Token Factory, then run a short task that exercises a tool call.
To run one prompt non-interactively:opencode models corvex --verbose prints the limits OpenCode loaded for
each model.Compatibility notes
- Output budget. Reasoning tokens count toward the 32,000-token step
budget. If a response or tool call is truncated, retry with a shorter prompt
or split the task. The
OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAXenvironment variable changes the cap; recompute the compaction window if you change it. - Context length. If a session still exceeds the model’s window, the gateway
returns
context_length_exceeded. Run/compactor start a new session. See Errors. - Model IDs. Use the exact
idfromGET /v1/models, prefixed with the provider ID (corvex/) when you select it on the command line.
Related documentation
- Connect Kilo Code — the same configuration format in Kilo Code.
- Connect pi and Connect Codex — other terminal coding agents.
- Errors — authentication, rate-limit, and validation responses.