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

Page: https://trymorse.ai/inference/docs/tools/opencode

# Use OpenCode with a private, uncensored API

Give [OpenCode](https://opencode.ai) 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](https://trymorse.ai/inference/uncensored).

## Before you start

Make a key for OpenCode alone, with a spend limit, under **API keys** in the [console](https://console.trymorse.ai). Then one tool can't spend all your credits. See [Limit a key](https://trymorse.ai/inference/docs/authentication#limits). 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 providerSave 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 keyOpenCode 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 OpenCodeIn 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

| Model | Context | Input / output | Why |
| --- | --- | --- | --- |
| `qwen/qwen3-coder` | 256K | $0.375 / $1.25 | Qwen's coding model. It doesn't reason, so it starts writing sooner. |
| `moonshotai/kimi-k3.1-pro` | 1M | $2 / $10 | Reasons, and reads images. |
| `z-ai/glm-5.3` | 1M | $1.40 / $4.40 | Reasons, and takes tools at TEE too. |
| `deepseek/deepseek-v4-pro-0813` | 1M | $1.32 / $3.96 | Reasons, at a lower price. |
| `z-ai/glm-5.3-flash` | 1M | $0.15 / $0.50 | Cheap 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](https://trymorse.ai/inference/models).

## 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:

```
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](https://trymorse.ai/inference/docs/privacy-tiers) and [Provider routing](https://trymorse.ai/inference/docs/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](https://trymorse.ai/inference/docs/sealed-api-keys).

## If something goes wrong

| What you see | What to do |
| --- | --- |
| `Provider not found: morse` | OpenCode 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_key` | Check that `MORSE_API_KEY` is set where OpenCode starts, and that the key isn't revoked. |
| `402 insufficient_balance` or `key_spend_limit_reached` | Add credits, or raise the key's spend limit. A request holds credit for its output limit before it starts: see [Holds](https://trymorse.ai/inference/docs/pricing#holds). |
| `404 model_not_found` | Use a model's id exactly as the table above writes it, with the part before the slash. |

Every code is in [Error codes](https://trymorse.ai/inference/docs/api/errors). For other tools, see [Tools and coding agents](https://trymorse.ai/inference/docs/tools).
