Using TOKENOPEN API with Claude
Use Claude CLI with TOKENOPEN API to access platform models directly from your terminal
Claude CLI is Anthropic's official command-line tool for conversing with Claude models, running code, and more — directly from your terminal. By pointing it at the TOKENOPEN API endpoint, you can seamlessly use all models available on the platform.
Step 1: Install Claude CLI
Follow the official Anthropic documentation to install Claude CLI:
👉 https://docs.anthropic.com/en/docs/claude-code/getting-started
Claude CLI supports macOS, Linux, and Windows (WSL). Make sure Node.js 18+ is installed before proceeding.
Once installed, verify the installation by running:
claude --versionStep 2: Configure TOKENOPEN API
Claude CLI supports custom API endpoints and keys via a config file — no source code changes needed.
Get an API Key
Log in to the TOKENOPEN Console, navigate to the API Keys page, and create or copy a key.
Set the Claude Config File
Open the config file with a terminal editor:
vim ~/.claude/settings.jsonAdd the following content to the file:
{
"hasCompletedOnboarding": true,
"env": {
"ANTHROPIC_AUTH_TOKEN": "replace-with-your-api-key",
"ANTHROPIC_BASE_URL": "https://www.tokenopen.ai",
"API_TIMEOUT_MS": "300000",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1
}
}Press Esc to exit insert mode, then save and quit with:
:wq!Open the config file with a terminal editor:
vim ~/.claude/settings.jsonAdd the following content to the file:
{
"hasCompletedOnboarding": true,
"env": {
"ANTHROPIC_AUTH_TOKEN": "replace-with-your-api-key",
"ANTHROPIC_BASE_URL": "https://www.tokenopen.ai",
"API_TIMEOUT_MS": "300000",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1
}
}Press Esc to exit insert mode, then save and quit with:
:wq!Alternatively, open the file in TextEdit:
open -e ~/.claude/settings.jsonRun the following command in PowerShell to create and write the config file automatically:
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.claude" | Out-Null
@'
{
"hasCompletedOnboarding": true,
"env": {
"ANTHROPIC_AUTH_TOKEN": "replace-with-your-api-key",
"ANTHROPIC_BASE_URL": "https://www.tokenopen.ai",
"API_TIMEOUT_MS": "300000",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1
}
}
'@ | Set-Content -Path "$env:USERPROFILE\.claude\settings.json" -Encoding UTF8Or open it directly in Notepad:
notepad "$env:USERPROFILE\.claude\settings.json"Step 3: Use Claude CLI
With the configuration in place, all Claude CLI requests will be automatically routed through the TOKENOPEN API.
Interactive Chat
Start an interactive session in your terminal:
claude
Type your questions directly in the session. Enter /exit or press Ctrl+C to quit.
Switch Models
By default, Claude CLI uses the platform's default model. To switch to a specific model inside the interactive session:
/model claude-haiku-4-5-20251001
Supported Claude models on TOKENOPEN (examples):
| Model ID | Description |
|---|---|
claude-sonnet-4-6 | Claude Sonnet 4.6, latest balanced model |
claude-opus-4-5 | Claude Opus 4.5, flagship reasoning model |
claude-sonnet-4-5 | Claude Sonnet 4.5, balanced performance & speed |
claude-haiku-4-5-20251001 | Claude Haiku 4.5, ultra-fast lightweight model |
For the full model list and pricing, visit the Model Marketplace.
One-Shot Query
For a quick question without entering interactive mode, use the -p flag:
claude -p "Write a bubble sort algorithm in Python"Use Inside a Project
Launch Claude CLI from within your project directory — it will automatically read the file structure to assist with coding and debugging:
cd your-project
claudeClaude CLI can read and write local files, making it ideal for code review, refactoring, documentation generation, and more.
Last updated on