CanalAPI
User GuideDeveloper GuideExamples

Claude CLI

Use CanalAPI with the Claude CLI (Claude Code).

1. Introduction

This guide explains how to install and use Claude Code on Windows.

2. Setup

2.1 Install the Node.js environment

  1. Open your browser and visit the Node.js website: https://nodejs.org, then click "Get Node.js" to open the download page. alt text
  2. On the download page, make sure the Node.js version is LTS, then click "Windows Installer (.msi)" to download the installer. alt text
  3. After the installer finishes downloading, double-click the .msi file, keep the default settings, and click "Next" until installation completes. alt text
  4. After installation, right-click the Start menu and select "Terminal (Admin)" to open a terminal. alt text
  5. In the terminal, run the following commands. If the corresponding version numbers appear, Node.js is installed successfully.
  • node --version
  • npm --version

alt text

2.2 Install Git Bash

  1. Open your browser and visit the Git website: https://git-scm.com/downloads/win, choose "Windows", then click "Click here to download" to download the Git installer. alt text
  2. Once downloaded, run the .exe installer. During installation, configure the following:
  • When the "Select Components" screen appears, check "Add a Git Bash Profile to Windows Terminal";
  • Keep the defaults for all other steps and click "Next" until installation completes.

alt text 3) After installation, open a terminal and run the following command. If the version number appears, Git Bash is installed successfully.

  • git --version

alt text

2.3 Install Claude Code

  1. Open a terminal and run the following command to install Claude Code.
  • npm install -g @anthropic-ai/claude-code

alt text 2) After installation, run the following command to add ~/.local/bin to your PATH:

  • [Environment]::SetEnvironmentVariable('Path', ([Environment]::GetEnvironmentVariable('Path','User') + ";$HOME.local\bin"), 'User')

alt text 3) Once done, run the command below. If a version number appears, Claude Code is installed successfully.

  • claude --version

alt text

2.4 Connect to CanalAPI

To connect Claude Code to CanalAPI, run the following commands in the terminal to set the environment variables:

[Environment]::SetEnvironmentVariable('ANTHROPIC_BASE_URL', 'https://api.canalapi.com', 'User')
[Environment]::SetEnvironmentVariable('ANTHROPIC_AUTH_TOKEN', 'YOUR_CANALAPI_KEY', 'User')

Replace YOUR_CANALAPI_KEY with the API key you created on the CanalAPI website.

alt text

2.5 Start using

  1. Open a new PowerShell window and run the following command to launch Claude Code directly:
  • claude

alt text

  1. Once Claude starts, you're ready to go.

On this page