Junie CLI with AI Gateway
Junie is JetBrains' coding agent, available as a CLI. It loads model profiles from $JUNIE_HOME/models/ (default ~/.junie), which you can point at AI Gateway for unified model access and spend monitoring.
Run the Vercel CLI setup command for Junie CLI:
npx vercel ai-gateway setup --agent junieThe command writes a stable vercel-ai-gateway profile pinned to the leaderboard's top model, plus one profile per shortlisted gateway model, into $JUNIE_HOME/models/. Each profile contains an environment-variable reference to AI_GATEWAY_API_KEY that resolves when the profile loads. Re-run the command to refresh the shortlist; profiles from earlier runs stay in place.
If you can't use the Vercel CLI, configure Junie CLI manually:
Go to the AI Gateway section in the Vercel dashboard sidebar and click API keys to create a new API key.
Export the key in your shell:
Terminalexport AI_GATEWAY_API_KEY="your-ai-gateway-api-key"To persist the key, add the same line to your shell's startup file. Junie resolves
${AI_GATEWAY_API_KEY}in a profile when the profile loads, so the key never lands in the file.Create
~/.junie/models/vercel-ai-gateway.json:~/.junie/models/vercel-ai-gateway.json{ "id": "openai/gpt-6-astra", "displayName": "GPT-6 Astra", "providerName": "Vercel AI Gateway", "baseUrl": "https://ai-gateway.vercel.sh/coding-agent/v1/chat/completions", "apiType": "OpenAICompletion", "apiKey": "${AI_GATEWAY_API_KEY}", "maxContextLength": 1050000 }The
idis the gateway model the profile selects. Change it to any gateway model ID, and adjustmaxContextLengthto match.For a picker entry per model, write additional profile files named
vercel-<gateway-model-id>.json(dashes replacing/and other punctuation), each with that model'sidand display name. They group under Vercel AI Gateway in/modelafter the built-in providers.- Terminal
junie --model custom:vercel-ai-gatewayOr pick the model with
/modelin a session. The stable profile defaults to the model in itsid.
View your usage, spend, and request activity in the AI Gateway section in the Vercel dashboard sidebar. See the observability documentation for more details.
| Variable | Description |
|---|---|
AI_GATEWAY_API_KEY | Your AI Gateway API key, read through ${AI_GATEWAY_API_KEY}. Required |
JUNIE_HOME | Overrides the profiles directory. Defaults to ~/.junie |
- Browse the models catalog for available models
- Configure spend limits on your API key
Was this helpful?