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
import { getModelSpec } from "../../src/shared/constants/modelSpecs.ts";
const CLOUD_CODE_REASONING_UNSUPPORTED_PATTERNS = [/^claude-/i, /^gpt-oss-/i, /^tab_/i];
function isRecord(value: unknown): value is Record<string, unknown> {
return !!value && typeof value === "object" && !Array.isArray(value);
}
const PREFIX_TRIM_RE = /^(?:models\/|antigravity\/)+/i;
function normalizeCloudCodeModel(model: string): string {
return String(model || "").trim().replace(PREFIX_TRIM_RE, "");
}
function stripGeminiThinkingConfig(value: unknown): unknown {
if (!isRecord(value)) return value;
if (!("thinkingConfig" in value) && !("thinking_config" in value)) return value;
const next = { ...value };
delete next.thinkingConfig;
delete next.thinking_config;
return next;
}
/**
* @deprecated This function will be removed in v4.0, reasoning configuration processing has migrated to translateRequest
*/
export function shouldStripCloudCodeThinking(provider: string, model: string): boolean {
if (!provider || !model) return false;
const normalizedModel = normalizeCloudCodeModel(model);
if (CLOUD_CODE_REASONING_UNSUPPORTED_PATTERNS.some((pattern) => pattern.test(normalizedModel))) {
return true;
}
const spec = getModelSpec(normalizedModel);
if (typeof spec?.supportsThinking === "boolean") {
return !spec.supportsThinking;
}
return false;
}
/**
* @deprecated This function will be removed in v4.0, reasoning configuration processing has migrated to translateRequest
*/
export function stripCloudCodeThinkingConfig(
body: Record<string, unknown>
): Record<string, unknown> {
const next = { ...body };
delete next.reasoning_effort;
delete next.reasoning;
delete next.thinking;
if ("generationConfig" in next) {
next.generationConfig = stripGeminiThinkingConfig(next.generationConfig);
}
if (isRecord(next.request)) {
const request = { ...next.request };
delete request.reasoning_effort;
delete request.reasoning;
delete request.thinking;
if ("generationConfig" in request) {
request.generationConfig = stripGeminiThinkingConfig(request.generationConfig);
}
next.request = request;
}
return next;
}