# Junie CLI

Run Junie CLI, JetBrains' terminal agent, on models you pay for in DA.

Junie takes a custom model profile: a JSON file naming an address, a model ID and a key. A profile pointing at OpenDunes sends each request to [`POST /v1/chat/completions`](/docs/reference/chat-completions).

1. [Install Junie CLI](#1-install-junie-cli).
2. [Write the model profile](#2-write-the-model-profile).
3. [Start Junie on the profile](#3-start-junie-on-the-profile).
4. [Run it from a script](#4-run-it-from-a-script).

## 1. Install Junie CLI

| On | Install line |
|---|---|
| macOS, Linux | `curl -fsSL https://junie.jetbrains.com/install.sh \| bash` |
| Windows, PowerShell | `iex (irm 'https://junie.jetbrains.com/install.ps1')` |

Create an API key for Junie alone, and cap it on *API Keys* ([API keys](/docs/api-keys) shows how). Put it in your shell profile, `~/.zshrc` or `~/.bashrc`, as `export OPENDUNES_API_KEY="…"`.

## 2. Write the model profile

Save this as `~/.junie/models/opendunes.json`. The file's name, `opendunes`, is the profile's name.

```json
{
  "id": "anthropic/claude-sonnet-4.5",
  "baseUrl": "https://opendunes.com/v1/chat/completions",
  "apiType": "OpenAICompletion",
  "apiKey": "${OPENDUNES_API_KEY}",
  "displayName": "Claude Sonnet 4.5 on OpenDunes",
  "providerName": "OpenDunes",
  "fasterModel": {
    "id": "anthropic/claude-haiku-4.5"
  }
}
```

| Key | Holds |
|---|---|
| `id` | the model ID Junie sends, from [Models](/docs/models) |
| `baseUrl` | the full address of the route, `/v1/chat/completions` included |
| `apiType` | `OpenAICompletion`: the chat completions shape |
| `apiKey` | your key, read from `OPENDUNES_API_KEY` when Junie starts |
| `fasterModel` | a second model for Junie's side tasks, such as summaries |

Each model is charged at its own rate, shown on its page in Models.

<div class="dont">
<p>Don't write the key itself into a profile under <code>.junie/models/</code> in a project. That folder is committed, and the key goes with it.</p>
</div>

<div class="do">
<p>Keep <code>${OPENDUNES_API_KEY}</code> in <code>apiKey</code>: the profile can then be shared, and each person runs it on their own key.</p>
</div>

## 3. Start Junie on the profile

```bash
junie --model custom:opendunes
```

In a session, `/model custom:opendunes` switches to it, and `/model` lists every model Junie knows, your profile among them. Send one task, then open *Activity*, in the app on opendunes.com: each request Junie sent is there, with its charge in DA.

<div class="watch-out">
<p>If <code>OPENDUNES_API_KEY</code> is not set, Junie cannot load the profile. Open a new terminal after editing your shell profile.</p>
</div>

## 4. Run it from a script

Give the task as an argument, and Junie runs it without asking:

```bash
junie --model custom:opendunes "Fix the failing test in tests/test_cart.py"
```

A run without the interface trusts the project and loads its `.junie` settings without asking. Run it on your own code only.

## Errors

| Status | Means | Do |
|---|---|---|
| 401 | the key is wrong, paused, revoked or expired | check `OPENDUNES_API_KEY` in the terminal Junie starts from |
| 402 | the balance is at zero or below, cannot pay the request's hold, or the key's cap is spent | make a deposit, or raise the cap |
| 404 | the model ID is not on sale, or `baseUrl` lacks `/v1/chat/completions` | copy the ID from Models, and the address from step 2 |

Every other status: [Errors and retries](/docs/errors-and-retries). Other terminal agents: [Coding agents](/docs/coding-agents).

Next: [OpenCode](/docs/cookbook/opencode) · [Hermes Agent](/docs/cookbook/hermes-agent)
