For the complete documentation index, see llms.txt. This page is also available as Markdown.

OpenCode Integration with The Grid | Provider Setup

Connect OpenCode to The Grid with opencode auth /connect. Add your consumption key, choose model and small_model, and run the agent loop.

OpenCode ships with a /connect flow that adds The Grid as a provider in one step. No JSON to edit, no config scope to choose. Run opencode auth /connect, pick The Grid, paste your consumption key, and the agent loop runs on market-priced inference.

Prerequisites

  • OpenCode installed (opencode --version to check).

  • A Grid account at app.thegrid.ai.

  • Credits in your account. The Grid is prepaid; zero credits returns 402.

  • A Grid consumption API key from Settings → API Keys → Create Consumption Key.

Setup

1. Get your Grid consumption API key

Log into app.thegrid.ai. Go to Settings → API Keys → Create Consumption Key and copy it.

2. Run opencode auth /connect

opencode auth /connect

Select The Grid from the provider list. Paste your Grid consumption key when prompted. OpenCode persists the credential for you.

3. Pick your model and small_model

OpenCode separates a primary model from a cheaper small_model used for title generation, summaries, and utility calls. Map both to Grid instruments. A useful default for coding agents:

  • model: code-prime

  • small_model: code-standard

Set them in the TUI with /model thegrid/code-prime and the equivalent setting for small_model. Instrument tiers and use cases live in the current instruments list.

4. Set token limits to avoid context overflow

OpenCode decides how much of the conversation to send from each model's limit.context and limit.output. When limit.input is set, it uses that as the input budget; when it isn't, it derives the budget as context minus output. On long coding turns with large file context and tool results, a missing or wrong limit makes OpenCode pack a request that overruns the window and returns a 400.

If you connected through auth /connect and The Grid's models come from the shared registry, the limits travel with them. If you wired The Grid as a custom provider, set the limits yourself per instrument:

Keep output below context so input plus output fits in one request. Use 120,000 for input on Standard and Prime instruments and 922,000 on the Max instruments. For an instrument not shown here, get its context window from the current instruments list.

5. Launch OpenCode

The Grid's instruments appear in the /model picker.

Verification

Run a quick non-interactive check against both tiers:

If both return OK, the provider is wired up, the key is valid, and both tiers route correctly.

Troubleshooting

The Grid's instruments don't appear in /model. Restart OpenCode after auth /connect. If the providers list still excludes The Grid, run auth /connect again to re-register.

Token counts don't match the Grid dashboard. OpenCode's built-in counter is provider-agnostic and does not see Grid market pricing. Real spend is in the Grid dashboard.

Last updated

Was this helpful?