-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: track Junie as an AI Gateway client #28266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9ae4ee7
feat: track Junie as an AI Gateway client
matifali 78898a8
docs: state the tested Junie API types
matifali b5e7aa9
chore(site/static/icon): scale junie icon to 256x256
matifali 73dc98a
fix(aibridge): match only the observed Junie user agent prefix
matifali b4bbbb3
Merge branch 'main' into matifali/junie-ai-gateway-client
matifali c1d7eaf
docs(docs/ai-coder/ai-gateway/clients): use junie.jetbrains.com refer…
matifali 8d2767f
Merge remote-tracking branch 'origin/main' into matifali/junie-ai-gat…
matifali File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}", | ||
| "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) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.