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
/**
* Muse Code (Meta) public endpoints and CLI identity.
*
* Parity with CLIProxyAPI's Meta provider (`internal/auth/meta`,
* `internal/runtime/executor/meta_executor*`): RFC 8628 device grant against
* auth.meta.com, then mint of the subscription inference key at
* api.meta.ai/muse-code/key. The Muse CLI User-Agent is required by Meta.
*/
import { stripTrailingSlashes } from "../utils/urlSanitize.ts";
export const MUSE_CODE_USER_AGENT = "muse-code/1.0.2";
/** Inference UA used by CLIProxyAPI's MetaExecutor (auth still uses muse-code/1.0.2). */
export const MUSE_CODE_INFERENCE_USER_AGENT =
"muse-build/1.3.0 (interactive; macos-aarch64; build ac7280f2aca67769d1455a8847bb502b617d50f6)";
export const MUSE_CODE_AUTH_HOST = "https://auth.meta.com";
export const MUSE_CODE_DEVICE_CODE_URL = `${MUSE_CODE_AUTH_HOST}/oidc/device/authorization/`;
export const MUSE_CODE_TOKEN_URL = `${MUSE_CODE_AUTH_HOST}/oidc/device/token/`;
export const MUSE_CODE_MINT_URL = "https://api.meta.ai/muse-code/key";
export const MUSE_CODE_API_BASE_URL = "https://api.meta.ai/v1";
export const MUSE_CODE_RESPONSES_URL = `${MUSE_CODE_API_BASE_URL}/responses`;
/** Muse Image (OpenAI-compatible): JSON generations + multipart edits on the same key. */
export const MUSE_CODE_IMAGES_GENERATIONS_URL = `${MUSE_CODE_API_BASE_URL}/images/generations`;
export const MUSE_CODE_IMAGES_EDITS_URL = `${MUSE_CODE_API_BASE_URL}/images/edits`;
export const MUSE_CODE_DEVICE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
export const MUSE_CODE_DEFAULT_POLL_INTERVAL_SEC = 5;
export const MUSE_CODE_MAX_POLL_MS = 15 * 60 * 1000;
export function museCodeHeaders(extra?: Record<string, string>): Record<string, string> {
return {
Accept: "application/json",
"User-Agent": MUSE_CODE_USER_AGENT,
...extra,
};
}
export function isMuseDcaToken(token: string | null | undefined): boolean {
return typeof token === "string" && token.trim().startsWith("dca:");
}
export function normalizeMuseBaseUrl(raw: string | null | undefined): string {
const trimmed = typeof raw === "string" ? raw.trim() : "";
if (!trimmed) return MUSE_CODE_API_BASE_URL;
return stripTrailingSlashes(trimmed);
}