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 { buildErrorBody, createErrorResult } from "../../utils/error.ts";
/**
* Internal label for a request that failed while being translated (#14815). Translation
* runs locally on the client's own body before any upstream call, so the failure says
* nothing about the account: every account would fail the same body the same way.
* `shouldSkipConnDisable()` reads this label so the account is not cooled down. It is
* set on the result object only — the client-facing body keeps its existing code.
*/
export const TRANSLATION_FAILURE_CODE = "request_translation_failed";
export function createTranslationFailureResult(
status: number,
message: string,
errorType: string | null
) {
if (!errorType) {
return { ...createErrorResult(status, message), errorCode: TRANSLATION_FAILURE_CODE };
}
const body = buildErrorBody(status, message, undefined, { type: errorType, code: errorType });
return {
success: false as const,
status,
error: body.error.message,
errorType,
errorCode: TRANSLATION_FAILURE_CODE,
response: new Response(JSON.stringify(body), {
status,
headers: { "Content-Type": "application/json" },
}),
};
}