Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
Merge PR #1193
diegosouzapw488f9653e678
diff --cc open-sse/services/claudeCodeCompatible.tsindex 06099f69a3,3c5b8c3a4e..1430bd4065--- a/open-sse/services/claudeCodeCompatible.ts+++ b/open-sse/services/claudeCodeCompatible.ts@@@ -1,16 -1,7 +1,17 @@@import { createHash, randomUUID } from "node:crypto";+ import { getStainlessTimeoutSeconds } from "@/shared/utils/runtimeTimeouts";import { prepareClaudeRequest } from "../translator/helpers/claudeHelper.ts";+import { signRequestBody } from "./claudeCodeCCH.ts";+import { computeFingerprint, extractFirstUserMessageText } from "./claudeCodeFingerprint.ts";+import { remapToolNamesInRequest } from "./claudeCodeToolRemapper.ts";+import {+ enforceThinkingTemperature,+ disableThinkingIfToolChoiceForced,+ enforceCacheControlLimit,+ ensureCacheControlOnLastUserMessage,+} from "./claudeCodeConstraints.ts";+import { obfuscateInBody } from "./claudeCodeObfuscation.ts";export const CLAUDE_CODE_COMPATIBLE_PREFIX = "anthropic-compatible-cc-";export const CLAUDE_CODE_COMPATIBLE_DEFAULT_CHAT_PATH = "/v1/messages?beta=true";@@@ -18,21 -9,13 +19,24 @@@ export const CLAUDE_CODE_COMPATIBLE_DEFexport const CLAUDE_CODE_COMPATIBLE_DEFAULT_MAX_TOKENS = 8092;export const CLAUDE_CODE_COMPATIBLE_ANTHROPIC_VERSION = "2023-06-01";export const CLAUDE_CODE_COMPATIBLE_ANTHROPIC_BETA =- "claude-code-20250219,interleaved-thinking-2025-05-14,context-management-2025-06-27,prompt-caching-scope-2026-01-05,effort-2025-11-24";-export const CLAUDE_CODE_COMPATIBLE_USER_AGENT = "claude-cli/2.1.89 (external, sdk-cli)";-export const CLAUDE_CODE_COMPATIBLE_BILLING_HEADER =- "x-anthropic-billing-header: cc_version=2.1.89.728; cc_entrypoint=sdk-cli; cch=00000;";+ "claude-code-20250219,oauth-2025-04-20,interleaved-thinking-2025-05-14,context-management-2025-06-27,prompt-caching-scope-2026-01-05,effort-2025-11-24,fast-mode-2025-04-01,redact-thinking-2025-06-20,token-efficient-tools-2025-02-19";+export const CLAUDE_CODE_COMPATIBLE_VERSION = "2.1.87";+export const CLAUDE_CODE_COMPATIBLE_USER_AGENT = `claude-cli/${CLAUDE_CODE_COMPATIBLE_VERSION} (external, cli)`;+/**+ * Build the billing header dynamically with fingerprint and CCH placeholder.+ * The cch=00000 placeholder is later replaced by signRequestBody().+ */+export function buildBillingHeader(messages?: Array<{ role?: string; content?: unknown }>): string {+ const msgText = extractFirstUserMessageText(messages);+ const fp = computeFingerprint(msgText, CLAUDE_CODE_COMPATIBLE_VERSION);+ return `x-anthropic-billing-header: cc_version=${CLAUDE_CODE_COMPATIBLE_VERSION}.${fp}; cc_entrypoint=cli; cch=00000;`;+}++/** @deprecated Use buildBillingHeader() for dynamic fingerprint */+export const CLAUDE_CODE_COMPATIBLE_BILLING_HEADER = `x-anthropic-billing-header: cc_version=${CLAUDE_CODE_COMPATIBLE_VERSION}.000; cc_entrypoint=cli; cch=00000;`;+ export const CLAUDE_CODE_COMPATIBLE_STAINLESS_TIMEOUT_SECONDS = getStainlessTimeoutSeconds(+ process.env+ );type HeaderLike =| Headers@@@ -118,9 -101,9 +122,9 @@@ export function buildClaudeCodeCompatib"x-app": "cli","User-Agent": CLAUDE_CODE_COMPATIBLE_USER_AGENT,"X-Stainless-Retry-Count": "0",- "X-Stainless-Timeout": "600",+ "X-Stainless-Timeout": String(CLAUDE_CODE_COMPATIBLE_STAINLESS_TIMEOUT_SECONDS),"X-Stainless-Lang": "js",- "X-Stainless-Package-Version": "0.74.0",+ "X-Stainless-Package-Version": "0.80.0","X-Stainless-OS": "MacOS","X-Stainless-Arch": "arm64","X-Stainless-Runtime": "node",