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 { GLM_DEFAULT_BASE_URLS } from "../../config/glmProvider.ts";
type ZaiCredentialsLike = {
providerSpecificData?: { targetFormat?: unknown } | null;
} | null;
/**
* #7364: "zai"/"glm-coding-apikey" default to the Anthropic Messages wire format
* (registry format:"claude"), but a per-model `targetFormat` override (custom-model
* dropdown, #2905) can resolve to "openai" — e.g. for a vision model like glm-4.6v
* that the operator wants routed through the OpenAI-compatible endpoint instead.
* chatCore/executionCredentials.ts threads that resolved override onto
* `providerSpecificData.targetFormat`; DefaultExecutor.buildUrl() has no other way
* to see it, so without this check every zai/glm-coding-apikey request silently hit
* the Claude-format endpoint regardless of the override.
*/
export function resolveZaiUrl(
credentials: ZaiCredentialsLike,
resolveBaseUrl: (fallback?: string) => string
): string {
if (credentials?.providerSpecificData?.targetFormat === "openai") {
return resolveBaseUrl(GLM_DEFAULT_BASE_URLS.international);
}
return `${resolveBaseUrl()}?beta=true`;
}