You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
authored
v0.21.1: Opt-in Claude Code identity injection for OAuth tokens (#74) (#75)
Anthropic gates premium models (Sonnet/Opus) behind subscription/OAuth
tokens (sk-ant-oat*) unless the request leads with the official Claude
Code identity system block. The real client always sends it; raw API/SDK
callers omit it and get a bare rate_limit_error on those models while
Haiku works.
Add NADIRCLAW_CLAUDE_CODE_IDENTITY (default off). When enabled,
/v1/messages and the OAuth completion path prepend
"You are Claude Code, Anthropic's official CLI for Claude." as the first
system block — only for Bearer/OAuth tokens, only when not already
present, preserving any caller-supplied system prompt after it. Recorded
as claude_code_identity on the request log.
Also fix the OAuth completion path forwarding role:"system" messages
inside the messages array (Anthropic requires system as a top-level
field); system/developer turns are now collected into the top-level
system field.
Co-authored-by: Nadir <info@getnadir.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,14 @@ All notable changes to NadirClaw will be documented in this file.
4
4
5
5
## [Unreleased]
6
6
7
+
## [0.21.1] - 2026-06-25
8
+
9
+
### Added
10
+
-**Opt-in Claude Code identity injection for OAuth tokens** (`NADIRCLAW_CLAUDE_CODE_IDENTITY=1`) — Anthropic gates premium models (Sonnet/Opus) behind subscription/OAuth tokens (`sk-ant-oat*`) unless the request leads with the official Claude Code identity system block. The real Claude Code client always sends it; raw API/SDK callers omit it and get a bare `rate_limit_error` on those models while Haiku works (#74). When enabled, `/v1/messages` and the OAuth completion path prepend `"You are Claude Code, Anthropic's official CLI for Claude."` as the first `system` block — only for Bearer/OAuth tokens (no effect on `sk-ant-api*` keys), only when not already present, preserving any caller-supplied system prompt after it. The decision is recorded as `claude_code_identity` on the request log. Default off, since it changes the system prompt the model sees.
11
+
12
+
### Fixed
13
+
-**OAuth completion path sent `system` turns as chat messages** — the direct Anthropic OAuth call in `/v1/chat/completions` forwarded `role: "system"` messages inside the `messages` array, which Anthropic's `/v1/messages` API rejects (system must be a top-level field). System/developer turns are now collected into the top-level `system` field before forwarding (#74).
If you authenticate with a Claude **subscription** token (`sk-ant-oat*`, from `nadirclaw auth anthropic login` or `claude setup-token`) and find that **Haiku works but Sonnet/Opus return an immediate `rate_limit_error`**, Anthropic is likely gating premium models behind the official Claude Code identity. The real client always leads its requests with a fixed identity system block; raw API/SDK callers omit it. Opt in to have NadirClaw prepend it:
746
+
747
+
```bash
748
+
export NADIRCLAW_CLAUDE_CODE_IDENTITY=1
749
+
nadirclaw serve
750
+
```
751
+
752
+
When enabled, NadirClaw prepends `"You are Claude Code, Anthropic's official CLI for Claude."` as the first `system` block on OAuth (`sk-ant-oat*`) requests — only when not already present, preserving any system prompt you sent after it. It has **no effect on API-key (`sk-ant-api*`) credentials** and is **off by default**, since it changes the system prompt the model sees.
753
+
743
754
### What happens
744
755
745
756
Claude Code sends every request to Anthropic's API. With NadirClaw in front, each prompt is classified in ~10ms:
0 commit comments