UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

221 lines (220 loc) • 6.37 kB
//#region extensions/xai/openclaw.plugin.json var modelIdNormalization = { "providers": { "xai": { "aliases": { "grok-4.3-latest": "grok-4.3", "grok-4.5-latest": "grok-4.5", "grok-4.7-latest": "grok-4.7", "grok-build-latest": "grok-4.5" } } } }; var modelCatalog = { "providers": { "xai": { "baseUrl": "https://api.x.ai/v1", "api": "openai-responses", "family": "xai", "models": [ { "id": "grok-4.7", "name": "Grok 4.7", "reasoning": true, "input": ["text", "image"], "cost": { "input": 2, "output": 6, "cacheRead": .5, "cacheWrite": 0 }, "contextWindow": 5e5, "maxTokens": 64e3 }, { "id": "grok-4.6", "name": "Grok 4.6", "reasoning": true, "input": ["text", "image"], "cost": { "input": 2, "output": 6, "cacheRead": .5, "cacheWrite": 0 }, "contextWindow": 5e5, "maxTokens": 64e3 }, { "id": "grok-4.5", "name": "Grok 4.5", "reasoning": true, "input": ["text", "image"], "cost": { "input": 2, "output": 6, "cacheRead": .3, "cacheWrite": 0 }, "contextWindow": 5e5, "maxTokens": 64e3 }, { "id": "grok-build-0.1", "name": "Grok Build 0.1", "reasoning": true, "input": ["text", "image"], "cost": { "input": 1, "output": 2, "cacheRead": .2, "cacheWrite": 0 }, "contextWindow": 256e3, "maxTokens": 64e3 }, { "id": "grok-4.3", "name": "Grok 4.3", "reasoning": true, "input": ["text", "image"], "cost": { "input": 1.25, "output": 2.5, "cacheRead": .2, "cacheWrite": 0 }, "contextWindow": 1e6, "maxTokens": 64e3 }, { "id": "grok-4.20-0309-reasoning", "name": "Grok 4.20 0309 (Reasoning)", "reasoning": true, "input": ["text", "image"], "cost": { "input": 1.25, "output": 2.5, "cacheRead": .2, "cacheWrite": 0 }, "contextWindow": 1e6, "maxTokens": 3e4 }, { "id": "grok-4.20-0309-non-reasoning", "name": "Grok 4.20 0309 (Non-Reasoning)", "reasoning": false, "input": ["text", "image"], "cost": { "input": 1.25, "output": 2.5, "cacheRead": .2, "cacheWrite": 0 }, "contextWindow": 1e6, "maxTokens": 3e4 } ] } }, "aliases": { "x-ai": { "provider": "xai" } }, "discovery": { "xai": "refreshable" }, "suppressions": [ { "provider": "xai", "model": "auto", "reason": "The xAI auto selector has retired; use a concrete model.", "retirement": { "replacedBy": "grok-4.7" }, "when": { "baseUrlHosts": ["cli-chat-proxy.grok.com", "api.x.ai"] } }, { "provider": "xai", "model": "grok-4.20-multi-agent-0309", "reason": "OpenClaw does not currently support xAI multi-agent models; choose another xAI model. See https://docs.openclaw.ai/providers/xai." }, { "provider": "xai", "model": "grok-4.20-multi-agent", "reason": "OpenClaw does not currently support xAI multi-agent models; choose another xAI model. See https://docs.openclaw.ai/providers/xai." }, { "provider": "xai", "model": "grok-4.20-multi-agent-latest", "reason": "OpenClaw does not currently support xAI multi-agent models; choose another xAI model. See https://docs.openclaw.ai/providers/xai." }, { "provider": "xai", "model": "grok-4.20-multi-agent-beta-latest", "reason": "OpenClaw does not currently support xAI multi-agent models; choose another xAI model. See https://docs.openclaw.ai/providers/xai." }, { "provider": "xai", "model": "grok-4.20-multi-agent-experimental-beta-0304", "reason": "OpenClaw does not currently support xAI multi-agent models; choose another xAI model. See https://docs.openclaw.ai/providers/xai." }, { "provider": "xai", "model": "grok-4.20-multi-agent-experimental-beta-latest", "reason": "OpenClaw does not currently support xAI multi-agent models; choose another xAI model. See https://docs.openclaw.ai/providers/xai." }, { "provider": "xai", "model": "grok-4.20-multi-agent-beta-0309", "reason": "OpenClaw does not currently support xAI multi-agent models; choose another xAI model. See https://docs.openclaw.ai/providers/xai." } ] }; //#endregion //#region extensions/xai/model-id.ts const XAI_GROK_RELEASE_ID = /^grok-(\d+)(?:\.(\d+))?(?:-(?:latest|\d{4}))?$/u; /** * xAI documents reasoning effort from Grok 4.5 and xhigh "on grok-4.6 and later", so * compare release numbers: new Grok releases work before the manifest lists them. */ function isXaiGrokReleaseAtLeast(e, t) { const n = XAI_GROK_RELEASE_ID.exec(normalizeXaiModelId(e.trim().toLowerCase())); if (!n) return false; const r = Number(n[1]); const i = Number(n[2] ?? 0); if (r === 4 && i === 20) return false; return r > t[0] || r === t[0] && i >= t[1]; } function isXaiXhighModelId(e) { return isXaiGrokReleaseAtLeast(e, [4, 6]); } function isXaiFrontierModelId(e) { return isXaiGrokReleaseAtLeast(e, [4, 5]); } const XAI_REASONING_EFFORTS = [ "none", "minimal", "low", "medium", "high", "xhigh" ]; /** Keep the efforts xAI defines, in ascending strength. */ function normalizeXaiReasoningEfforts(e) { return XAI_REASONING_EFFORTS.filter((t) => e.includes(t)); } function isXaiGrok43ModelId(e) { return e === "grok-latest" || e === "grok-4.3" || e.startsWith("grok-4.3-"); } /** Efforts the model-ID rules grant a reasoning model, for rows without a listing. */ function resolveXaiIdReasoningEfforts(e) { if (!isXaiGrok43ModelId(e) && !isXaiFrontierModelId(e)) return []; return [ ...isXaiGrok43ModelId(e) ? ["none"] : [], "low", "medium", "high", ...isXaiXhighModelId(e) ? ["xhigh"] : [] ]; } const XAI_MODEL_ALIASES = new Map([ ...Object.entries(modelIdNormalization.providers.xai.aliases), ["grok-code-fast-1", "grok-build-0.1"], ["grok-code-fast", "grok-build-0.1"], ["grok-code-fast-1-0825", "grok-build-0.1"], ["grok-4-fast-reasoning", "grok-4-fast"], ["grok-4-1-fast-reasoning", "grok-4-1-fast"] ]); function normalizeXaiModelId(e) { return XAI_MODEL_ALIASES.get(e) ?? e; } //#endregion export { isXaiXhighModelId as a, resolveXaiIdReasoningEfforts as c, isXaiGrokReleaseAtLeast as i, modelCatalog as l, isXaiFrontierModelId as n, normalizeXaiModelId as o, isXaiGrok43ModelId as r, normalizeXaiReasoningEfforts as s, XAI_REASONING_EFFORTS as t };