Coding Tools
Claude Code
Use TokenLab with Anthropic's Claude Code CLI
Let my agent set this up
Copy this task to an agent already running on your computer:
Read this guide and help me connect Claude Code to TokenLab:
https://tokenlab.sh/docs/en/integrations/claude-code
Check my installed version and active configuration first.
Preserve existing accounts, providers, permissions and other settings.
Back up local files and show proposed changes.
Have me enter any API key locally; never ask for, print or paste it in chat.
Check configuration loading first.
Explain any paid request test separately before running it.Overview
Claude Code can use a TokenLab API key and the TokenLab Messages API for Claude models.
Installation
Anthropic now recommends the native installer. The npm package still works, but Anthropic has deprecated that installation method.
curl -fsSL https://claude.ai/install.sh | bashIf you specifically need the npm package, use:
npm install -g @anthropic-ai/claude-code@2.1.263Do not use sudo npm install -g for Claude Code.
Configuration
Use the Quickstart terminal instructions for macOS, Linux, WSL, or Windows PowerShell to set TOKENLAB_API_KEY without putting the key in command history. Launch Claude Code from that terminal. For persistent use, use your local secret manager; do not append a plaintext key to your shell profile.
These variables apply only to this launch; your saved account, default model and permission settings stay in place. Launch normally without the variables to use your previous setup. Do not persist them in your shell profile.
This session path uses Claude Code 2.1.263 and Bearer authentication through ANTHROPIC_AUTH_TOKEN. Keep the Base URL without /v1. Existing settings-file env values, credential helpers, cloud-provider switches or managed policies can affect authentication; inspect them before launch. If they conflict, use the setup helper below instead of deleting account data or weakening policies. Check /status for the selected model and permissions.
ANTHROPIC_BASE_URL=https://api.tokenlab.sh ANTHROPIC_AUTH_TOKEN="${TOKENLAB_API_KEY:?Set TOKENLAB_API_KEY first}" ANTHROPIC_API_KEY= claude --model claude-sonnet-4-6Optional: the reversible Claude Code setup helper provides preview, apply and original-file restoration with Python 3.11+. TokenLab Skills plugin 0.1.2 includes these scripts; a standalone Skill installation can also be used after updating to a version that contains them. For an existing plugin or standalone Skill installation, follow the README update instructions and confirm the script is present. The manual configuration here remains usable without the helper.
Saving settings or listing models does not verify a key or a completed request. A prompt uses TokenLab balance. Check the reply and its matching request record before trying tools; auxiliary requests may also be billed.
Usage
After configuration, use Claude Code normally:
# Start an interactive session
ANTHROPIC_BASE_URL=https://api.tokenlab.sh ANTHROPIC_AUTH_TOKEN="${TOKENLAB_API_KEY:?Set TOKENLAB_API_KEY first}" ANTHROPIC_API_KEY= claude --model claude-sonnet-4-6
# Run a single command
ANTHROPIC_BASE_URL=https://api.tokenlab.sh ANTHROPIC_AUTH_TOKEN="${TOKENLAB_API_KEY:?Set TOKENLAB_API_KEY first}" ANTHROPIC_API_KEY= claude --model claude-sonnet-4-6 "Explain this code" < main.pyVerify the installation if needed:
claude --version
claude doctorChoose a model
Copy a current Claude model ID from the Models page, then pass it with --model:
ANTHROPIC_BASE_URL=https://api.tokenlab.sh ANTHROPIC_AUTH_TOKEN="${TOKENLAB_API_KEY:?Set TOKENLAB_API_KEY first}" ANTHROPIC_API_KEY= claude --model claude-sonnet-4-6 "Review this PR"Extended Thinking
For complex reasoning tasks, use models with extended thinking:
ANTHROPIC_BASE_URL=https://api.tokenlab.sh ANTHROPIC_AUTH_TOKEN="${TOKENLAB_API_KEY:?Set TOKENLAB_API_KEY first}" ANTHROPIC_API_KEY= claude --model claude-opus-4-6 "Design a microservices architecture for..."