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
/**
* chatCore noAuth-provider echoModel aliasing (PR #10571).
*
* Pure helper extracted from chatCore: for a bare (unprefixed) requested model
* routed to a no-auth catalog provider (e.g. `opencode`), returns the
* `<alias>/<model>` listing-valid form so that clients validating
* `response.model` against the provider's entry in `/v1/models` (which lists
* models under the provider's alias prefix) don't warn/reject. Returns null
* when the request does not match that shape, leaving any existing echoModel
* decision (e.g. the #1311 opt-in echo) untouched.
*/
import { REGISTRY } from "../../config/providerRegistry.ts";
import { isNoAuthProviderKey } from "@/shared/utils/noAuthProviders.ts";
export function resolveNoAuthEchoModel(
requestedModel: unknown,
provider: string | null | undefined
): string | null {
if (typeof requestedModel !== "string" || !requestedModel) return null;
if (requestedModel.includes("/")) return null;
if (!isNoAuthProviderKey(provider)) return null;
const alias = (provider && REGISTRY[provider]?.alias) || provider;
return `${alias}/${requestedModel}`;
}