JUNIE CLI BYOK
ROUTING ACTIVE
JUNIE CLI INTEGRATION
JUNIE BYOKSMART ROUTING

Cut Junie
Costs by
60%

JetBrains Junie CLI with BYOK sends hundreds of API calls per session. Route simple tasks to Haiku. Reserve Opus for what matters.

$npx @relayplane/proxy --port 4100
JUNIE SESSION LOGROUTING
[10:02:01] Reading project files → haiku
[10:02:02] Analyzing dependencies → haiku
[10:02:04] Planning implementation → sonnet
[10:02:06] Writing code changes → sonnet
[10:02:08] Verifying syntax → haiku
[10:02:10] Complex refactor → opus
[10:02:14] Final lint check → haiku
✓ Task done · 7 calls · $0.28 (was $0.70)
ALL OPUS$15.00/1M
WITH RELAYPLANEavg $0.85/1M
// ABOUT JUNIE CLI

JetBrains' New Coding Agent

Junie CLI launched March 2026 as JetBrains' LLM-agnostic terminal coding agent. With BYOK support, you bring your own Anthropic, OpenAI, or Google API keys — and pay providers directly.

But BYOK doesn't mean cheap. A typical Junie session analyzing and refactoring code can rack up 50–200 API calls. Using Claude Opus for everything is like taking a taxi everywhere when a scooter would do.

TYPICAL JUNIE SESSION COSTS
Quick fix (15 calls)
$1.80$0.72
Feature build (60 calls)
$7.20$2.88
Big refactor (150 calls)
$18.00$7.20
MONTHLY (heavy use)
$450+$180
60%
Average cost reduction
200+
API calls per heavy session
<1ms
Routing decision latency
// QUICK START

Three Steps to Start Saving

Works alongside Junie's BYOK. No code changes required.

~/projects/my-project
# Step 1: Start the RelayPlane proxy
npx @relayplane/proxy --port 4100
▸ RelayPlane proxy listening on http://localhost:4100
# Step 2: Set your Anthropic API key and proxy URL
export ANTHROPIC_API_KEY="sk-ant-..."
export ANTHROPIC_BASE_URL=http://localhost:4100
# Step 3: Run Junie with BYOK — all Claude calls route through RelayPlane
JUNIE_ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY junie
✓ Junie now routes through RelayPlane — smart model selection enabled
ALTERNATIVE: One-liner with all vars
$ANTHROPIC_BASE_URL=http://localhost:4100 JUNIE_ANTHROPIC_API_KEY=sk-ant-... junie
// HOW IT WORKS

Transparent Proxy Architecture

01

Junie Makes API Call

POST /v1/messages

Junie CLI sends Claude API requests. With ANTHROPIC_BASE_URL set, calls go to RelayPlane instead of Anthropic directly.

02

RelayPlane Routes

→ claude-3-5-haiku

Analyzes the prompt complexity. File reads and simple checks go to Haiku. Deep reasoning goes to Sonnet or Opus.

03

Anthropic Responds

← SSE stream

RelayPlane forwards to the optimal model and streams the response back to Junie. Completely transparent.

// ROUTING MODES

Choose Your Strategy

DEFAULT

Smart Routing

relayplane:auto

Infers task complexity from the prompt. Junie file-reads go to Haiku, complex reasoning goes to Sonnet/Opus.

file_read → haiku
code_analysis → sonnet
AGGRESSIVE

Cost Priority

relayplane:cost

Maximum savings. Routes everything to Haiku first, escalates only on failure.

everything → haiku
# escalate on error
CONSERVATIVE

Quality Priority

relayplane:quality

Uses best available model. Similar quality to native Junie, but with routing telemetry.

everything → opus
# full quality mode
// ENVIRONMENT VARIABLES

Config Reference

RelayPlane (proxy config)

ANTHROPIC_API_KEY

Your Anthropic key — used by the proxy to forward requests

ANTHROPIC_BASE_URL

Set to http://localhost:4100 to route through proxy

OPENAI_API_KEY

Optional: enable OpenAI model routing

Junie CLI (BYOK)

JUNIE_ANTHROPIC_API_KEY

Your Anthropic key for Junie BYOK authentication

JUNIE_MODEL

Default model (RelayPlane overrides per-request)

JUNIE_API_KEY

Alternative: JetBrains subscription key

~/.bashrc or ~/.zshrc
# RelayPlane proxy config
export ANTHROPIC_API_KEY="sk-ant-your-key-here"
export ANTHROPIC_BASE_URL="http://localhost:4100"

# Optional: multi-provider routing
export OPENAI_API_KEY="sk-your-openai-key"

# Junie BYOK (mirrors your Anthropic key)
export JUNIE_ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY"
// REAL SAVINGS EXAMPLE

A Day of Junie Sessions

WITHOUT RELAYPLANE
Morning standup prep$2.40
Feature implementation$8.60
Bug investigation$5.20
PR review + fixes$3.80
Daily total$20.00
Monthly (~22 workdays): $440
WITH RELAYPLANE
Morning standup prep$0.90
Feature implementation$3.20
Bug investigation$1.90
PR review + fixes$1.40
Daily total$7.40
Monthly (~22 workdays): $163
$277 saved per month
per developer, at typical Junie usage. Zero code changes.
// TROUBLESHOOTING

Common Issues

Junie not using the proxy?

Confirm ANTHROPIC_BASE_URL is set in the same shell session where you run Junie:

echo $ANTHROPIC_BASE_URL  # Should show http://localhost:4100

Proxy not running?

Start RelayPlane with verbose mode to see what's happening:

npx @relayplane/proxy --port 4100 -v

Authentication errors?

Make sure both env vars reference the same Anthropic API key:

export ANTHROPIC_API_KEY="sk-ant-..."
export JUNIE_ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY"

Want to verify routing is working?

Check the RelayPlane stats endpoint while Junie is running:

curl http://localhost:4100/control/stats | jq

Bypass proxy for a session?

Unset ANTHROPIC_BASE_URL to go direct, then reset it:

unset ANTHROPIC_BASE_URL && junie

Start Saving Today

One environment variable. No Junie config changes. Instant cost reduction.

100% OPEN SOURCEMIT LICENSEJUNIE COMPATIBLE