fix: add missing API request headers for parity with Claude Code#109
Merged
griffinmartin merged 2 commits intomainfrom Mar 31, 2026
Merged
fix: add missing API request headers for parity with Claude Code#109griffinmartin merged 2 commits intomainfrom
griffinmartin merged 2 commits intomainfrom
Conversation
Add headers that Claude Code sends on every API request: - anthropic-version: 2023-06-01 - x-client-request-id: unique UUID per request - X-Claude-Code-Session-Id: stable UUID per process lifetime Also fixes user-agent format from 'claude-cli/<v> (external, cli)' to 'claude-code/<v>' and bumps ccVersion to 2.1.88. Adds validate-oauth and validate-oauth-dry Makefile targets.
Owner
Author
|
@minzique thoughts? |
Contributor
I will take a look later today and let you know https://minzique.github.io/claude-code-re/ should have all the request formats auto documented going forward but i need to double check it, the pipeline's only been running for a couple weeks |
Owner
Author
@minzique Thanks for the resource. An hour after I opened this and went through the effort to decompile the bun binary the cc source code leaked 🤣 |
Claude Code's API User-Agent is 'claude-cli/<v> (external, cli)', not 'claude-code/<v>'. The latter is used for non-SDK HTTP requests only (transports, telemetry). Revert to the correct format.
griffinmartin
pushed a commit
that referenced
this pull request
Apr 3, 2026
## Summary Fixes #119 — API 400 for `claude-haiku-4-5-20251001`. - Adds a `haiku` model override in `model-config.ts` to exclude the `interleaved-thinking-2025-05-14` beta flag from haiku requests - Haiku 4.5 has limited extended thinking support (no adaptive thinking) and does not benefit from this beta — excluding it reduces the surface for API validation errors ## Root cause analysis The reported 400 error on plugin v1.3.0 was primarily caused by: 1. **Malformed billing header** — v1.3.0 used `cch=00000` (hardcoded) with the model ID embedded in the version string (`cc_version=2.1.80.claude-haiku-4-5-20251001`), which doesn't match the expected `cc_version=X.Y.Z.{3-char-hash}` format. Fixed in v1.4.3 (#116). 2. **Missing API headers** — `anthropic-version`, `x-client-request-id`, and `X-Claude-Code-Session-Id` were absent. Fixed in v1.4.2 (#109). This PR adds a defensive fix on top: excluding the `interleaved-thinking-2025-05-14` beta for haiku, since Claude Code CLI historically sent fewer betas to haiku (ref: `claude-code` v2.1.78 changelog) and the interleaved-thinking-with-tools behavior is not well-documented for haiku models. ## Changes - `src/model-config.ts` — Add `haiku` entry to `modelOverrides` excluding `interleaved-thinking-2025-05-14` - `src/betas.test.ts` — Update haiku test to verify excluded betas are rejected; add dedicated test for both `claude-haiku-4-5` and `claude-haiku-4-5-20251001` ## Test results ``` 191 tests, 0 failures lint: clean ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds missing HTTP headers to API requests to match what Claude Code sends, and bumps the version identifier to 2.1.88.
Changes
Headers added to
buildRequestHeaders(src/index.ts)anthropic-version: 2023-06-01— API version headerx-client-request-id— unique UUID per request for tracingX-Claude-Code-Session-Id— stable UUID per process lifetime (generated once viacrypto.randomUUID()at module load, never persisted to disk)User-Agent
claude-cli/<v> (external, cli)to match Claude Code's primary API User-Agent (src/utils/http.ts:getUserAgent()). Note:claude-code/<v>is used upstream only for non-SDK HTTP requests (transports, telemetry), not for API calls.Other fixes
ccVersionbumped from2.1.80to2.1.88validate-oauthandvalidate-oauth-dryMakefile targetsTests (
src/index.test.ts)x-client-request-idis unique per callX-Claude-Code-Session-Idis stable across callsAll 161 tests pass. Lint and build clean.