Connect r2ai 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/r2ai

# Use r2ai with a private API

Give [r2ai](https://github.com/radareorg/r2ai) 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 r2ai 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 r2ai 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 r2ai for you. Or set it up by hand, below.

Setup prompt

```
Set up r2ai 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 deepseek/deepseek-v4.1-flash-1017-abliterated.
4. Follow https://trymorse.ai/inference/docs/tools/r2ai, then run its check.

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

## Set up r2ai

1. Install r2ai and give it your keyr2ai is the AI plugin for the radare2 reverse-engineering framework. Use it on binaries you own or are authorized to analyze. Morse's [acceptable-use policy](https://trymorse.ai/terms) bans creating malware and attacking systems or people you're not authorized to test.Install the plugin with radare2's package manager:Terminal`r2pm -Uci r2ai`r2ai reads the key for its `openai` provider from `OPENAI_API_KEY`. Set it to your Morse key in the shell you start radare2 from:Terminal`export OPENAI_API_KEY="$MORSE_API_KEY"`To keep the key out of your shell, run `r2ai -K` instead. Add a line `openai=` followed by your key to the file it opens.
2. Point r2ai at MorseInside radare2, choose the `openai` provider, set Morse's base URL, and pick a model:Text`r2ai -e api=openai r2ai -e baseurl=https://inference.trymorse.ai/v1 r2ai -e model=deepseek/deepseek-v4.1-flash-1017-abliterated`r2ai adds `/chat/completions` to the base URL itself. To keep these settings, run `r2ai -E` and paste the same three lines into the file it opens. r2ai runs them each time it loads.

## Which model to pick

| Model | Context | Input / output | Why |
| --- | --- | --- | --- |
| `deepseek/deepseek-v4.1-flash-1017-abliterated` | 1M | $0.50 / $1.50 | Uncensored, so it explains what a sample does instead of refusing, with a long context for big functions. |
| `moonshotai/kimi-k3.1-pro-uncensored` | 1M | $5 / $18.75 | Uncensored, and the strongest reasoner here for tangled control flow. |
| `qwen/qwen3.8-27b-uncensored` | 262.1K | $0.35 / $1.75 | Uncensored, cheap, and runs only in attested enclaves. |

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

Open a binary of your own, analyze it, and ask r2ai to decompile `main`. Readable code shows that Morse took the key and the model:

```
r2 -qc 'aaa; s main; r2ai -d' ./your-binary
```

For auto mode, which lets the model run radare2 commands itself, run `r2ai -a` and a question inside radare2.

## Keep it private

Set a privacy floor on r2ai'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 |
| --- | --- |
| r2ai calls another provider | Check that `r2ai -e api` prints `openai` and `r2ai -e baseurl` prints `https://inference.trymorse.ai/v1`. Settings saved with `r2ai -E` run each time r2ai starts, so fix them there too. |
| `r2ai -e model=?` lists models, but every request fails | The model list is public, so it loads without a key. Check that `OPENAI_API_KEY` is set in the shell that started radare2. |
| Responses stop mid-sentence | Raise `r2ai -e max_tokens`. The reasoning these models do before they answer counts toward it. |
| `401 invalid_api_key` | Check that `MORSE_API_KEY` is set where r2ai 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).
