CanalAPI

Set up Claude Code

Install, connect, verify, and troubleshoot Claude Code on Windows, macOS, and Linux. Includes the Claude CLI search alias.

1. Before you begin

Follow this guide from installation to a first reply and a matching usage log. “Claude CLI” here means the Claude Code command-line tool.

  • Create an API key and check that your account has available credit.
  • Choose a model suitable for Claude Code, with Anthropic Messages and tool-calling support. Copy its full ID.
  • Already installed? Jump to Connect to CanalAPI. This guide configures the CLI; other clients can have different settings.

2. Installation and environment

Install Claude Code

Use a normal user terminal and the command for your system, as documented in the official installation guide.

Windows PowerShell

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

macOS, Linux, WSL (Bash / Zsh)

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

Open a new terminal after installation:

claude --version
claude doctor

A version number confirms that the executable runs. doctor checks installation and settings; it does not prove an API request works. If the command is missing, check the installer's PATH instructions before installing another copy.

Is Node.js required?

The native installers above do not require Node.js. Install Node.js only for an npm installation or when your project needs it. Avoid mixing installation methods; check the active method with claude doctor before updating.

Git Bash on Windows

Git for Windows provides Git Bash. Native Windows and WSL have separate environments: configure variables and tools wherever you run Claude Code. If Git Bash cannot be found, check its installation path using the official installation guide.

3. Connect to CanalAPI

Replace both YOUR_CANALAPI_KEY and YOUR_CLAUDE_MODEL_ID. The base URL has no /v1 suffix; the client adds /v1/messages.

Key created dialog with Copy key, Copy API URL, and setup guides; key redacted

Copy the key from the creation dialog. This screenshot is redacted. Its general API URL includes /v1; for Claude Code, use https://api.canalapi.com without /v1 as ANTHROPIC_BASE_URL.

Windows PowerShell — current terminal and programs launched from it only

$env:ANTHROPIC_BASE_URL = "https://api.canalapi.com"
$env:ANTHROPIC_AUTH_TOKEN = "YOUR_CANALAPI_KEY"
$env:ANTHROPIC_MODEL = "YOUR_CLAUDE_MODEL_ID"
claude --model $env:ANTHROPIC_MODEL

macOS, Linux, WSL (Bash / Zsh)

export ANTHROPIC_BASE_URL="https://api.canalapi.com"
export ANTHROPIC_AUTH_TOKEN="YOUR_CANALAPI_KEY"
export ANTHROPIC_MODEL="YOUR_CLAUDE_MODEL_ID"
claude --model "$ANTHROPIC_MODEL"

CanalAPI accepts the Bearer authentication used here. Do not also supply an ANTHROPIC_API_KEY from another service. Record existing settings before changing them and check for conflicts. Changing tool approval permissions does not fix an API connection.

4. Verify the connection

  1. Start Claude Code from the same terminal and run /status. Confirm the base URL is https://api.canalapi.com, the model ID is correct, and the credential source is expected.
  2. Ask it to “Reply only OK, without tools.” This is a real model request, billed under your account's rules.
  3. Check the time, model, status, and usage in usage logs.
  4. In a trusted project, try “Describe the project structure without editing files” to check the selected model's tool-calling behavior.

Starting the app, printing a version, or opening the public model list verifies only installation or a public endpoint. None replaces a successful authenticated request.

5. Keep the configuration for future sessions

First verify the temporary configuration above. For persistent use, back up and merge these fields into your user-level ~/.claude/settings.json (%USERPROFILE%\.claude\settings.json on Windows), keeping other settings:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.canalapi.com",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_CANALAPI_KEY",
    "ANTHROPIC_MODEL": "YOUR_CLAUDE_MODEL_ID"
  }
}

This file contains a plaintext credential. Keep it in your private user directory; do not commit it or share its backup. Merge into an existing env object instead of adding a second one. Settings-file values can override shell variables. Restart Claude Code and recheck /status.

For a temporary trial, close the terminal to end that process's variable settings. To undo persistent configuration, restore the backup or remove the fields you added, then restart the tool.

6. Troubleshooting

SymptomNext step
Another service's login is still requestedCheck the address and credential source in /status, then compare shell and user settings
401 / invalid_api_keyCheck key state, expiry, completeness, and outbound IP restrictions
Unknown or unauthorized modelCopy the exact model ID from the console and check the key's model restrictions
Main conversation works but background tasks failAuxiliary tasks may select other models; check the official gateway model-mapping guidance
IDE configuration does not take effectEditors may not inherit shell variables; use the extension's documented settings and restart it

Continue with Connection troubleshooting. Sources: installation, gateway connection and status checks. Configuration reviewed on 2026-11-03; model availability and client interfaces depend on the active version.

On this page