Using Claude Code
Run Claude Code with your Onysoft key and TRY balance
Claude Code works directly with your Onysoft key: three environment variables are enough. Requests go through the Anthropic Messages API endpoint and are billed from the same balance at the same price as Chat Completions.
Environment Variables
| Variable | Value |
|---|---|
ANTHROPIC_BASE_URL | https://api.onysoft.com (do not append /v1) |
ANTHROPIC_AUTH_TOKEN | Your Onysoft API key (sk-ony-...) |
ANTHROPIC_MODEL | For example anthropic/claude-sonnet-5. Spellings such as claude-sonnet-5-5 or anthropic/claude-sonnet-5.5 are accepted too. |
Optional variables:
ANTHROPIC_DEFAULT_HAIKU_MODEL=anthropic/claude-haiku-5.5: pins the model Claude Code uses for background tasks and/model haikuto a model your key is allowed to use.CLAUDE_CODE_MAX_OUTPUT_TOKENS=16000: Claude Code asks for 64,000–128,000 output tokens on every request. The balance pre-check is made against this ceiling, so with a low balance requests can be rejected with "Insufficient balance" (402). This variable lowers the ceiling. You are always charged for actual usage.CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1: in recent Claude Code versions the/modelpicker lists the Claude models your key can use.
Key safety: do not type the key on the command line, in the Read-Host prompt text, in scripts or in screenshots. With the methods below the key is entered hidden, is not shown on screen and is not written to the command history. If your key has been exposed anywhere, create a new key in the dashboard or contact us and we will disable the old one.
Windows (PowerShell)
$env:ANTHROPIC_BASE_URL = "https://api.onysoft.com"
$env:ANTHROPIC_MODEL = "anthropic/claude-sonnet-5"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "anthropic/claude-haiku-5.5"
# optional: output ceiling for the balance pre-check
# $env:CLAUDE_CODE_MAX_OUTPUT_TOKENS = "16000"
# Enter the key hidden: the prompt text stays fixed, you only paste the key (shown as *).
$secret = Read-Host "Paste your Onysoft API key" -AsSecureString
$env:ANTHROPIC_AUTH_TOKEN = [System.Net.NetworkCredential]::new("", $secret).Password
Remove-Variable secret
# Connection test
claude -p "Reply with CONNECTION_OK only."
# Normal use (in your project folder)
claude
Clear the variables when you close the session:
Remove-Item Env:ANTHROPIC_AUTH_TOKEN, Env:ANTHROPIC_BASE_URL, Env:ANTHROPIC_MODEL, Env:ANTHROPIC_DEFAULT_HAIKU_MODEL -ErrorAction SilentlyContinue
macOS / Linux (zsh or bash)
export ANTHROPIC_BASE_URL="https://api.onysoft.com"
export ANTHROPIC_MODEL="anthropic/claude-sonnet-5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="anthropic/claude-haiku-5.5"
# optional: output ceiling for the balance pre-check
# export CLAUDE_CODE_MAX_OUTPUT_TOKENS=16000
# Enter the key hidden (not shown, not saved to history) — zsh, the macOS default:
read -rs "ANTHROPIC_AUTH_TOKEN?Onysoft API key: "; echo
# if you use bash, instead: read -rsp "Onysoft API key: " ANTHROPIC_AUTH_TOKEN; echo
export ANTHROPIC_AUTH_TOKEN
claude -p "Reply with CONNECTION_OK only."
claude
To clear: unset ANTHROPIC_AUTH_TOKEN ANTHROPIC_BASE_URL ANTHROPIC_MODEL ANTHROPIC_DEFAULT_HAIKU_MODEL
Choosing Models
Claude Code's own aliases (/model sonnet, opus, haiku) and Anthropic ids (such as claude-sonnet-5-5, claude-haiku-4-5-20251001) are mapped to their counterpart in the Onysoft catalog. If you pick a model your key is not allowed to use, Claude Code says "There's an issue with the selected model"; pick one of the allowed models instead.
Non-Claude models can be used too (e.g. ANTHROPIC_MODEL=openai/gpt-5.5 or z-ai/glm-5.3:tr): the request is translated to the chat format, thinking blocks are not shown and server tools are removed from the request. On personal keys :tr models are available only to verified accounts, and their daily request limit is shared across all :tr models; since Claude Code sends many requests per session, that limit can be reached quickly.
Billing and Limits
You are charged for actual usage at the model's catalog price. Before every request a balance pre-check is made based on max_tokens; Claude Code asks for a high ceiling, so with a low balance use CLAUDE_CODE_MAX_OUTPUT_TOKENS. Claude Code may send several requests in one turn (title generation, token counting); as the per-minute limit is counted per API key, we recommend a separate key for Claude Code.
Common Errors
- 401: the key is missing or wrong.
- 402: insufficient balance. The message states the required and the available amount; the
CLAUDE_CODE_MAX_OUTPUT_TOKENSvariable helps in this case. - "There's an issue with the selected model":
ANTHROPIC_BASE_URLends with/v1, the model name is not in the catalog, or your key is not allowed to use this model. - 429: the per-minute request limit was exceeded. Claude Code waits and retries by itself.
Notes
ANTHROPIC_API_KEYalso works instead ofANTHROPIC_AUTH_TOKEN; Claude Code then sends the key in thex-api-keyheader. In interactive mode it asks you to confirm the key once and writes only its last 20 characters to its own settings file (~/.claude.json). WithANTHROPIC_AUTH_TOKENthere is no confirmation step.- Claude Code's web search (WebSearch) tool works on Claude models and its use is charged.
- Server-side code execution and remote MCP servers (
mcp_servers) are not supported on this endpoint. MCP servers you install on your own computer work normally. - Server-side fallback model (
fallbacks), server-side summarization (compact_*) and fast mode (speed) are removed from the request; the request runs normally. Details: Anthropic Messages API.
To add Onysoft's catalog, pricing and balance tools to Claude Code, see the MCP Server section.