Vendor OpenClaw source as Adolf fork baseline
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
This commit is contained in:
346
extensions/xai/model-definitions.ts
Normal file
346
extensions/xai/model-definitions.ts
Normal file
@@ -0,0 +1,346 @@
|
||||
// Xai plugin module implements model definitions behavior.
|
||||
import type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-shared";
|
||||
import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
||||
|
||||
export const XAI_BASE_URL = "https://api.x.ai/v1";
|
||||
export const XAI_DEFAULT_IMAGE_MODEL = "grok-imagine-image";
|
||||
export const XAI_IMAGE_MODELS = ["grok-imagine-image", "grok-imagine-image-quality"] as const;
|
||||
export const XAI_DEFAULT_CONTEXT_WINDOW = 1_000_000;
|
||||
const XAI_LARGE_CONTEXT_WINDOW = 2_000_000;
|
||||
const XAI_GROK_4_CONTEXT_WINDOW = 256_000;
|
||||
const XAI_CODE_CONTEXT_WINDOW = 256_000;
|
||||
export const XAI_DEFAULT_MAX_TOKENS = 64_000;
|
||||
const XAI_LEGACY_CONTEXT_WINDOW = 131_072;
|
||||
const XAI_LEGACY_MAX_TOKENS = 8_192;
|
||||
export const XAI_DEFAULT_MODEL_ID = "grok-4.3";
|
||||
|
||||
type XaiCost = ModelDefinitionConfig["cost"];
|
||||
|
||||
type XaiCatalogEntry = {
|
||||
id: string;
|
||||
name: string;
|
||||
reasoning: boolean;
|
||||
input?: ModelDefinitionConfig["input"];
|
||||
contextWindow: number;
|
||||
maxTokens?: number;
|
||||
cost: XaiCost;
|
||||
};
|
||||
|
||||
const XAI_GROK_4_COST = {
|
||||
input: 3,
|
||||
output: 15,
|
||||
cacheRead: 0.75,
|
||||
cacheWrite: 0,
|
||||
} satisfies XaiCost;
|
||||
|
||||
const XAI_FAST_COST = {
|
||||
input: 0.2,
|
||||
output: 0.5,
|
||||
cacheRead: 0.05,
|
||||
cacheWrite: 0,
|
||||
} satisfies XaiCost;
|
||||
|
||||
const XAI_GROK_420_COST = {
|
||||
input: 1.25,
|
||||
output: 2.5,
|
||||
cacheRead: 0.2,
|
||||
cacheWrite: 0,
|
||||
} satisfies XaiCost;
|
||||
|
||||
const XAI_GROK_43_COST = {
|
||||
input: 1.25,
|
||||
output: 2.5,
|
||||
cacheRead: 0.2,
|
||||
cacheWrite: 0,
|
||||
} satisfies XaiCost;
|
||||
|
||||
const XAI_GROK_BUILD_COST = {
|
||||
input: 1,
|
||||
output: 2,
|
||||
cacheRead: 0.2,
|
||||
cacheWrite: 0,
|
||||
} satisfies XaiCost;
|
||||
|
||||
const XAI_CODE_FAST_COST = {
|
||||
input: 0.2,
|
||||
output: 1.5,
|
||||
cacheRead: 0.02,
|
||||
cacheWrite: 0,
|
||||
} satisfies XaiCost;
|
||||
|
||||
const XAI_MODEL_CATALOG = [
|
||||
{
|
||||
id: "grok-build-0.1",
|
||||
name: "Grok Build 0.1",
|
||||
reasoning: true,
|
||||
input: ["text", "image"],
|
||||
contextWindow: XAI_CODE_CONTEXT_WINDOW,
|
||||
cost: XAI_GROK_BUILD_COST,
|
||||
},
|
||||
{
|
||||
id: "grok-3",
|
||||
name: "Grok 3",
|
||||
reasoning: false,
|
||||
input: ["text"],
|
||||
contextWindow: XAI_LEGACY_CONTEXT_WINDOW,
|
||||
maxTokens: XAI_LEGACY_MAX_TOKENS,
|
||||
cost: XAI_GROK_4_COST,
|
||||
},
|
||||
{
|
||||
id: "grok-3-fast",
|
||||
name: "Grok 3 Fast",
|
||||
reasoning: false,
|
||||
input: ["text"],
|
||||
contextWindow: XAI_LEGACY_CONTEXT_WINDOW,
|
||||
maxTokens: XAI_LEGACY_MAX_TOKENS,
|
||||
cost: { input: 5, output: 25, cacheRead: 1.25, cacheWrite: 0 },
|
||||
},
|
||||
{
|
||||
id: "grok-3-mini",
|
||||
name: "Grok 3 Mini",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
contextWindow: XAI_LEGACY_CONTEXT_WINDOW,
|
||||
maxTokens: XAI_LEGACY_MAX_TOKENS,
|
||||
cost: { input: 0.3, output: 0.5, cacheRead: 0.075, cacheWrite: 0 },
|
||||
},
|
||||
{
|
||||
id: "grok-3-mini-fast",
|
||||
name: "Grok 3 Mini Fast",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
contextWindow: XAI_LEGACY_CONTEXT_WINDOW,
|
||||
maxTokens: XAI_LEGACY_MAX_TOKENS,
|
||||
cost: { input: 0.6, output: 4, cacheRead: 0.15, cacheWrite: 0 },
|
||||
},
|
||||
{
|
||||
id: "grok-4.3",
|
||||
name: "Grok 4.3",
|
||||
reasoning: true,
|
||||
input: ["text", "image"],
|
||||
contextWindow: XAI_DEFAULT_CONTEXT_WINDOW,
|
||||
maxTokens: XAI_DEFAULT_MAX_TOKENS,
|
||||
cost: XAI_GROK_43_COST,
|
||||
},
|
||||
{
|
||||
id: "grok-4",
|
||||
name: "Grok 4",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
contextWindow: XAI_GROK_4_CONTEXT_WINDOW,
|
||||
maxTokens: XAI_DEFAULT_MAX_TOKENS,
|
||||
cost: XAI_GROK_4_COST,
|
||||
},
|
||||
{
|
||||
id: "grok-4-0709",
|
||||
name: "Grok 4 0709",
|
||||
reasoning: false,
|
||||
input: ["text"],
|
||||
contextWindow: XAI_GROK_4_CONTEXT_WINDOW,
|
||||
maxTokens: XAI_DEFAULT_MAX_TOKENS,
|
||||
cost: XAI_GROK_4_COST,
|
||||
},
|
||||
{
|
||||
id: "grok-4-fast",
|
||||
name: "Grok 4 Fast",
|
||||
reasoning: true,
|
||||
input: ["text", "image"],
|
||||
contextWindow: XAI_LARGE_CONTEXT_WINDOW,
|
||||
maxTokens: 30_000,
|
||||
cost: XAI_FAST_COST,
|
||||
},
|
||||
{
|
||||
id: "grok-4-fast-non-reasoning",
|
||||
name: "Grok 4 Fast (Non-Reasoning)",
|
||||
reasoning: false,
|
||||
input: ["text", "image"],
|
||||
contextWindow: XAI_LARGE_CONTEXT_WINDOW,
|
||||
maxTokens: 30_000,
|
||||
cost: XAI_FAST_COST,
|
||||
},
|
||||
{
|
||||
id: "grok-4-1-fast",
|
||||
name: "Grok 4.1 Fast",
|
||||
reasoning: true,
|
||||
input: ["text", "image"],
|
||||
contextWindow: XAI_LARGE_CONTEXT_WINDOW,
|
||||
maxTokens: 30_000,
|
||||
cost: XAI_FAST_COST,
|
||||
},
|
||||
{
|
||||
id: "grok-4-1-fast-non-reasoning",
|
||||
name: "Grok 4.1 Fast (Non-Reasoning)",
|
||||
reasoning: false,
|
||||
input: ["text", "image"],
|
||||
contextWindow: XAI_LARGE_CONTEXT_WINDOW,
|
||||
maxTokens: 30_000,
|
||||
cost: XAI_FAST_COST,
|
||||
},
|
||||
{
|
||||
id: "grok-4.20-beta-latest-reasoning",
|
||||
name: "Grok 4.20 Beta Latest (Reasoning)",
|
||||
reasoning: true,
|
||||
input: ["text", "image"],
|
||||
contextWindow: XAI_LARGE_CONTEXT_WINDOW,
|
||||
maxTokens: 30_000,
|
||||
cost: XAI_GROK_420_COST,
|
||||
},
|
||||
{
|
||||
id: "grok-4.20-beta-latest-non-reasoning",
|
||||
name: "Grok 4.20 Beta Latest (Non-Reasoning)",
|
||||
reasoning: false,
|
||||
input: ["text", "image"],
|
||||
contextWindow: XAI_LARGE_CONTEXT_WINDOW,
|
||||
maxTokens: 30_000,
|
||||
cost: XAI_GROK_420_COST,
|
||||
},
|
||||
] as const satisfies readonly XaiCatalogEntry[];
|
||||
|
||||
const XAI_SELECTABLE_MODEL_IDS = new Set<string>([
|
||||
"grok-build-0.1",
|
||||
"grok-4.3",
|
||||
"grok-4.20-beta-latest-reasoning",
|
||||
"grok-4.20-beta-latest-non-reasoning",
|
||||
]);
|
||||
|
||||
const XAI_GROK_BUILD_ALIASES = new Set<string>([
|
||||
"grok-code-fast-1",
|
||||
"grok-code-fast",
|
||||
"grok-code-fast-1-0825",
|
||||
]);
|
||||
|
||||
const XAI_RETIRED_BUILTIN_MODEL_IDS = new Set<string>(
|
||||
XAI_MODEL_CATALOG.map((entry) => entry.id).filter((id) => !XAI_SELECTABLE_MODEL_IDS.has(id)),
|
||||
);
|
||||
|
||||
function normalizeXaiCatalogModelId(modelId: string): string {
|
||||
const lower = normalizeOptionalLowercaseString(modelId) ?? "";
|
||||
const unprefixed = lower.startsWith("xai/") ? lower.slice("xai/".length) : lower;
|
||||
if (XAI_GROK_BUILD_ALIASES.has(unprefixed)) {
|
||||
return "grok-build-0.1";
|
||||
}
|
||||
return unprefixed;
|
||||
}
|
||||
|
||||
export function isRetiredXaiBuiltinModelId(modelId: string): boolean {
|
||||
const lower = normalizeOptionalLowercaseString(modelId) ?? "";
|
||||
const unprefixed = lower.startsWith("xai/") ? lower.slice("xai/".length) : lower;
|
||||
if (XAI_GROK_BUILD_ALIASES.has(unprefixed)) {
|
||||
return true;
|
||||
}
|
||||
return XAI_RETIRED_BUILTIN_MODEL_IDS.has(normalizeXaiCatalogModelId(modelId));
|
||||
}
|
||||
|
||||
function toModelDefinition(entry: XaiCatalogEntry): ModelDefinitionConfig {
|
||||
return {
|
||||
id: entry.id,
|
||||
name: entry.name,
|
||||
reasoning: entry.reasoning,
|
||||
input: entry.input ?? ["text"],
|
||||
cost: entry.cost,
|
||||
contextWindow: entry.contextWindow,
|
||||
maxTokens: entry.maxTokens ?? XAI_DEFAULT_MAX_TOKENS,
|
||||
};
|
||||
}
|
||||
|
||||
export function buildXaiModelDefinition(): ModelDefinitionConfig {
|
||||
return toModelDefinition(
|
||||
XAI_MODEL_CATALOG.find((entry) => entry.id === XAI_DEFAULT_MODEL_ID) ?? {
|
||||
id: XAI_DEFAULT_MODEL_ID,
|
||||
name: "Grok 4.3",
|
||||
reasoning: true,
|
||||
input: ["text", "image"],
|
||||
contextWindow: XAI_DEFAULT_CONTEXT_WINDOW,
|
||||
maxTokens: XAI_DEFAULT_MAX_TOKENS,
|
||||
cost: XAI_GROK_43_COST,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function buildXaiCatalogModels(): ModelDefinitionConfig[] {
|
||||
return XAI_MODEL_CATALOG.filter((entry) => XAI_SELECTABLE_MODEL_IDS.has(entry.id)).map((entry) =>
|
||||
toModelDefinition(entry),
|
||||
);
|
||||
}
|
||||
|
||||
export function resolveXaiCatalogEntry(modelId: string) {
|
||||
const trimmed = modelId.trim();
|
||||
const lower = normalizeXaiCatalogModelId(modelId);
|
||||
const exact = XAI_MODEL_CATALOG.find(
|
||||
(entry) => normalizeOptionalLowercaseString(entry.id) === lower,
|
||||
);
|
||||
if (exact) {
|
||||
return toModelDefinition(exact);
|
||||
}
|
||||
if (lower.includes("multi-agent")) {
|
||||
return undefined;
|
||||
}
|
||||
if (lower.startsWith("grok-code-fast")) {
|
||||
return toModelDefinition({
|
||||
id: trimmed,
|
||||
name: trimmed,
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
contextWindow: XAI_CODE_CONTEXT_WINDOW,
|
||||
maxTokens: 10_000,
|
||||
cost: XAI_CODE_FAST_COST,
|
||||
});
|
||||
}
|
||||
if (
|
||||
lower.startsWith("grok-3-mini-fast") ||
|
||||
lower.startsWith("grok-3-mini") ||
|
||||
lower.startsWith("grok-3-fast") ||
|
||||
lower.startsWith("grok-3")
|
||||
) {
|
||||
const legacyCost = lower.startsWith("grok-3-mini-fast")
|
||||
? { input: 0.6, output: 4, cacheRead: 0.15, cacheWrite: 0 }
|
||||
: lower.startsWith("grok-3-mini")
|
||||
? { input: 0.3, output: 0.5, cacheRead: 0.075, cacheWrite: 0 }
|
||||
: lower.startsWith("grok-3-fast")
|
||||
? { input: 5, output: 25, cacheRead: 1.25, cacheWrite: 0 }
|
||||
: XAI_GROK_4_COST;
|
||||
return toModelDefinition({
|
||||
id: trimmed,
|
||||
name: trimmed,
|
||||
reasoning: lower.includes("mini"),
|
||||
input: ["text"],
|
||||
contextWindow: XAI_LEGACY_CONTEXT_WINDOW,
|
||||
maxTokens: XAI_LEGACY_MAX_TOKENS,
|
||||
cost: legacyCost,
|
||||
});
|
||||
}
|
||||
if (
|
||||
lower.startsWith("grok-4.3") ||
|
||||
lower.startsWith("grok-4.20") ||
|
||||
lower.startsWith("grok-4-1") ||
|
||||
lower.startsWith("grok-4-fast")
|
||||
) {
|
||||
return toModelDefinition({
|
||||
id: trimmed,
|
||||
name: trimmed,
|
||||
reasoning: !lower.includes("non-reasoning"),
|
||||
input: ["text", "image"],
|
||||
contextWindow: lower.startsWith("grok-4.3")
|
||||
? XAI_DEFAULT_CONTEXT_WINDOW
|
||||
: XAI_LARGE_CONTEXT_WINDOW,
|
||||
maxTokens: lower.startsWith("grok-4.3") ? XAI_DEFAULT_MAX_TOKENS : 30_000,
|
||||
cost: lower.startsWith("grok-4.3")
|
||||
? XAI_GROK_43_COST
|
||||
: lower.startsWith("grok-4.20")
|
||||
? XAI_GROK_420_COST
|
||||
: XAI_FAST_COST,
|
||||
});
|
||||
}
|
||||
if (lower.startsWith("grok-4")) {
|
||||
return toModelDefinition({
|
||||
id: modelId.trim(),
|
||||
name: modelId.trim(),
|
||||
reasoning: lower.includes("reasoning"),
|
||||
input: ["text"],
|
||||
contextWindow: XAI_GROK_4_CONTEXT_WINDOW,
|
||||
maxTokens: XAI_DEFAULT_MAX_TOKENS,
|
||||
cost: XAI_GROK_4_COST,
|
||||
});
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user