opencode setup

How to add a custom provider in opencode

opencode reads providers from opencode.json. Add an entry that uses the OpenAI-compatible provider package with baseURL set to https://api.quickrouter.homes/v1, then list the models you want available. Nothing else in your configuration changes.

Last updated: October 2026

What you need before you start

opencode is configured through a JSON file, so the work happens in your editor rather than in a settings screen.

  • A QuickRouter account with an active plan and an API key from the console.
  • The base URL https://api.quickrouter.homes/v1 - opencode expects the OpenAI-style path.
  • opencode installed and run at least once, so it has created its config directory.
  • Write access to opencode.json in the project root or in the global config directory.

Register the provider

Add the provider under the provider key. The npm field tells opencode which SDK to load, and options carries the endpoint and credential.

  1. 01

    Open opencode.json

    Create the file in the project root if it does not exist, or edit the global config to make the provider available in every project.

    {
      "provider": {
        "quickrouter": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "QuickRouter",
          "options": {
            "baseURL": "https://api.quickrouter.homes/v1",
            "apiKey": "sk-qr-your-key"
          },
          "models": {
            "gpt-5": { "name": "GPT-5" },
            "claude-sonnet-4-5": { "name": "Claude Sonnet 4.5" },
            "deepseek-v3-2": { "name": "DeepSeek V3.2" }
          }
        }
      }
    }
  2. 02

    Reference the provider in an agent

    A model id is written as provider/model, so the gateway entry is selected explicitly rather than by guessing a default.

    {
      "agent": {
        "build": { "model": "quickrouter/gpt-5" }
      }
    }
  3. 03

    Confirm the route

    Start opencode and run a short prompt, then check the console usage view for the matching request.

Errors you are most likely to hit

Because opencode validates the config at load time, a mistake in the JSON shows up immediately rather than as a network error later.

SymptomCauseFix
Provider not foundThe agent references a provider key that is not declaredUse the same key in provider and in the agent model string
Config fails to parseTrailing comma or an unquoted model id in opencode.jsonValidate the file as JSON before restarting
404 from the endpointbaseURL points at the host rootSet baseURL to https://api.quickrouter.homes/v1
401 from the endpointThe apiKey value was edited by hand and lost charactersPaste the key again from the console
Model works in chat but not in an agentThe model is not listed under the provider modelsAdd the model id under models, then restart opencode

Which models should opencode use?

Split roles rather than picking one model for everything: a strong planner for the main agent and a cheaper model for search and summarisation steps.

Frequently asked questions

Which package does the provider need?+

The OpenAI-compatible SDK, referenced as @ai-sdk/openai-compatible. opencode installs it from the npm field in your provider entry.

Can I keep the key out of opencode.json?+

Yes. Read it from an environment variable in your shell and reference that variable from your own tooling, or keep the file out of version control so the literal never leaves your machine.

Should the base URL include /v1?+

Yes. opencode expects the OpenAI-style path: https://api.quickrouter.homes/v1.

Does opencode work with Claude models through the gateway?+

Yes. Model names are routed upstream by the gateway, so an Anthropic model id works through the same OpenAI-compatible provider entry.

One key covers every model in this guide

Create an account, pick a plan and copy an API key. Gateway plans start at $19 per month and model usage is billed at upstream list prices.

opencode custom provider: add QuickRouter to opencode.json