feat: add xAI Grok provider support#9832
Conversation
- Add DeepSeek to authentication choice types and options - Create DeepSeek authentication handler following existing patterns - Implement provider configuration and model definitions - Wire DeepSeek handler into onboarding flow - Add setDeepSeekApiKey credential function Resolves openclaw#7309
Import DEEPSEEK_DEFAULT_MODEL_REF from onboard-auth.models.ts instead of duplicating it in credentials file to avoid drift. Addresses feedback from Greptile code review bot.
Implemented xAI Grok as a first-class LLM provider: - Added 'xai-api-key' to AuthChoice and OnboardOptions - Defined xAI provider group and choice options - Added Grok model definitions (grok-2-latest) - Created applyAuthChoiceXAI handler for API key authentication - Integrated xAI into the onboarding flow configuration logic
| if (authChoice === "xai-api-key") { | ||
| const key = params.opts?.xaiApiKey; | ||
| if (typeof key !== "string" || key.trim() === "") { | ||
| return null; |
There was a problem hiding this comment.
Non-interactive xAI path breaks
applyAuthChoiceXAI returns null when authChoice === "xai-api-key" but opts.xaiApiKey is missing/blank. In the dispatcher (src/commands/auth-choice.apply.ts:60-67), null means “no handler matched”, so onboarding will silently fall through and keep the old config even though the user selected xAI. This will definitely break claw onboard --non-interactive --authChoice xai-api-key unless --xaiApiKey is always provided.
Fix: if authChoice matches, don’t return null—either (a) prompt for the key in interactive mode like other API-key flows, or (b) throw/return an error result in non-interactive mode when the key is missing.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/commands/auth-choice.apply.xai.ts
Line: 10:13
Comment:
**Non-interactive xAI path breaks**
`applyAuthChoiceXAI` returns `null` when `authChoice === "xai-api-key"` but `opts.xaiApiKey` is missing/blank. In the dispatcher (`src/commands/auth-choice.apply.ts:60-67`), `null` means “no handler matched”, so onboarding will silently fall through and keep the old config even though the user selected xAI. This will definitely break `claw onboard --non-interactive --authChoice xai-api-key` unless `--xaiApiKey` is always provided.
Fix: if `authChoice` matches, don’t return `null`—either (a) prompt for the key in interactive mode like other API-key flows, or (b) throw/return an error result in non-interactive mode when the key is missing.
How can I resolve this? If you propose a fix, please make it concise.
Additional Comments (1)
Add an Prompt To Fix With AIThis is a comment left during a code review.
Path: src/commands/auth-choice-options.ts
Line: 153:156
Comment:
**Missing xAI choice option**
`AUTH_CHOICE_GROUP_DEFS` includes `choices: ["xai-api-key"]` (`src/commands/auth-choice-options.ts:42-47`), but `buildAuthChoiceOptions` never pushes an option with `value: "xai-api-key"`. As a result, the xAI group will render with an empty `options` array (it gets filtered out in `buildAuthChoiceGroups`), so users won’t be able to select Grok during interactive onboarding.
Add an `options.push({ value: "xai-api-key", ... })` entry (similar to the DeepSeek one at `src/commands/auth-choice-options.ts:235`).
How can I resolve this? If you propose a fix, please make it concise. |
|
I narrowed this down to xAI-only and opened a replacement PR: #9885. Rationale:
If you’d prefer to keep #9832 instead of switching PRs, the head branch can be rewritten to just commit 1310e9c (xAI-only) via a force-push. |
|
Superseded by #9885 (xAI-only). Closing this PR to avoid duplicate review. |
Overview
This PR adds first-class support for xAI’s Grok models (Grok 2) to OpenClaw. It enables users to select Grok as their LLM provider during the onboarding process (
claw onboard) and configures it automatically using an API key.Changes
xai-api-keyto the authentication choices andxaiApiKeyto onboarding options.grok-2-latest).Verification
pnpm buildsuccessfully to ensure no type regressions.Greptile Overview
Greptile Summary
This PR adds onboarding and configuration support for xAI (Grok) and DeepSeek:
cfg.models.providers).The implementation largely follows existing provider patterns, but there are a couple of xAI wiring issues that will prevent users from selecting/configuring xAI correctly in interactive and non-interactive onboarding (called out in review comments).
Confidence Score: 3/5
(4/5) You can add custom instructions or style guidelines for the agent here!