{"id":39311,"date":"2026-12-04T11:38:34","date_gmt":"2026-12-04T11:38:34","guid":{"rendered":"https:\/\/www.milesweb.co.uk\/blog\/?p=39311"},"modified":"2026-12-04T11:38:35","modified_gmt":"2026-12-04T11:38:35","slug":"how-to-set-up-9router-with-claude-code","status":"publish","type":"post","link":"https:\/\/www.milesweb.co.uk\/blog\/hosting\/vps\/how-to-set-up-9router-with-claude-code\/","title":{"rendered":"How to Set Up 9Router with Claude Code: A Step-by-Step Guide"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Claude Code is a popular <a href=\"https:\/\/www.milesweb.co.uk\/blog\/technology-hub\/best-vibe-coding-tools-platforms\/\">Vibe coding tool<\/a> by Anthropic that reads codebases, edits files, runs commands, and automates development tasks across the terminal, IDE, desktop app, and browser. Developers hit the limit of Claude Code because of its prolonged usage. That\u2019s the problem 9Router solves.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The 9Router open-source router runs on the local machine. It sits between Claude Code and the providers you connect to and falls back to another model when one runs out.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The guide navigates you through the setup process, from installing both tools to pointing Claude Code to the local machine. By the end of this blog, you&#8217;ll know if it&#8217;s right for you.<\/p>\n\n\n\n<div class=\"skrlto-container\" style=\"border-radius: 13px; padding: 25px; background: #EEF6FF;\">\n<h2 class=\"skrlto-header-title\">Table of Content<\/h2>\n<div class=\"skrlto-links-wrapper\">\n<ul>\n<li class=\"skroll-button\" data-skrolllto=\"WPT1WPTheme\">Why Use 9Router With Claude Code?<\/li>\n<li class=\"skroll-button\" data-skrolllto=\"WPT2WPTheme\">A Setup Guide for 9Router with Claude Code\n<ul class=\"innr-skroll-button\">\n<li class=\"skroll-button\" data-skrolllto=\"WPT3WPTheme\">Install and Run It<\/li>\n<li class=\"skroll-button\" data-skrolllto=\"WPT4WPTheme\">Connect Your Existing Logins<\/li>\n<li class=\"skroll-button\" data-skrolllto=\"WPT5WPTheme\">Connect Your Providers<\/li>\n<li class=\"skroll-button\" data-skrolllto=\"WPT6WPTheme\">Create a Model Combo with Fallbacks<\/li>\n<li class=\"skroll-button\" data-skrolllto=\"WPT7WPTheme\">Copy Your Endpoint and API Key<\/li>\n<li class=\"skroll-button\" data-skrolllto=\"WPT8WPTheme\">Point Claude Code at 9Router<\/li>\n<\/ul>\n<\/li>\n<li class=\"skroll-button\" data-skrolllto=\"WPT9WPTheme\">FAQs<\/li>\n<\/ul>\n<\/div>\n<\/div>\n\n\n\n<div style=\"max-width:1000px; margin:30px auto; font-family: Arial, Helvetica, sans-serif; border-radius:12px; overflow:hidden; border:1px solid #e5e7eb; background: linear-gradient(90deg, #dbeafe, #eff6ff);\">\n  <div style=\"padding:24px 28px;\">\n    <div style=\"color:#0891b2; font-weight:700; letter-spacing:0.5px; text-transform:uppercase; font-size:13px; margin-bottom:12px;\">TL;DR<\/div>\n    <ul style=\"margin:0; padding-left:20px; color:#1f2937; font-size:15.5px; line-height:1.8;\">\n      <li><strong>9Router<\/strong> is an open-source router that runs on your own machine. It sits between Claude Code and the providers you connect, and it can fall back to another model when one hits its limit, so your work doesn&#8217;t stop mid-task.<\/li>\n      <li>The perks: <strong>automatic fallback<\/strong>, <strong>one endpoint<\/strong> for several providers, a <strong>dashboard<\/strong> to track usage, and room to compare different models on your own projects.<\/li>\n      <li>Setup in short: install and run 9Router, connect only the providers you&#8217;re allowed to use, build a <strong>model combo<\/strong> with fallbacks, copy your endpoint and API key, then point Claude Code at it with three environment variables.<\/li>\n      <li>Check each provider&#8217;s terms before connecting. Using a subscription login through a third-party tool may be restricted, and free tiers often have strict limits and different data-handling rules.<\/li>\n      <li>Fallback models can behave differently, so verify their output on important tasks, and treat every dashboard number as a guide, not your bill.<\/li>\n      <li>Keep your API key secret: store it in a .env file or secrets manager, never in source control or screenshots, and revoke it right away if it leaks.<\/li>\n    <\/ul>\n  <\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u00a0<strong>Also Read:<\/strong> <a href=\"https:\/\/www.milesweb.co.uk\/blog\/technology-hub\/what-is-9router\/\">What is 9router<\/a>?<strong>\u00a0<\/strong><\/p>\n\n\n\n<h2 id=\"WPT1WPTheme\" class=\"wp-block-heading\">Why Use 9Router With Claude Code?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Automatic fallback when credit limits expire:<\/strong> Claude Code stops mid-task when a provider\u2019s quota is exhausted. 9Router lets you configure an ordered list of models, so when the first is unavailable, it tries the next one, and work keeps moving. The trade-off is that a fallback model may behave differently, so verify its output on important tasks.<\/li>\n\n\n\n<li><strong>One endpoint for several providers:<\/strong> Instead of reconfiguring Claude Code every time you switch providers, you point it at the single local address and manage the rest from a dashboard. That\u2019s straightforward if you use multiple API keys or accounts. Furthermore, it means more tools in the chain, keeping it updated, and reviewing what it accesses.<\/li>\n\n\n\n<li><strong>Visibility into usage and limits:<\/strong> The dashboard tracks the usage of connected providers, which helps you plan heavy sessions and spot the cost of origin. It is useful while managing the self-API or sharing the setup with the team. Consider every number as a guide and confirm them against each provider\u2019s billing page.<\/li>\n\n\n\n<li><strong>Room to experiment with different models:<\/strong> Router translates between formats; you can try other models behind the same Claude Code, comparing quality, speed, and cost on your projects. That\u2019s the less-risk way to find the right fit for each task. Stay cautious about free options, since limits, data handling, and terms vary, so read each provider\u2019s policy first.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Also Read<\/strong>: <a href=\"https:\/\/www.milesweb.co.uk\/blog\/hosting\/vps\/how-to-use-9router-with-vs-code-for-ai-assisted-coding\/\">How to Use 9Router with VS Code for AI-Assisted Coding<\/a>?<\/p>\n\n\n\n<h2 id=\"WPT2WPTheme\" class=\"wp-block-heading\">A Setup Guide for 9Router with Claude Code<\/h2>\n\n\n\n<h3 id=\"WPT3WPTheme\" class=\"wp-block-heading\">Step 1: Install and Run It<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install 9Router from the project\u2019s repository; it is a local install, not the service you sign up for.<\/li>\n\n\n\n<li>Start the router. It runs on localhost on the local machine.<\/li>\n\n\n\n<li>Confirm its active status before connecting anything to it.<\/li>\n<\/ul>\n\n\n\n<h3 id=\"WPT4WPTheme\" class=\"wp-block-heading\">Step 2: Connect Your Existing Logins<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Linking your Claude Code credentials is one of the overlooked steps.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Adding more accounts for GitHub, Claude, and Codex gives a buffer before you hit the resource limit. In fact, 9Router supports multiple Claude accounts for any of these providers, pooling them together automatically.<\/p>\n\n\n\n<h3 id=\"WPT5WPTheme\" class=\"wp-block-heading\">Step 3: Connect Your Providers<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Add only the authorized providers:<\/strong> Connect the API keys or accounts and review each provider\u2019s terms beforehand. Using a subscription login through the third-party tool may be restricted, so review the AI service provider\u2019s usage policy before linking.<\/li>\n\n\n\n<li><strong>API key:<\/strong> You paste a key from the provider\u2019s console, and you are billed by tokens from that provider. It is the transparent option, because costs shoot up on the shopping cart.<\/li>\n\n\n\n<li><strong>Subscription login:<\/strong> Some AI service providers allow premium sign-ups. They use the quota and limits of the plan instead of billing per token. See if the provider allows such usage in third-party tools. Be aware of usage caps that reset on the schedule.<\/li>\n\n\n\n<li><strong>Free tier:<\/strong> Free pricing models often have strict quotas, rate limits, and sometimes different data-handling conditions. Use them as a backup, not as a foundation. It is important to review the privacy policy before you start sending code through it.<\/li>\n<\/ul>\n\n\n\n<h3 id=\"WPT6WPTheme\" class=\"wp-block-heading\">Step 4: Create a Model Combo with Fallbacks<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Make the combo and order the models:<\/strong> Just keep the main model first, then add cheaper or faster models below it as backup. Example order: Claude Sonnet \u2192 Claude Haiku \u2192 a lightweight open-source model.<\/li>\n\n\n\n<li><strong>Set fallback rules:<\/strong> Define the switching period of a model. Be it a timeout, a rate limit, an API error, or low-confidence output. Add a retry limit (say 2 attempts) before falling into the next one.<\/li>\n\n\n\n<li><strong>Sample config &amp; trade-offs:<\/strong> Simple setup includes high-quality model, fallback 1: faster\/cheaper model, fallback 2: lowest-cost model. More expensive \/ slower. Fallbacks protect uptime and budget at the cost of worse answers.<\/li>\n<\/ul>\n\n\n\n<h3 id=\"WPT7WPTheme\" class=\"wp-block-heading\">Step 5: Copy Your Endpoint and API Key<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In the dashboard, go to the API or Keys section, and you will see the endpoint URL and a button to generate or copy the API key. Copy both and paste them into the app\u2019s settings or environment variables. Keep your API key secret like a password. Don&#8217;t paste it into source control, screenshots, or shared chats. Don&#8217;t hardcode it; store it in a .env file or secrets manager. If it ever leaks, revoke it right away and generate a new one.<\/p>\n\n\n\n<h3 id=\"WPT8WPTheme\" class=\"wp-block-heading\">Step 6: Point Claude Code at 9Router<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Instruct Claude Code to use 9Router instead of the default API by setting three environment variables:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ANTHROPIC_BASE_URL (your 9Router endpoint)\n\nANTHROPIC_AUTH_TOKEN (the API key you copied)\n\nANTHROPIC_MODEL (your combo name)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you\u2019d rather make it permanent, insert the same values under the env block in ~\/.claude\/settings.json. Then launch Claude Code and send a quick test prompt like \u201csay hello.\u201d A successful connection looks like a normal reply coming back with no auth or connection errors, and you must see the request appear in your 9Router dashboard logs, confirming it was routed through your combo.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Also Read:<\/strong> <a href=\"https:\/\/www.milesweb.co.uk\/blog\/domains\/is-an-icu-domain-good-for-seo-and-trust\/\">Is an .icu Domain Good For SEO and Trust<\/a>?<\/p>\n\n\n\n<div class=\"vlt-box \">\n<div class=\"box-title\" style=\"background:#D5EAFF; color:#000\">Conclusion<\/div>\n<div class=\"box-content\" >\n<p>After completing this setup, you now have 9Router working with Claude Code. It is simpler than it first looks. You built a model combo, added fallbacks so your work doesn\u2019t stop when one model hits a limit, and connected everything with just an endpoint and an API key.<\/p>\n<p>Flexibility is the best part, as this strong model is functional for complicated tasks. Besides, it is cost-effective to execute daily tasks without changing the code syntax. Fallbacks serve as a backup when the code fails to run.<\/p>\n<p>Before going live, discreet your API key, review your dashboard logs once, and change your combo with the requirement. These adjustments save both time and money.<\/p>\n<\/div><\/div>\n\n\n\n<div class=\"vlt-box \">\n<h2 class=\"box-title\" style=\"background:#D5EAFF; color:#000\" id=\"WPT9WPTheme\">FAQs<\/h2>\n<div class=\"box-content\">\n<h3 class=\"box-title\" style=\"background:#D5EAFF; color:#000\">1. What does 9Router do for Claude Code?<\/h3>\n<p>9Router runs locally and sits between Claude Code and the providers you connect. You point Claude Code at one local address, and 9Router routes requests to your providers, falling back to the next model in your list when one runs out of quota.<\/p>\n<h3 class=\"box-title\" style=\"background:#D5EAFF; color:#000\">2. How do I point Claude Code at 9Router?<\/h3>\n<p>Set three environment variables: ANTHROPIC_BASE_URL (your 9Router endpoint), ANTHROPIC_AUTH_TOKEN (the API key from the dashboard), and ANTHROPIC_MODEL (your combo name). To make it permanent, add the same values under the env block in ~\/.claude\/settings.json. Then launch Claude Code and send a quick test prompt.<\/p>\n<h3 class=\"box-title\" style=\"background:#D5EAFF; color:#000\">3. How do I know the connection is working?\n<\/h3>\n<p>You should get a normal reply with no authentication or connection errors, and the request should show up in your 9Router dashboard logs. That confirms it was routed through your combo.<\/p>\n<h3 class=\"box-title\" style=\"background:#D5EAFF; color:#000\">4. How do I keep my 9Router API key safe?<\/h3>\n<p>Treat it like a password. Keep it in a .env file or secrets manager, never in source control, screenshots, or shared chats, and don&#8217;t hardcode it. If it ever leaks, revoke it right away and generate a new one.\n<\/p>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Claude Code is a popular Vibe coding tool by Anthropic that reads codebases, edits files, runs commands, and automates development tasks across the terminal, IDE, desktop app, and browser. Developers hit the limit of Claude Code because of its prolonged usage. That\u2019s the problem 9Router solves. The 9Router open-source router runs on the local machine&#8230;. <a class=\"read-more\" href=\"https:\/\/www.milesweb.co.uk\/blog\/hosting\/vps\/how-to-set-up-9router-with-claude-code\/\">Read More<\/a><\/p>\n","protected":false},"author":964,"featured_media":39313,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[365],"tags":[],"class_list":["post-39311","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vps"],"_links":{"self":[{"href":"https:\/\/www.milesweb.co.uk\/blog\/wp-json\/wp\/v2\/posts\/39311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.milesweb.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.milesweb.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/blog\/wp-json\/wp\/v2\/users\/964"}],"replies":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=39311"}],"version-history":[{"count":1,"href":"https:\/\/www.milesweb.co.uk\/blog\/wp-json\/wp\/v2\/posts\/39311\/revisions"}],"predecessor-version":[{"id":39312,"href":"https:\/\/www.milesweb.co.uk\/blog\/wp-json\/wp\/v2\/posts\/39311\/revisions\/39312"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/blog\/wp-json\/wp\/v2\/media\/39313"}],"wp:attachment":[{"href":"https:\/\/www.milesweb.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=39311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=39311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=39311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}