Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions aibridge/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const (
ClientRoo Client = "Roo Code"
ClientCursor Client = "Cursor"
ClientOpenCode Client = "OpenCode"
ClientJunie Client = "Junie"
ClientUnknown Client = "Unknown"
)

Expand Down Expand Up @@ -58,6 +59,8 @@ func GuessClient(r *http.Request) Client {
return ClientCursor
case strings.HasPrefix(userAgent, "opencode/"):
return ClientOpenCode
case strings.HasPrefix(userAgent, "junie:"):
return ClientJunie
}
return ClientUnknown
}
5 changes: 5 additions & 0 deletions aibridge/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ func TestGuessClient(t *testing.T) {
userAgent: "opencode/1.16.0 ai-sdk/provider-utils/4.0.23 runtime/bun/1.3.14",
wantClient: aibridge.ClientOpenCode,
},
{
name: "junie_cli",
userAgent: "Junie:SNAPSHOT",
wantClient: aibridge.ClientJunie,
},
{
name: "unknown_client",
userAgent: "ccclaude-cli/calude-with-wrong-prefix",
Expand Down
1 change: 1 addition & 0 deletions docs/ai-coder/ai-gateway/clients/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
| [Kilo Code](./kilo-code.md) | ✅ | ✅ | ❌ | |
| [VS Code](./vscode.md) | ✅ | ✅ | ❌ | VS Code 1.122+ via Custom Endpoint provider. GitHub sign-in not required. Inline suggestions still require GitHub Copilot. |
| [JetBrains IDEs](./jetbrains.md) | ✅ | ❌ | ❌ | Works in Chat mode via [third-party model configuration](https://www.jetbrains.com/help/ai-assistant/use-custom-models.html#provide-your-own-api-key). |
| [Junie](./junie.md) | ✅ | ✅ | ✅ | Junie CLI via custom model profiles. |
| [Zed](./zed.md) | ✅ | ✅ | ❌ | |
| [GitHub Copilot](./copilot.md) | ⚙️ | - | - | Requires [AI Gateway Proxy](../ai-gateway-proxy/index.md). Uses per-user GitHub tokens. |
| Devin Desktop (formerly Windsurf) | ❌ | ❌ | ❌ | No option to override base URL. |
Expand All @@ -62,7 +63,7 @@

*Legend: ✅ supported, ⚙️ requires AI Gateway Proxy, ❌ not supported, - not applicable.*

## Configuring In-Workspace Tools

Check warning on line 66 in docs/ai-coder/ai-gateway/clients/index.md

View workflow job for this annotation

GitHub Actions / lint-docs

Coder.GerundHeading

Heading starts with an -ing word ('Configuring'); prefer the imperative ('Install') or the noun ('Installation'). See capitalization-and-punctuation.md#no-gerund-leading-headings.

AI coding tools running inside a Coder workspace, such as IDE extensions, can be configured to use AI Gateway.

Expand Down
127 changes: 127 additions & 0 deletions docs/ai-coder/ai-gateway/clients/junie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Junie

> [!NOTE]
> AI Gateway is part of [AI Governance](../../ai-governance.md), which is
> included with a Premium license.

[Junie CLI](https://junie.jetbrains.com/docs/junie-cli.html) supports AI Gateway
through [custom model profiles](https://junie.jetbrains.com/docs/custom-llm-models.html#using-custom-models).

| Provider | API type | Endpoint |
|-----------|-------------------|--------------------------|
| OpenAI | `OpenAIResponses` | `/openai/v1/responses` |
| Anthropic | `Anthropic` | `/anthropic/v1/messages` |

For Junie inside JetBrains IDEs, refer to [JetBrains IDEs](./jetbrains.md).

## Prerequisites

* **Junie CLI**: Installed with `curl -fsSL https://junie.jetbrains.com/install.sh | bash`.
* **Authentication**: Your **[Coder API token](../../../admin/users/sessions-tokens.md#generate-a-long-lived-api-token-on-behalf-of-yourself)**.

## Centralized API Key

Junie discovers custom model profiles from JSON files in two locations:

| Scope | Location |
|---------|--------------------------|
| User | `~/.junie/models/*.json` |
| Project | `.junie/models/*.json` |

The file name without the `.json` extension is the profile ID.

Create `~/.junie/models/ai-gateway.json` for the OpenAI endpoint:

```json
{
"id": "gpt-5.5",
"baseUrl": "https://coder.example.com/api/v2/ai-gateway/openai/v1/responses",
"apiType": "OpenAIResponses",
"apiKey": "${CODER_API_TOKEN}",
"fasterModel": { "id": "gpt-5.4-mini" }
}
```

Or for the Anthropic endpoint:

```json
{
"id": "claude-sonnet-5",
"baseUrl": "https://coder.example.com/api/v2/ai-gateway/anthropic/v1/messages",
"apiType": "Anthropic",
"apiKey": "${CODER_API_TOKEN}",
"fasterModel": { "id": "claude-haiku-4-5-20251001" }
}
```

*Replace `coder.example.com` with your Coder deployment URL.*

> [!NOTE]
> `baseUrl` is the complete endpoint URL. Junie does not append a path to it, so
> include `/v1/responses` for `OpenAIResponses` and `/v1/messages` for
> `Anthropic`.

Junie resolves `${VAR}` references in `apiKey` and `extraHeaders` from the
environment, so the token never has to be written to disk:

```sh
export CODER_API_TOKEN=$(coder login token)
```

Run Junie with the profile:

```sh
junie --model custom:ai-gateway
```

Custom profiles also appear in the model selection list of the interactive TUI
and in the `/model` slash command.

## BYOK (Personal API Key)

Junie supports custom headers, so BYOK works by sending your personal provider
key as the API key and the Coder API token as the governance token:

```json
{
"id": "gpt-5.5",
"baseUrl": "https://coder.example.com/api/v2/ai-gateway/openai/v1/responses",
"apiType": "OpenAIResponses",
"apiKey": "${OPENAI_API_KEY}",
Comment thread
matifali marked this conversation as resolved.
"extraHeaders": { "X-Coder-AI-Governance-Token": "${CODER_API_TOKEN}" }
}
```

Set both environment variables:

```sh
# Your personal provider API key, forwarded to the upstream provider.
export OPENAI_API_KEY="<your-openai-api-key>"

# Your Coder API token, used for authentication with AI Gateway.
export CODER_API_TOKEN="<your-coder-api-token>"
```

## Pre-configuring in Templates

Commit the profile to your repository at `.junie/models/ai-gateway.json` and
inject the token from the template, so users get a working configuration without
manual setup:

```tf
data "coder_workspace_owner" "me" {}

data "coder_workspace" "me" {}

resource "coder_env" "coder_api_token" {
agent_id = coder_agent.main.id
name = "CODER_API_TOKEN"
value = data.coder_workspace_owner.me.session_token
}
```

Reference the deployment URL in the profile with
`${data.coder_workspace.me.access_url}/api/v2/ai-gateway/openai/v1/responses`
if you generate the file from the template instead of committing it.

**References:** [Junie custom LLMs](https://junie.jetbrains.com/docs/custom-llm-models.html#using-custom-models)
3 changes: 3 additions & 0 deletions docs/ai-coder/ai-gateway/monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,13 @@ Available query filters:
- `GitHub Copilot (VS Code)`
- `GitHub Copilot (CLI)`
- `Kilo Code`
- `Roo Code`
- `Coder Agents`
- `Mux`
- `Cursor`
- `OpenCode`
- `Charm Crush`
- `Junie`
- `Unknown`

</details><br>
Expand Down
6 changes: 6 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,12 @@
"path": "./ai-coder/ai-gateway/clients/jetbrains.md",
"state": ["premium"]
},
{
"title": "Junie",
"description": "Configure Junie CLI to route requests through AI Gateway with a custom model profile.",
"path": "./ai-coder/ai-gateway/clients/junie.md",
"state": ["premium"]
},
{
"title": "Zed",
"description": "Configure the Zed editor's language models to route requests through AI Gateway.",
Expand Down
7 changes: 7 additions & 0 deletions site/src/pages/AIBridgePage/icons/AIBridgeClientIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ export const AIBridgeClientIcon = ({
className={cn(iconClassName, className)}
/>
);
case "Junie":
return (
<ExternalImage
src="/icon/junie.svg"
className={cn(iconClassName, className)}
/>
);
case "GitHub Copilot (VS Code)":
case "GitHub Copilot (CLI)":
return (
Expand Down
1 change: 1 addition & 0 deletions site/src/theme/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"jetbrains-toolbox.svg",
"jetbrains.svg",
"jfrog.svg",
"junie.svg",
"jupyter.svg",
"k8s.png",
"k8s.svg",
Expand Down
5 changes: 5 additions & 0 deletions site/static/icon/junie.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading