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

VariableValue
ANTHROPIC_BASE_URLhttps://api.onysoft.com (do not append /v1)
ANTHROPIC_AUTH_TOKENYour Onysoft API key (sk-ony-...)
ANTHROPIC_MODELFor example anthropic/claude-sonnet-5. Spellings such as claude-sonnet-5-5 or anthropic/claude-sonnet-5.5 are accepted too.

Optional variables:

security

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)

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:

PowerShell
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)

zsh / 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

Notes

To add Onysoft's catalog, pricing and balance tools to Claude Code, see the MCP Server section.

Want help finding the right model?