Skip to main content

Using Junie CLI with OpenRouter

Junie CLI is an agentic coding tool by JetBrains that provides an interactive terminal interface for developers to review, write, and modify code. By connecting Junie to OpenRouter, you can access hundreds of AI models from a single API key instead of managing separate keys for each provider.

Why Use OpenRouter with Junie?

  • Access to hundreds of models — Use models from Anthropic, OpenAI, Google, xAI, Meta, and many more through a single API key
  • Provider failover — If one provider is unavailable or rate-limited, OpenRouter automatically routes to another
  • Centralized billing — Track and manage spending across all models from your OpenRouter dashboard
  • Team controls — Set budgets and monitor usage across your organization

Prerequisites

Step 1: Install Junie CLI

Verify the installation:

Step 2: Configure OpenRouter

Junie supports OpenRouter as a built-in BYOK (Bring Your Own Key) provider. Set the JUNIE_OPENROUTER_API_KEY environment variable to connect Junie to OpenRouter:
Replace <your-openrouter-api-key> with your actual OpenRouter API key from the API Keys page. Keys start with sk-or-v1-.

Step 3: Start Coding

Navigate to your project directory and start Junie:
Type your prompt in the interactive CLI:
Use @ to attach files or folders to the request context, and type / to see available slash commands.

Headless Mode (CI/CD)

Junie supports a headless mode for non-interactive use in CI/CD pipelines. Combined with OpenRouter, this gives you centralized billing and model access for automated coding tasks:

GitHub Actions Example

GitLab CI/CD Example

Follow the setup instructions to configure the Junie Workspace project, then add JUNIE_OPENROUTER_API_KEY as a CI/CD variable. Once set up, trigger reviews by commenting on any MR:

Verify Your Connection

After starting a session, check the OpenRouter Activity Dashboard to confirm your requests are being routed through OpenRouter.

Learn More