openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
4 lines • 5.46 kB
JavaScript
//!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,"compat":{"thinkingLevels":[`low`,`medium`,`high`,`xhigh`],"defaultThinkingLevel":`high`}},{"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,"compat":{"thinkingLevels":[`low`,`medium`,`high`,`xhigh`],"defaultThinkingLevel":`high`}},{"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,"compat":{"thinkingLevels":[`low`,`medium`,`high`],"defaultThinkingLevel":`high`}},{"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,"compat":{"thinkingLevels":[`off`],"defaultThinkingLevel":`off`}},{"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,"compat":{"thinkingLevels":[`off`,`minimal`,`low`,`medium`,`high`],"defaultThinkingLevel":`low`}},{"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,"compat":{"thinkingLevels":[`off`],"defaultThinkingLevel":`off`}},{"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.`}]};
//!extensions/xai/model-id.ts
const XAI_GROK_RELEASE_ID=/^grok-(\d+)(?:\.(\d+))?(?:-(?:latest|\d{4}))?$/u;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`];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-`)}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}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};