Skip to content

Use OpenCode with any model

OpenCode reads custom providers from a provider block in its opencode.json config file. Connect to Hopscotch to use any model in the catalog.

Set it up

  1. 01

    The configuration surface

    The file is opencode.json, either at your repository root or globally at ~/.config/opencode/opencode.json, and the two are merged. Add a provider:

    opencode.json
    {
      "provider": {
        "hopscotch": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "Hopscotch",
          "options": {
            "baseURL": "https://api.hopscotchlabs.ai/v1",
            "apiKey": "{env:HOPSCOTCH_API_KEY}"
          },
          "models": {
            "openai/gpt-4o-mini": {
              "name": "GPT-4o mini via Hopscotch"
            }
          }
        }
      }
    }

    OpenCode does not append /v1. Its documentation says the baseURL should end at the version prefix the provider uses, so include it.

  2. 02

    Pick the right package

    npm names the adapter, and the choice is not cosmetic. @ai-sdk/openai-compatible speaks chat completions, which is what this API serves.

  3. 03

    List the models yourself

    OpenCode does not ask a custom provider what it can serve. It has no discovery step for one, so the models it offers are the keys of your models object, and those keys are pinned ids. Adding a model means editing the file again.

    Each model may carry a limit object with context and output. Fill both in from GET /v1/models, which publishes the context window and the maximum output for every model.

  4. 04

    The key, and the file that gets committed

    OpenCode's own documentation says the project-level config is safe to check into version control, which it is right up until somebody writes a key into it. Use the interpolation instead: {env:VARIABLE_NAME} reads the value from your environment, as in the block above, and resolves to an empty string when the variable is unset.

    bash
    export HOPSCOTCH_API_KEY=ub_live_YOUR_KEY_HERE

Models that fit an agent

These models support tool calling and take at least 128K tokens of context. Prices are per million tokens.

ModelContextMax outputInput /1MOutput /1MCached input /1MProvidersReleased
Zhipu AIZ.ai: GLM 5.3 FlashZhipu AIrelace/glm-5.3-flash1M131K$0.005$0.20n/aRelace26 Aug 2026
Mistral AImistralai/mistral-nemoMistral AIeachlabs/mistral-nemo131K16K$0.03$0.03n/aEachLabs30 Jul 2024
Zhipu AIZ.ai: GLM 5.2Zhipu AIrelace/glm-5.21M131K$0.03$7.00n/aRelace13 Jun 2026
AlibabaQwen 3.8 27BAlibabadarkbloom/Qwen3.8-27B-4bit-mtp262K66K$0.04$1.50$0.02Darkbloomn/a
Googlegemma-4-26bGoogledarkbloom/gemma-4-26b131K33K$0.04$0.15$0.01Darkbloomn/a
OpenAIGPT OSS 20BOpenAIakash/gpt-oss-20b131K118K$0.04$0.15n/aAkashML, DeepInfra, CoreWeave / W&B Inference5 Aug 2025

What changes when OpenCode runs through Hopscotch

One key for every model
Switch models in OpenCode by changing the model name.
A budget for this tool
Give OpenCode its own key with a daily limit. A long session stops at the limit.
Every call in Activity
Each request OpenCode sends shows up with its model, provider, tokens and cost.
List price
You pay each provider's list price per token, with no markup.

OpenCode questions

Do I need an account with each provider?

No. One Hopscotch key covers every model in the catalog, and you buy credit once.

Which model name goes in OpenCode?

The ID from the models page, such as relace/glm-5.3-flash. The provider comes first, then the model.

Will OpenCode get a different model than the one I picked?

No. Hopscotch runs the model you name. To add a backup, set up a routing profile.

Can I use my own provider key with OpenCode?

Yes. Add the key in your dashboard. Requests to that provider run on it.

Run OpenCode on any model

Get a key and paste the config above.