Connect Pi to the private Morse API: set it up, pick a model, and check it works. Updated November 30, 2026.

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

# Use Pi with a private API

Give [Pi](https://pi.dev) the base URL `https://inference.trymorse.ai/v1` and a Morse API key. It calls the OpenAI API.

## Before you start

Make a key for Pi 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 Pi 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 Pi for you. Or set it up by hand, below.

Setup prompt

```
Set up Pi 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/pi, then run its check.

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

## Set up Pi

1. Add Morse as a providerSave this as `~/.pi/agent/models.json`. It names Morse's base URL, the variable your key is in, and each model's limits and prices. Keep the `$` in `apiKey`: without it, Pi sends the variable's name as the key.models.json`{ "$schema": "https://pi.dev/schemas/models.schema.json", "providers": { "morse": { "name": "Morse", "baseUrl": "https://inference.trymorse.ai/v1", "api": "openai-completions", "apiKey": "$MORSE_API_KEY", "models": [ { "id": "qwen/qwen3-coder", "name": "Qwen3 Coder 480B A35B", "reasoning": false, "input": [ "text" ], "contextWindow": 262144, "maxTokens": 32768, "cost": { "input": 0.375, "output": 1.25, "cacheRead": 0.125, "cacheWrite": 0 } }, { "id": "moonshotai/kimi-k3.1-pro", "name": "Kimi K3.1 Pro", "reasoning": true, "input": [ "text", "image" ], "contextWindow": 1048576, "maxTokens": 32768, "cost": { "input": 2, "output": 10, "cacheRead": 0.2, "cacheWrite": 0 }, "thinkingLevelMap": { "off": "none", "minimal": null, "low": "low", "medium": null, "high": "high", "xhigh": null, "max": "max" } }, { "id": "z-ai/glm-5.3", "name": "GLM 5.3", "reasoning": true, "input": [ "text" ], "contextWindow": 1048576, "maxTokens": 32768, "cost": { "input": 1.4, "output": 4.4, "cacheRead": 0.26, "cacheWrite": 0 }, "thinkingLevelMap": { "off": null, "minimal": null, "low": "low", "medium": null, "high": "high", "xhigh": null, "max": "max" } }, { "id": "deepseek/deepseek-v4-pro-0813", "name": "DeepSeek V4 Pro", "reasoning": true, "input": [ "text" ], "contextWindow": 1048576, "maxTokens": 32768, "cost": { "input": 1.32, "output": 3.96, "cacheRead": 0.13, "cacheWrite": 0 }, "thinkingLevelMap": { "off": "none", "minimal": null, "low": "low", "medium": null, "high": "high", "xhigh": null, "max": "max" } }, { "id": "z-ai/glm-5.3-flash", "name": "GLM 5.3 Flash", "reasoning": true, "input": [ "text", "image" ], "contextWindow": 1048576, "maxTokens": 32768, "cost": { "input": 0.15, "output": 0.5, "cacheRead": 0.03, "cacheWrite": 0 }, "thinkingLevelMap": { "off": null, "minimal": null, "low": "low", "medium": null, "high": "high", "xhigh": null, "max": "max" } } ] } } }`With `cost` filled in, the totals Pi shows match what Morse charges.
2. Start Pi on a Morse modelTerminal`pi --provider morse --model qwen/qwen3-coder`On a model that reasons, add `--thinking high`, or another level the model's `thinkingLevelMap` names.

## Install the Morse plugin

Morse's provider extension for Pi is on GitHub, at [trymorse/pi-morse-provider](https://github.com/trymorse/pi-morse-provider). Its README shows how to install it from there. The steps above set Pi up without it.

## Which model to pick

| Model | Context | Input / output | Why |
| --- | --- | --- | --- |
| `qwen/qwen3-coder` | 262.1K | $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 Pi to list the files in your folder. It calls a tool to read them, so an answer shows that Morse took both the request and its tools. One command asks and exits:

```
pi --provider morse --model qwen/qwen3-coder -p "List the files in this folder." </dev/null
```

## Keep it private

Set a privacy floor on Pi'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 |
| --- | --- |
| Pi lists no Morse models | Set `MORSE_API_KEY` where Pi starts. Pi lists a provider's models only once its key is set. |
| Pi's cost doesn't match your usage page | Fill in the model's `cost`, in dollars per million tokens, from the table above. |
| `401 invalid_api_key` | Check that `MORSE_API_KEY` is set where Pi 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).
