# How to integrate RouterLink in Claude Code

{% hint style="info" %}
This documentation is provided for informational purposes only and demonstrates how to configure and use our API with third-party AI chat interfaces. Any third-party software, websites, or services mentioned are not operated, controlled, or endorsed by us.
{% endhint %}

## Overview

This tutorial guides you through integrating **RouterLink**—WORLD3's decentralized AI model routing infrastructure—with **Claude Code**, an intelligent coding tool.

### Purpose

RouterLink provides a unified API endpoint that routes requests to multiple AI model providers through a decentralized network. By integrating RouterLink with Claude Code, you gain access to a diverse range of large language models (LLMs) without managing multiple API keys or provider-specific configurations.

### What You Will Learn

By completing this tutorial, you will:

* **Configure Claude Code** to connect with RouterLink's API endpoint
* **Authenticate** using your RouterLink API credentials with custom headers
* **Add and manage AI models** available through the RouterLink network
* **Execute inference requests** through Claude Code's conversational interface

### Prerequisites

Before proceeding, ensure you have:

* A RouterLink API key (obtain one from the [Quick Start Guide](https://docs.world3.ai/world3/how-to-guides/routerlink/quick-start-guide))
* A web browser with internet access
* Basic familiarity with API configuration concepts

## Introduction to Claude Code

<figure><img src="/files/7THjVlc02WonbPCFhgbS" alt=""><figcaption></figcaption></figure>

**Claude Code** is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.**Claude Code** Key Features:

* **Autonomous Action**: Reads/writes files, runs terminal commands, and fixes bugs directly.
* **Full Context**: Automatically understands the entire codebase without manual copy-pasting.
* **Safety & Control**: Supports one-click rollbacks and requires manual approval for key actions.
* **Tool Integration**: Supports custom complex workflows via SKILL.md.

### Step 1: Install Claude Code

If you **only use** it within VS Code, you can just install [Claude Code extension](https://marketplace.visualstudio.com/items?itemName=anthropic.claude-code) —there’s no need to install the Claude Code CLI tool separately. The VS Code extension provides inline diffs, @-mentions, plan review, and conversation history directly in your editor.

Open the settings of Claude Code for VS Code.

<figure><img src="/files/2fI7EXzp1qf1r6VWkI6N" alt=""><figcaption></figcaption></figure>

Click **“Edit in settings.json”** under **Environment Variables**.

<figure><img src="/files/EdfAdXyYXHKpBDrduLjw" alt=""><figcaption></figcaption></figure>

Add the following content. Make sure to replace ${API\_KEY} with the API Key obtained from [Quick Start Guide](https://docs.world3.ai/world3/how-to-guides/routerlink/quick-start-guide)

```json
{
    "claudeCode.disableLoginPrompt": true,
    "claudeCode.preferredLocation": "panel",
    "claudeCode.environmentVariables": [
    {"name":"ANTHROPIC_AUTH_TOKEN","value":"${API_KEY}"},
    {"name":"ANTHROPIC_BASE_URL","value":"https://router-link.world3.ai/api"},
    {"name":"ANTHROPIC_DEFAULT_HAIKU_MODEL","value":"anthropic/claude-haiku-4-5"},
    {"name":"ANTHROPIC_DEFAULT_SONNET_MODEL","value":"anthropic/claude-sonnet-4-6"},
    {"name":"ANTHROPIC_DEFAULT_OPUS_MODEL","value":"anthropic/claude-opus-4-7"}
    ]
}
```

Click the Claude icon on the left, then select “New session” to start using Claude Code for VS Code.

<figure><img src="/files/c8VW7dkx8T3iVKewgPnW" alt=""><figcaption></figcaption></figure>

If you need to install the Claude Code CLI tool separately, Anthropic officially recommends the [Native Install method](https://code.claude.com/docs/en/overview#native-install-recommended), which requires your terminal to be able to access the Claude Code official installation source.

* macOS, Linux, WSL:

```bash
curl -fsSL https://claude.ai/install.sh | bash
```

* Windows PowerShell:

```bash
irm https://claude.ai/install.ps1 | iex
```

* Windows CMD:

```bash
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
```

Windows requires [Git for Windows](https://git-scm.com/downloads/win). Install it first if you don’t have it.

> Native installations automatically update in the background to keep you on the latest version.

If you cannot install the Claude Code CLI tool using the Native Install method, please install [the newest LTS version of Node.js](https://nodejs.org/en/download/), and then use npm or pnpm to install it globally.

```bash
# Install using pnpm (recommended)
pnpm install -g @anthropic-ai/claude-code

# Or install using npm
npm install -g @anthropic-ai/claude-code
```

Run the following command to check the installation result.

```bash
claude --version
```

### Step 2: Configure Claude Code

Claude Code officially supports managing persistent configuration through the settings system. For daily use, it is recommended to prioritize writing configurations into `settings.json`. Shell or system environment variables are better suited for temporary switching, CI scenarios, or as a fallback when encountering known issues in the current version.

Edit or create the settings.json file\
On macOS & Linux: \~/.claude/settings.json\
On Windows: C:\Users\<USERNAME>.claude\settings.json\
Make sure to replace ${API\_KEY} with the API Key obtained from [Quick Start Guide](https://docs.world3.ai/world3/how-to-guides/routerlink/quick-start-guide)

```json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "${API_KEY}",
    "ANTHROPIC_BASE_URL": "https://router-link.world3.ai/api",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "anthropic/claude-haiku-4-5",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "anthropic/claude-sonnet-4-6",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "anthropic/claude-opus-4-7"
  }
}
```

### Step 3: Start using Claude Code

Navigate to your code working directory and run the `claude` command in the terminal to start using Claude Code (If you are using the VS Code extension, please open it directly in VS Code.).

```bash
claude
```

When using Claude Code for the first time, you may be forced to log in to an Anthropic account. Please follow the steps below to skip this process:

<figure><img src="/files/VG2FnFvsIVM5Pc702HDM" alt=""><figcaption></figcaption></figure>

1. Open or create the `.claude.json` file in the user’s home directory. The specific paths are as follows: macOS / Linux: `~/.claude.json` Windows: `C:\Users\<USERNAME>\.claude.json`

2. Set the value of the `hasCompletedOnboarding` field to `true`.

   ```bash
   {
     "hasCompletedOnboarding": true
   }
   ```

3. Save the file, then run `claude` again in the terminal.

   After launching, choose to trust Claude Code to access the files in the folder, as shown below:

<figure><img src="/files/dtBnt7nruCcqmiZTMUE6" alt=""><figcaption></figcaption></figure>

Done! You can now use Claude Code normally.

## Troubleshooting

### **No response after entering a prompt / “You don’t have enough $WAI” error**

Make sure your API input is correct. Due to the high token consumption of Anthropic models, the daily free quota may not support this model. Please top up your balance.

### **How can I switch to another model?**

1\. Go to <https://world3.ai/routerlink> and select the Anthropic Channel on the right. Click on the model, set the API Format to “Anthropic,” and locate the `model` field in the code block.

Copy the model name from the `model` field and replace it in the `settings.json` file above.

<figure><img src="/files/eEcejUitw0R2uVoT4CHC" alt=""><figcaption></figcaption></figure>

Open a new terminal window. Run `claude` to start Claude Code. Then type `/status` to verify the model status.

<figure><img src="/files/osWqRkGpMKdGCoAf2UVA" alt=""><figcaption></figcaption></figure>

### **Manual configuration changes not taking effect**

If you have manually edited the `~/.claude/settings.json` file but the changes are not applied, please try the following:

1. Close all Claude Code windows. Open a new terminal window and run `claude` again to restart.
2. If the issue persists, try deleting the `~/.claude/settings.json` file and reconfigure the environment variables. Claude Code will automatically generate a new configuration file.
3. Make sure the JSON format of the configuration file is correct. Check for issues such as incorrect variable names, missing commas, or extra commas. You can use an online JSON validator to verify the file.

### **How can I upgrade Claude Code?**

Enter the following command in the terminal:

```bash
claude update
```

### Need more help?

Please check the official documentation. <https://support.claude.com/en/articles/12386420-claude-code-faq>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.world3.ai/world3/how-to-guides/routerlink/tutorials/how-to-integrate-routerlink-in-claude-code.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
