> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Junie

> Route Junie CLI model calls through Orq.ai AI Gateway with a custom model profile, for unified tracing, cost tracking, and model governance.

[Junie](https://junie.jetbrains.com/) is the JetBrains coding agent. The CLI connects to the [**Orq.ai AI Gateway**](/docs/ai-gateway/get-started/introduction) through a custom model profile: a JSON file that names the endpoint and the models to run. Requests appear in [Traces](/docs/ai-studio/observability/traces) automatically.

## Prerequisites

* Junie CLI installed
* Active **Orq.ai** account with **AI Gateway** access
* [**Orq.ai** API key](/docs/ai-studio/organization/api-keys)
* Model enabled in [**AI Gateway** → **Supported Models**](/docs/ai-gateway/supported-models)

A custom model profile authenticates with the **Orq.ai** API key alone, so no JetBrains AI subscription is required.

### Install Junie CLI

<Tabs>
  <Tab title="macOS / Linux" icon="terminal">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    curl -fsSL https://junie.jetbrains.com/install.sh | bash
    ```
  </Tab>

  <Tab title="Windows" icon="windows">
    ```powershell theme={"theme":{"light":"github-light","dark":"github-dark"}}
    powershell -NoProfile -ExecutionPolicy Bypass -Command "iex (irm 'https://junie.jetbrains.com/install.ps1')"
    ```
  </Tab>
</Tabs>

Confirm the install:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
junie --version
```

Homebrew and npm alternatives are listed in the [Junie quickstart](https://junie.jetbrains.com/docs/junie-cli.html#step-1-install-junie-cli).

## Setup

<Steps>
  <Step title="Create the model profile">
    Junie loads custom profiles from `$JUNIE_HOME/models/*.json` at user scope (`$JUNIE_HOME` defaults to `~/.junie`) and from `.junie/models/*.json` in the project root. The filename becomes the profile identifier, so `orq.json` is selected as `custom:orq`.

    Create `~/.junie/models/orq.json`, creating the `models` directory if it does not exist. Only `baseUrl` and `apiType` change between the three supported wire formats:

    <CodeGroup>
      ```json JSON (OpenAI Responses) theme={"theme":{"light":"github-light","dark":"github-dark"}}
      {
        "id": "openai/gpt-5.6-sol",
        "baseUrl": "https://my.orq.ai/v3/router/responses",
        "apiType": "OpenAIResponses",
        "apiKey": "${ORQ_API_KEY}",
        "displayName": "Orq.ai AI Gateway",
        "providerName": "Orq.ai",
        "fasterModel": {
          "id": "openai/gpt-5.4-mini"
        }
      }
      ```

      ```json JSON (Chat Completions) theme={"theme":{"light":"github-light","dark":"github-dark"}}
      {
        "id": "anthropic/claude-sonnet-5",
        "baseUrl": "https://my.orq.ai/v3/router/chat/completions",
        "apiType": "OpenAICompletion",
        "apiKey": "${ORQ_API_KEY}",
        "displayName": "Orq.ai AI Gateway",
        "providerName": "Orq.ai",
        "fasterModel": {
          "id": "openai/gpt-5.4-mini"
        }
      }
      ```

      ```json JSON (Anthropic Messages) theme={"theme":{"light":"github-light","dark":"github-dark"}}
      {
        "id": "anthropic/claude-sonnet-5",
        "baseUrl": "https://my.orq.ai/v3/anthropic/v1/messages",
        "apiType": "Anthropic",
        "apiKey": "${ORQ_API_KEY}",
        "displayName": "Orq.ai AI Gateway",
        "providerName": "Orq.ai",
        "fasterModel": {
          "id": "anthropic/claude-haiku-4-5"
        }
      }
      ```
    </CodeGroup>

    `id` is the model used for reasoning and code generation. `fasterModel` overrides it for helper tasks such as summarizing context, and inherits every top-level value it does not set. The model IDs above are examples: any provider-prefixed model enabled in [**AI Gateway** → **Supported Models**](/docs/ai-gateway/supported-models) works, and one profile can mix models from different providers.
  </Step>

  <Step title="Export the API key">
    The `apiKey` value resolves `${ORQ_API_KEY}` when the profile loads. Export the variable in the shell that starts Junie:

    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export ORQ_API_KEY=<ORQ_API_KEY>
    ```

    If the variable is unset, Junie refuses to load the profile and names the unresolved variable.
  </Step>

  <Step title="Start Junie on the profile">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    junie --model custom:orq
    ```

    Without the flag, `junie` opens the model picker, where the profile is listed as **Orq.ai AI Gateway** under the **Orq.ai** provider. A custom profile needs no JetBrains account: when one is available, the picker replaces the sign-in options.

    On the first interactive launch Junie also offers to import configuration from Claude Code or Codex, which can be skipped, and asks about sharing anonymous statistics.
  </Step>
</Steps>

<Note>
  A profile in `.junie/models/` loads only for a trusted project, and Junie asks for that decision when the interactive UI opens the project. Because `--model` is resolved before the UI opens, a first run in a new project fails with `Unknown custom model profile`. To use project scope instead of user scope, start `junie` once without `--model`, choose **Trust this project**, then launch with the profile. User scope has no trust requirement.
</Note>

<Note>
  Gateway routing requires the Junie CLI. The JetBrains IDE plugin cannot be pointed at a custom endpoint yet, so this profile has no effect inside the IDE ([JUNIE-554](https://youtrack.jetbrains.com/issue/JUNIE-554)).
</Note>

## Configuration reference

| Field              | Required | Description                                                                             |
| ------------------ | -------- | --------------------------------------------------------------------------------------- |
| `id`               | Yes      | Model identifier as the endpoint expects it, for example `anthropic/claude-sonnet-5`.   |
| `baseUrl`          | Yes      | Full URL of the endpoint, including the path. See the `apiType` pairings below.         |
| `apiType`          | Yes      | Wire format. Must match the protocol of `baseUrl`; see the pairings below.              |
| `apiKey`           | No       | Sent as the Bearer token. Supports `${VAR}` environment references.                     |
| `displayName`      | No       | Label shown in the model picker. Defaults to the profile filename.                      |
| `providerName`     | No       | Provider label that groups the profile's models in the picker.                          |
| `temperature`      | No       | Sampling temperature. When omitted, the provider default applies.                       |
| `extraHeaders`     | No       | Additional HTTP headers sent with every request. Values support `${VAR}` references.    |
| `extraBody`        | No       | JSON object merged into the body of every request.                                      |
| `maxContextLength` | No       | Maximum context length supported by the model, in tokens.                               |
| `fasterModel`      | No       | Role overrides for helper tasks.                                                        |
| `primaryModel`     | No       | Role overrides for the main model. Rarely needed: top-level values already apply to it. |

The endpoint follows the wire format, not the model vendor. All three combinations are verified working:

| `apiType`          | `baseUrl`                                      |
| ------------------ | ---------------------------------------------- |
| `OpenAICompletion` | `https://my.orq.ai/v3/router/chat/completions` |
| `OpenAIResponses`  | `https://my.orq.ai/v3/router/responses`        |
| `Anthropic`        | `https://my.orq.ai/v3/anthropic/v1/messages`   |

`OpenAICompletion` works with any model enabled in the workspace, because the **AI Gateway** translates the OpenAI format to each provider. Use `Anthropic` for Claude models to reach the provider as a native Messages call instead of through that translation.

Junie also accepts `Google` for Gemini endpoints. The Gemini path carries the model inside the URL (`/v1beta/models/{model}:generateContent`) and the profile supplies `baseUrl` and `id` separately, so it is untested against the **AI Gateway**.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Profile fails to load">
    Junie reports the unresolved variable name when a `${VAR}` reference has no value in the environment. Export the variable in the shell that starts Junie.
  </Accordion>

  <Accordion title="Unknown custom model profile at launch">
    Junie resolves `--model` before the project trust decision, so a profile in `.junie/models/` fails this way on a first run in a new project. Either place the profile at `~/.junie/models/`, or start `junie` once without `--model` and choose **Trust this project**. Confirm the filename matches the selector exactly: `orq.json` is `custom:orq`.
  </Accordion>

  <Accordion title="Model missing from the picker">
    Check that `/model` lists the profile after the built-in providers. A profile in `.junie/models/` is also skipped for an untrusted project, and one in `~/.junie/models/` is not.
  </Accordion>

  <Accordion title="Model not found">
    The `id` must be the provider-prefixed identifier the **AI Gateway** expects, for example `openai/gpt-5.4`. The model also has to be enabled for the workspace in [**AI Gateway** → **Supported Models**](/docs/ai-gateway/supported-models).
  </Accordion>

  <Accordion title="Config edits have no effect">
    Profiles are read when Junie starts. Restart the CLI after editing the file, or reselect the profile with `/model`.
  </Accordion>

  <Accordion title="Authentication error">
    Confirm the API key is a valid **Orq.ai** key and that it is scoped to the workspace holding the models. Keys from other providers are rejected, because the profile sends the value as a Bearer token to the **AI Gateway**.
  </Accordion>

  <Accordion title="No Traces appearing">
    Confirm `baseUrl` matches the `apiType` pairing used, and that the profile was selected for the session. Traces are scoped to the workspace of the API key, and a new trace takes a few seconds to appear in [Traces](/docs/ai-studio/observability/traces).
  </Accordion>
</AccordionGroup>

## Verification

Run a task in a project, for example `junie --model custom:orq "Summarize this repository"`. The session completes in the terminal, and a new row appears within a few seconds in [Traces](/docs/ai-studio/observability/traces) showing the model identifier from the profile's `id`, the token usage, and the tool calls Junie made.
