Skip to content

v0.21.0 — Anthropic-native /v1/messages fixes

Choose a tag to compare

@doramirdor doramirdor released this 24 Jun 20:37
· 16 commits to main since this release

Fixes the Anthropic-native /v1/messages surface (what Claude Code and the official anthropic SDK talk to).

Added

  • /v1/messages/count_tokens endpoint (#72) — resolves the model through the same router as /v1/messages and forwards to Anthropic's real count_tokens, returning {"input_tokens": N} verbatim. Non-billable. Previously 404'd, so clients silently fell back to approximate local token estimation.

Fixed

  • /v1/messages traffic invisible to metrics & budget (#71) — record_request dropped type="messages" entries, so all Anthropic-native traffic was missing from Prometheus counters and the budget tracker. The recorder now accepts messages entries and the handler computes cost/status/latency/token counts on both paths (streaming usage recovered from SSE message_start/message_delta).
  • max_tokens not reconciled vs the routed model's output ceiling (#73) — on a max_tokens: N > M 400, /v1/messages now clamps to M and retries once (streaming + non-streaming), tagging non-streaming responses with X-NadirClaw-MaxTokens-Clamped: true.
  • nadirclaw test failed for Claude subscription tokens (#74) — it called litellm.completion() directly, sending sk-ant-oat* tokens as x-api-key instead of Authorization: Bearer + the oauth-2025-04-20 beta header the server uses. It now probes Anthropic models through the same OAuth path as the running server.

Full test suite green (831 passed).