How to Use Claude Code with OpenRouter (Fast Install)
This video shows how to use Claude Code with OpenRouter so you can use any AI model you want in 10 minutes for both Mac & Windows. You can also use Claude Code for free via this method by selecting OpenRouter's free models. This is the easiest method to perform this switch that I have found. -- Chapters: 0:20 Install NodeJS 0:50 Install Claude Code 1:00 Create A Folder 1:20 Create an OpenRouter API Key 1:44 Configure Quick Setup Code with API Key & Model Selections 2:55 Run Configured Quick Setup Code in IDE Terminal 3:13 Initialize Claude 3:25 Claude Code Model Selection 3:40 Run the Agent with a Job 4:17 Run Quick Setup Code Per Project 4:38 OpenRouter Model Selection & Free Models 4:57 Evaluating Models via Arena AI 5:20 Reminder to Run Quick Setup Code Per Project 5:35 Note to Windows Users -- Setup: Step 1. Copy & Paste Node Install Command for your operating system into your terminal from https://nodejs.org/en/download Step 2. Install Claude Code: npm install -g @anthropic-ai/claude-code Step 3. Create a folder on your desktop in which you want to run Claude Code. Step 4. Get an OpenRouter API Key & fund your account, otherwise, use a free model from OpenRouter. OPTIONAL STEP: For Previous Claude Code Users Only -- You need to clear your previous session. Enter: claude /logout Step 5. We're going to setup a fast-start code block that you'll run in each new project folder you're going to use Claude Code with OpenRouter in before starting Claude Code. It skips the login and configures your OpenRouter Models for that project specifically. Copy the code block for your operating system (which is sitting between divider lines for visual clarity) and replace the "ANTHROPIC_AUTH_TOKEN" value with your OpenRouter API key, and input your desired OpenRouter models for each of the "ANTHROPIC_DEFAULT_OPUS_MODEL", "ANTHROPIC_DEFAULT_SONNET_MODEL", "ANTHROPIC_DEFAULT_HAIKU_MODEL", and "CLAUDE_CODE_SUBAGENT_MODEL" environment variables. I’ve preconfigured a few popular, cheaper models, but you can switch those with any model on OpenRouter. Your success may vary per model. Code snippet available here as a webpage since I can't paste code in the description directly: https://pub-836affdf54f543309ac673e6b0d0d17f.r2.dev/claude-code-openrouter-snippets.html Step 5, Continued: When done and you have your API Key in as well as the OpenRouter Models you want to use, save that entire configured command block into a secure, encrypted file that you'll never expose to the internet so your OpenRouter API key doesn't leak. You'll paste this into the terminal once per new project for quick setup. This avoids having to mess with shell profiles which is where most people run into issues, and allows you to set different OpenRouter models per project. You can switch out the models for an in-progress project by editing settings.local.json in your .claude folder at any time, and rebooting Claude code. 6. Lastly, run the command: claude 7. Switch between your preconfigured models with /model —— If you need to uninstall the Claude Code CLI in the future, you can run: npm uninstall -g @anthropic-ai/claude-code
Download
1 formatsVideo Formats
Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.