Skip to main content
Corvex Token Factory connects to OpenCode through a custom OpenAI-compatible provider. Add the provider and its models to your OpenCode configuration, then select a Token Factory model from /models. Verified with OpenCode 1.19.0, October 2026.

Prerequisites

Context window and compaction

OpenCode does not read limits from the endpoint, so each model declares them under limit:
  • limit.context is the model’s context_window.
  • limit.output is the model’s max_output_tokens. OpenCode sends max_tokens = the smaller of this and its built-in 32,000-token cap.
  • limit.input sets where OpenCode compacts: it summarizes the conversation once a request reaches limit.input minus 20,000 tokens (its default compaction.reserved while the output cap is at least 20,000). Without limit.input, OpenCode compacts only at limit.context − max_tokens, with no headroom.
A single turn with large tool results can push the context past the compaction point before compaction runs, so leave about 15% headroom: the compaction window is (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 {env:CORVEX_API_KEY}.
You can instead run /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_MAX environment 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 /compact or start a new session. See Errors.
  • Model IDs. Use the exact id from GET /v1/models, prefixed with the provider ID (corvex/) when you select it on the command line.
Last modified on October 23, 2026