Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions packages/cli/src/proxy-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,29 @@ export async function createProxyServer(
const body = await c.req.json();
const handler = await getHandlerForRequest(body.model);

// Strip Claude Code billing header from system prompt for non-Anthropic
// providers. Claude Code injects `x-anthropic-billing-header: cc_version=...; cch=XXXXX;`
// into the prompt body — the `cch=` token changes every request, breaking
// prefix caching on self-hosted inference (vLLM, Ollama). Only Anthropic
// needs this header.
if (!(handler instanceof NativeHandler)) {
if (typeof body.system === "string") {
body.system = body.system.replace(
/x-anthropic-billing-header: cc_version=[^\n]*\n?/g,
""
);
} else if (Array.isArray(body.system)) {
for (const block of body.system) {
if (block.type === "text" && typeof block.text === "string") {
block.text = block.text.replace(
/x-anthropic-billing-header: cc_version=[^\n]*\n?/g,
""
);
}
}
}
}

// Route
return handler.handle(c, body);
} catch (e) {
Expand Down