Skip to main content
Use RunInfra models in OpenCode through the OpenAI-compatible Chat Completions API.

Connect OpenCode

Use Node 20 or newer, an installed OpenCode with first-time setup complete, a workspace API key, and available RunInfra credits.
In an interactive terminal, Connect starts login if needed. Review and approve the proposed changes. Connect saves a snapshot, writes the provider settings and model selection, and makes a real Chat Completions request that uses credits. Follow the printed restart hint before using OpenCode. To choose a model during setup:
See Connect for key placement, status, diagnostics, and restore behavior. Run on again to refresh the saved model list.

Configure manually

Use the built-in listing

RunInfra is listed on models.dev, which supplies OpenCode’s provider and model catalog. You do not need a provider block to use that listing. Load your workspace key into RUNINFRA_GATEWAY_KEY through your secret-management workflow, then launch OpenCode from that environment:
Alternatively, start OpenCode, run /connect, select RunInfra, and enter your workspace key. Use /models to choose a RunInfra model. OpenCode saves that credential in ~/.local/share/opencode/auth.json.
The built-in listing reads RUNINFRA_GATEWAY_KEY. Connect’s login and helper mode use RUNINFRA_API_KEY. These names are not interchangeable unless you set both to the same workspace key.

Define an explicit provider

Use this form when you need to override the listing or declare a model yourself. Back up your configuration, then merge the block into ~/.config/opencode/opencode.json. OpenCode also accepts opencode.jsonc. A project-level opencode.json can override global values.
@ai-sdk/openai-compatible sends Chat Completions requests. The provider id is runinfra; model selections use runinfra/<slug>, such as runinfra/deepseek-v4-flash. The key under models is the bare model id sent to the API. Keep limit.context and limit.output explicit when declaring models. They let OpenCode track the available context and output budget. Standard listing entries already supply these values. An explicit provider block can shadow listing values, so update it when you change models. The {env:RUNINFRA_GATEWAY_KEY} reference resolves to an empty string if the variable is missing. Load the key before you restart OpenCode. Keep literal keys out of shared project configuration.

Verify

Load the same workspace key into RUNINFRA_GATEWAY_KEY in your terminal, including when you used /connect to save it in OpenCode. This request uses credits and reads usage.prompt_tokens_details.cached_tokens. The macOS and Linux example uses jq.
A count of 0 is valid; a successful request does not guarantee a cache hit. This tests the API, not whether OpenCode has reloaded its configuration. Restart OpenCode and select the model with /models.

Revert

If you used Connect:
This restores the snapshot from immediately before the most recent on, which may already contain RunInfra settings. If a managed file changed afterward, Connect refuses to overwrite it. Back up and review those edits before proceeding. For manual setup, restore the previous provider.runinfra block and any model or small_model selection you changed. Remove them only if you added them for this setup. Check global and project configuration, plus any OPENCODE_CONFIG or OPENCODE_CONFIG_CONTENT override. If you saved a credential with /connect, run opencode auth logout and select RunInfra. Remove RUNINFRA_GATEWAY_KEY from the launch environment and any project .env where you set it. Restart OpenCode and use /models to select another model, since OpenCode can remember the last selection. Connect’s logout removes only its saved credentials. It does not restore agent settings or revoke the workspace key. Revoke an unwanted key in the dashboard.

Connect

Set up, inspect, and restore your coding agent.

Chat completions

Read the request contract and cache usage fields.

Models

Find model ids and context windows.