Claude Code

Claude Code

Claude Code speaks the Anthropic Messages API, which Hisoka serves at /api/v1/messages.
Setup is two environment variables and no plugin.

Configure

export ANTHROPIC_BASE_URL="https://hisoka.ai/api/v1"
export ANTHROPIC_AUTH_TOKEN="sk-your-key-here"

Then start it as usual:

claude

To make it permanent, put both lines in your shell profile (~/.zshrc, ~/.bashrc).

Pick a model

claude --model glm-5.3-flash

Any id from GET /models works. For a coding session, prefer a model
whose capabilities.tools is true; that is what an agent needs to read files and run
commands.

Do not set the base URL one level deeper

https://hisoka.ai/api/v1 is correct. The Anthropic SDK appends /v1/messages itself, so
a base URL ending in /v1/messages produces /api/v1/messages/v1/messages and every
request 404s.

What Claude Code will call

It calls POST /messages for each turn, and POST /messages/count_tokens before a turn
to budget its context window. Both are served, and count_tokens is answered locally
rather than proxied, so it does not double your upstream request count.

Verify it is really working

A successful turn is not proof that the gateway is in the path; it could have fallen back
to a direct Anthropic account. Check the bill:

curl -s "https://hisoka.ai/api/v1/transactions?limit=1" \
  -H "Authorization: Bearer $HISOKA_API_KEY" | jq '.data[0]'

A usage row naming your model, timestamped in the last minute, is the proof.

Tool calls behave normally

tool_choice left unspecified stays unspecified. The gateway does not rewrite it to
required, which would forbid the model from answering without a tool call and leave an
agent looping forever on valid 200 responses.

If a turn comes back empty

A reasoning model given a small max_tokens can spend the whole budget thinking and
return empty content with finish_reason: "stop". That is a finished turn, not an
outage. Raise the cap, or the gateway raises it for you and reports cap_raised_from in
the response so a raised cap is visible instead of silent.

Common problems

Symptom Cause
Every request 404s base URL includes /v1 twice
401 invalid_api_key key missing, revoked, or spaces inside the header value
402 insufficient_quota wallet empty, or under the free-model floor
Agent repeats the same file read forever a client-side tool_choice: required, not a gateway setting
Answers are short and cut off finish_reason was length: raise max_tokens