Use OpenCode with a private, uncensored API

Connect OpenCode to the private Morse API, uncensored models included: set it up, pick a model, and check it works.

Give OpenCode the base URL https://inference.trymorse.ai/v1 and a Morse API key. It calls the OpenAI API.

The same key also calls 14 uncensored models. See them.

Before you start

Make a key for OpenCode alone, with a spend limit, under API keys in the console. Then one tool can't spend all your credits. See Limit a key. Keep the key in your environment, where OpenCode reads it.

Terminal
export MORSE_API_KEY="sk_morse_..."

Set it up with a prompt

Paste this into a coding agent, such as Claude Code or Codex, and it sets up OpenCode for you. Or set it up by hand, below.

Setup prompt
Set up OpenCode to use Morse.

1. Use the OpenAI-compatible endpoint https://inference.trymorse.ai/v1
2. Read the key from the MORSE_API_KEY environment variable.
3. Default to the model qwen/qwen3-coder.
4. Follow https://trymorse.ai/inference/docs/tools/opencode, then run its check.

Change only OpenCode's settings. Leave everything else as it is.

Set up OpenCode

  1. Add Morse as a provider

    Save this as opencode.json in your project, or in ~/.config/opencode for every project. It names Morse's base URL, the variable your key is in, and the model's limits and prices, so OpenCode shows what a session costs.

    opencode.json
    {
      "$schema": "https://opencode.ai/config.json",
      "model": "morse/qwen/qwen3-coder",
      "provider": {
        "morse": {
          "name": "Morse",
          "env": ["MORSE_API_KEY"],
          "npm": "@ai-sdk/openai-compatible",
          "options": { "baseURL": "https://inference.trymorse.ai/v1" },
          "models": {
            "qwen/qwen3-coder": {
              "name": "Qwen3 Coder 480B A35B",
              "tool_call": true,
              "reasoning": false,
              "attachment": false,
              "modalities": {
                "input": ["text"],
                "output": ["text"]
              },
              "limit": { "context": 262144, "output": 32768 },
              "cost": { "input": 0.375, "output": 1.25, "cache_read": 0.125 }
            }
          }
        }
      }
    }

    A model's reference is the provider, a slash, and Morse's id, so the id keeps its own slash: morse/qwen/qwen3-coder. To add another model from the table below, add it under models the same way.

    Set each model's limit.context to its context window, and limit.output to a quarter of that or less. OpenCode keeps the output limit free in the window, so an output limit near the window makes it compact on every turn.

    OpenCode 1 and OpenCode 2 both read this file. OpenCode 2's own docs name these parts providers, package, and settings. OpenCode 1 skips that format and says Provider not found: morse, so this format is the safe choice. Run opencode --version to see which you have.

  2. On OpenCode 2, give its service the key

    OpenCode 1 reads MORSE_API_KEY from the shell you start it in, so it needs nothing more. OpenCode 2 runs its sessions in a shared background service, which reads the key from its own environment. If the service started before you set MORSE_API_KEY, pass the key to it:

    Terminal
    opencode service set env MORSE_API_KEY "$MORSE_API_KEY"
  3. Start OpenCode

    In your project's folder, run opencode. It starts on the model the file names, and /models switches to another.

    Terminal
    opencode

Which model to pick

ModelContextInput / outputWhy
qwen/qwen3-coder256K$0.375 / $1.25Qwen's coding model. It doesn't reason, so it starts writing sooner.
moonshotai/kimi-k3.1-pro1M$2 / $10Reasons, and reads images.
z-ai/glm-5.31M$1.40 / $4.40Reasons, and takes tools at TEE too.
deepseek/deepseek-v4-pro-08131M$1.32 / $3.96Reasons, at a lower price.
z-ai/glm-5.3-flash1M$0.15 / $0.50Cheap and fast for small edits, and takes tools at TEE too.

Prices are in dollars per million tokens, on each model's default endpoint. Every model is on the models page.

Check it works

Ask OpenCode to change a line in one of your files. It edits files with its tools, so a finished edit shows that Morse took the request and its tool calls. One command does the same without the interface:

Terminal
opencode run --auto --model morse/qwen/qwen3-coder "In README.md, fix the first typo you find."

Keep it private

Set a privacy floor on OpenCode's key to hold it to a tier, such as TEE. Without a floor, a request runs on its model's default privacy tier. The floor only decides which endpoints serve the requests. See Privacy tiers and Provider routing.

On a plain API call, TLS ends inside Morse's door, an attested enclave, which seals the request before the relay receives it. A plain client checks the door's certificate, not its attestation. To check the attestation yourself, see Sealed API keys.

If something goes wrong

What you seeWhat to do
Provider not found: morseOpenCode didn't read the provider. Check the file's name and folder, and that it uses provider, npm, and options as above: OpenCode 1 skips OpenCode 2's providers format.
401 invalid_api_keyCheck that MORSE_API_KEY is set where OpenCode starts, and that the key isn't revoked.
402 insufficient_balance or key_spend_limit_reachedAdd credits, or raise the key's spend limit. A request holds credit for its output limit before it starts: see Holds.
404 model_not_foundUse a model's id exactly as the table above writes it, with the part before the slash.

Every code is in Error codes. For other tools, see Tools and coding agents.