Claude Code + osmAPI Setup Guide
Complete step-by-step guide to install Claude Code and configure it with osmAPI on macOS, Windows & Linux.
Claude Code is Anthropic's official CLI tool for interacting with Claude directly from your terminal. By connecting it to the osmAPI gateway, you get unified model access, cost tracking, and routing — all through a single API key.
Prerequisites
- Node.js v18+ (npm comes bundled with Node.js)
- An active osmAPI Access Token
1. Install Node.js & npm
Option A — Using the Installer:
- Go to https://nodejs.org
- Download the LTS macOS installer (
.pkg) - Double-click the downloaded file and follow the wizard
- Open Terminal and verify:
node -v
npm -vOption B — Using Homebrew (recommended):
brew install nodeOption A — Using the Installer:
- Go to https://nodejs.org
- Download the LTS Windows installer (
.msi) - Run the installer — check the box "Automatically install the necessary tools"
- Open PowerShell or Command Prompt and verify:
node -v
npm -vOption B — Using winget:
winget install OpenJS.NodeJS.LTSOption C — Using nvm-windows (recommended for managing multiple versions):
- Download nvm-windows from https://github.com/coreybutler/nvm-windows/releases
- Install it, then run:
nvm install lts
nvm use ltsOption A — Using NodeSource (recommended for Ubuntu/Debian):
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejsOption B — Using nvm (recommended for managing multiple versions):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
nvm install --lts
nvm use --ltsFedora/RHEL:
sudo dnf install nodejsVerify on any Linux distro:
node -v
npm -v2. Install Claude Code
Run this command on all platforms (macOS, Windows, Linux):
npm install -g @anthropic-ai/claude-codeOn macOS/Linux, if you get a permission error, either fix npm permissions (recommended) or prefix with sudo:
sudo npm install -g @anthropic-ai/claude-codeTo fix npm permissions permanently (macOS/Linux):
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc # or ~/.zshrc on macOS
source ~/.bashrcOn Windows, run PowerShell or CMD as Administrator if you encounter permission errors.
3. Configure osmAPI Environment Variables
You need to set three environment variables so Claude Code uses the osmAPI gateway with the glm-5 model.
Temporary (current session only):
export ANTHROPIC_BASE_URL=https://api.osmapi.com
export ANTHROPIC_AUTH_TOKEN=osm_your_api_key_here
export ANTHROPIC_MODEL=glm-5Permanent (persists across sessions):
echo 'export ANTHROPIC_BASE_URL=https://api.osmapi.com' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN=osm_your_api_key_here' >> ~/.zshrc
echo 'export ANTHROPIC_MODEL=glm-5' >> ~/.zshrc
source ~/.zshrcReplace osm_your_api_key_here with your actual osmAPI key from the
dashboard.
Option A — PowerShell (temporary, current session):
$env:ANTHROPIC_BASE_URL = "https://api.osmapi.com"
$env:ANTHROPIC_AUTH_TOKEN = "osm_your_api_key_here"
$env:ANTHROPIC_MODEL = "glm-5"Option B — Set permanently via System Environment Variables (GUI):
- Press
Win + R, typesysdm.cpl, press Enter - Go to Advanced tab → Environment Variables
- Under User variables, click New for each:
| Variable Name | Value |
|---|---|
ANTHROPIC_BASE_URL | https://api.osmapi.com |
ANTHROPIC_AUTH_TOKEN | osm_your_api_key_here |
ANTHROPIC_MODEL | glm-5 |
- Click OK on all dialogs
- Restart your terminal/PowerShell
Option C — Set permanently via PowerShell:
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://api.osmapi.com", "User")
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "osm_your_api_key_here", "User")
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_MODEL", "glm-5", "User")Then restart your terminal.
Option D — Command Prompt (permanent via setx):
setx ANTHROPIC_BASE_URL "https://api.osmapi.com"
setx ANTHROPIC_AUTH_TOKEN "osm_your_api_key_here"
setx ANTHROPIC_MODEL "glm-5"Then restart your terminal.
Temporary (current session only):
export ANTHROPIC_BASE_URL=https://api.osmapi.com
export ANTHROPIC_AUTH_TOKEN=osm_your_api_key_here
export ANTHROPIC_MODEL=glm-5Permanent (persists across sessions):
echo 'export ANTHROPIC_BASE_URL=https://api.osmapi.com' >> ~/.bashrc
echo 'export ANTHROPIC_AUTH_TOKEN=osm_your_api_key_here' >> ~/.bashrc
echo 'export ANTHROPIC_MODEL=glm-5' >> ~/.bashrc
source ~/.bashrcFor Fish shell users:
set -Ux ANTHROPIC_BASE_URL https://api.osmapi.com
set -Ux ANTHROPIC_AUTH_TOKEN osm_your_api_key_here
set -Ux ANTHROPIC_MODEL glm-54. Verify Installation
Run these commands to confirm everything is set up:
# Check Node.js and npm
node -v
npm -v
# Check Claude Code is installed
claude --versionecho $ANTHROPIC_BASE_URL
echo $ANTHROPIC_AUTH_TOKEN
echo $ANTHROPIC_MODELecho $env:ANTHROPIC_BASE_URL
echo $env:ANTHROPIC_AUTH_TOKEN
echo $env:ANTHROPIC_MODELExpected output:
ANTHROPIC_BASE_URL → https://api.osmapi.com
ANTHROPIC_AUTH_TOKEN → osm_your_api_key_here
ANTHROPIC_MODEL → glm-55. Using Claude Code
Starting Claude Code
Open your terminal and navigate to your project directory:
cd /path/to/your/project
claudeClaude Code will launch in interactive mode, connected to the osmAPI gateway using the glm-5 model.
Common Commands
| Command | Description |
|---|---|
claude | Start interactive mode in current directory |
claude "your prompt here" | Run a one-shot command |
claude -p "your prompt" | Print-only mode (no interactive session) |
claude config | View/edit configuration |
claude update | Update Claude Code to the latest version |
Example Usage
# Ask Claude to explain your codebase
claude "explain this codebase"
# Ask Claude to create a new file
claude "create a Python script that downloads a CSV from a URL and converts it to JSON"
# Fix a bug
claude "find and fix the bug in app.py that causes a 500 error on the /users endpoint"
# Run in a specific project
cd my-project
claudeClaude Code works best when run from your project root directory so it can see
your files. Use /help inside the interactive session for available commands.
Use Ctrl+C to cancel a running operation and Ctrl+D or type /exit to
quit.
6. Troubleshooting
"command not found: claude"
Your global npm bin directory is not in PATH.
export PATH="$(npm config get prefix)/bin:$PATH"Add the above line to your ~/.zshrc or ~/.bashrc to make it permanent.
Ensure the npm global directory is in your system PATH. Typically: C:\Users\<you>\AppData\Roaming\npm
"ANTHROPIC_AUTH_TOKEN not set" or Authentication Error
Double-check your environment variable is set correctly. Make sure there are no extra spaces or quotes around the value. Restart your terminal after setting permanent variables.
Permission errors during npm install
- macOS/Linux: Use the npm prefix fix described in Section 2, or use
sudo. - Windows: Run your terminal as Administrator.
Network / Proxy Issues
If you're behind a corporate proxy, set the proxy for npm:
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080Updating Claude Code
npm update -g @anthropic-ai/claude-codeQuick Reference
┌─────────────────────────────────────────────────────────┐
│ osmAPI + Claude Code │
├─────────────────────────────────────────────────────────┤
│ ANTHROPIC_BASE_URL = https://api.osmapi.com │
│ ANTHROPIC_AUTH_TOKEN = osm_your_api_key_here │
│ ANTHROPIC_MODEL = glm-5 │
├─────────────────────────────────────────────────────────┤
│ Install: npm install -g @anthropic-ai/claude-code │
│ Run: claude │
│ Update: npm update -g @anthropic-ai/claude-code │
└─────────────────────────────────────────────────────────┘How is this guide?