feat(opencode): add grok 4.5 and default to it via x.ai subscription - #2030
Conversation
|
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds an ChangesxAI Grok provider integration
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request adds support for the xAI Grok-4.5 model, including adding the XAI_API_KEY environment variable, configuring the xai provider, and setting Grok-4.5 as the default model. The review feedback correctly points out that the descriptions referring to "via xAI subscription" are misleading, as subscriptions use OAuth, whereas the API key is for the pay-as-you-go xAI Console API. It is recommended to update these descriptions to "via xAI API" or "via xAI Console" to prevent user confusion.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| # xAI API key for Grok access via x.ai subscription (used by opencode xai provider) | ||
| XAI_API_KEY=xai-your-key-here |
There was a problem hiding this comment.
The comment states that the XAI_API_KEY is for access via the "x.ai subscription". However, xAI subscriptions (SuperGrok / X Premium) authenticate via OAuth (browser login or device code) and do not provide API keys. The XAI_API_KEY is instead used for pay-as-you-go API access via the xAI Console (console.x.ai). The comment should be updated to avoid confusing users.
# xAI API key for Grok access via xAI Console (used by opencode xai provider)
XAI_API_KEY=xai-your-key-here
| "grok-4.5": { | ||
| "name": "Grok 4.5 (via xAI subscription)" | ||
| } |
There was a problem hiding this comment.
The display name says "via xAI subscription", but this provider block is configured to use XAI_API_KEY which is for the pay-as-you-go xAI Console API. Users with a SuperGrok subscription authenticate via OAuth and do not use this API key. To prevent confusion, the display name should be updated to "via xAI API" or "via xAI Console".
"grok-4.5": {
"name": "Grok 4.5 (via xAI API)"
}
| "__GROK__": { | ||
| "name": "__GROK_PRETTY__ (via xAI subscription)" | ||
| } |
There was a problem hiding this comment.
The display name in the template says "via xAI subscription", but this provider block is configured to use XAI_API_KEY which is for the pay-as-you-go xAI Console API. Users with a SuperGrok subscription authenticate via OAuth and do not use this API key. To prevent confusion, the display name should be updated to "via xAI API" or "via xAI Console".
"__GROK__": {
"name": "__GROK_PRETTY__ (via xAI API)"
}
| "$schema": "https://opencode.ai/config.json", | ||
| "model": "cliproxyapi/__GLM__", | ||
| "model": "xai/__GROK__", | ||
| "small_model": "cliproxyapi/__GLM__", |
There was a problem hiding this comment.
Optional: the default model is now xai/__GROK__, but small_model still resolves to cliproxyapi/__GLM__. Anyone who onboards with just XAI_API_KEY (as .env.example now suggests) will get auth failures the moment opencode dispatches to the small-model path. If keeping GLM here is intentional (cheaper/faster for aux calls), no action needed — otherwise switch this to xai/__GROK__ so the default stack is self-consistent.
There was a problem hiding this comment.
Performed full review of 32ef2ba...aa13845
Analysis
• Changing the default model to xAI/Grok requires a new paid API key (XAI_API_KEY), creating a bootstrap failure for fresh environments and CI pipelines unless the key is explicitly configured—this breaks the zero-friction onboarding experience and increases developer friction unnecessarily.
• Missing preflight validation and error handling means users without XAI_API_KEY will encounter unclear failures rather than actionable error messages directing them to configure the key or select an alternative model.
• CI/test pipelines will break unless updated with mock or test credentials for the new default model, requiring infrastructure changes to mitigate.
• The default model change represents a significant policy-level decision that should be opt-in rather than enforced, with a widely-available provider (like GLM-4.7) maintained as the default and Grok offered as a documented performance upgrade for those willing to add the dependency.
Tip
Help
Slash Commands:
/review- Request a full code review/review latest- Review only changes since the last review/describe- Generate PR description. This will update the PR body or issue comment depending on your configuration/help- Get help with Mesa commands and configuration options
0 files reviewed | 3 comments | Edit Agent Settings • Read Docs
| { | ||
| "$schema": "https://opencode.ai/config.json", | ||
| "model": "cliproxyapi/glm-4.7", | ||
| "model": "xai/grok-4.5", |
There was a problem hiding this comment.
Changing the default model to xai/grok-4.5 creates a breaking change for environments without XAI_API_KEY. Fresh setups, CI pipelines, and new developer environments will fail immediately. Consider: (1) adding preflight validation with actionable error messages pointing to .env.example, (2) implementing fallback logic to cliproxyapi/glm-4.7 when the key is unavailable, or (3) keeping a widely-available provider as default and documenting Grok as an opt-in upgrade.
Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#2030
File: config/opencode/opencode.jsonc#L3
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.
Feedback:
Changing the default model to `xai/grok-4.5` creates a breaking change for environments without `XAI_API_KEY`. Fresh setups, CI pipelines, and new developer environments will fail immediately. Consider: (1) adding preflight validation with actionable error messages pointing to `.env.example`, (2) implementing fallback logic to `cliproxyapi/glm-4.7` when the key is unavailable, or (3) keeping a widely-available provider as default and documenting Grok as an opt-in upgrade.
| "xai": { | ||
| "name": "xAI", | ||
| "options": { | ||
| "apiKey": "{env:XAI_API_KEY}" |
There was a problem hiding this comment.
The apiKey configuration uses environment variable interpolation {env:XAI_API_KEY}. Please verify this interpolation format matches the pattern used by other providers (e.g., anthropic, openai) to ensure consistency in credential resolution. If other providers use a different format or include additional options like timeout/retry/baseUrl fields, those should be added here for parity.
Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#2030
File: config/opencode/opencode.tpl.jsonc#L199
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.
Feedback:
The `apiKey` configuration uses environment variable interpolation `{env:XAI_API_KEY}`. Please verify this interpolation format matches the pattern used by other providers (e.g., anthropic, openai) to ensure consistency in credential resolution. If other providers use a different format or include additional options like timeout/retry/baseUrl fields, those should be added here for parity.
| OPENCLAW_GATEWAY_TOKEN=your-gateway-token-here | ||
| # OpenCode API key for OpenCode Go access via cliproxyapi | ||
| OPENCODE_API_KEY=your-opencode-api-key-here | ||
| # xAI API key for Grok access via x.ai subscription (used by opencode xai provider) |
There was a problem hiding this comment.
Good documentation of the new API key. However, since xai/grok-4.5 is now the default model, consider adding additional context here explaining: (1) this key is required for the default configuration, (2) how to obtain it (link to x.ai subscription), and (3) what fallback model to use if unavailable. This will significantly improve developer onboarding and reduce setup friction.
Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#2030
File: .env.example#L16
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.
Feedback:
Good documentation of the new API key. However, since `xai/grok-4.5` is now the default model, consider adding additional context here explaining: (1) this key is **required** for the default configuration, (2) how to obtain it (link to x.ai subscription), and (3) what fallback model to use if unavailable. This will significantly improve developer onboarding and reduce setup friction.
Mesa DescriptionTL;DRAdded Grok 4.5 support to opencode, setting it as the default model powered by the x.ai provider. What changed?
Test plan
🤖 Generated with Claude Code Description generated by Mesa. Update settings |
There was a problem hiding this comment.
3 issues found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="config/opencode/opencode.tpl.jsonc">
<violation number="1" location="config/opencode/opencode.tpl.jsonc:203">
P2: Same issue as in the generated config: "via xAI subscription" is inaccurate for API-key-based access. This template propagates the misleading label. Should be "via xAI API" to match how `XAI_API_KEY` authentication actually works.</violation>
</file>
<file name="config/opencode/opencode.jsonc">
<violation number="1" location="config/opencode/opencode.jsonc:203">
P2: The display name "Grok 4.5 (via xAI subscription)" is misleading — `XAI_API_KEY` is used for pay-as-you-go access through the xAI Console, not subscription-based OAuth. Consider renaming to "Grok 4.5 (via xAI API)" to accurately reflect the authentication method.</violation>
</file>
<file name=".env.example">
<violation number="1" location=".env.example:16">
P2: The comment says "via x.ai subscription" but `XAI_API_KEY` is actually for pay-as-you-go API access through the xAI Console (`console.x.ai`). xAI subscriptions (SuperGrok / X Premium) authenticate via OAuth, not API keys. This will confuse developers trying to set up their environment.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| }, | ||
| "models": { | ||
| "__GROK__": { | ||
| "name": "__GROK_PRETTY__ (via xAI subscription)" |
There was a problem hiding this comment.
P2: Same issue as in the generated config: "via xAI subscription" is inaccurate for API-key-based access. This template propagates the misleading label. Should be "via xAI API" to match how XAI_API_KEY authentication actually works.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At config/opencode/opencode.tpl.jsonc, line 203:
<comment>Same issue as in the generated config: "via xAI subscription" is inaccurate for API-key-based access. This template propagates the misleading label. Should be "via xAI API" to match how `XAI_API_KEY` authentication actually works.</comment>
<file context>
@@ -193,6 +193,17 @@
+ },
+ "models": {
+ "__GROK__": {
+ "name": "__GROK_PRETTY__ (via xAI subscription)"
+ }
+ }
</file context>
| "name": "__GROK_PRETTY__ (via xAI subscription)" | |
| "name": "__GROK_PRETTY__ (via xAI API)" |
| }, | ||
| "models": { | ||
| "grok-4.5": { | ||
| "name": "Grok 4.5 (via xAI subscription)" |
There was a problem hiding this comment.
P2: The display name "Grok 4.5 (via xAI subscription)" is misleading — XAI_API_KEY is used for pay-as-you-go access through the xAI Console, not subscription-based OAuth. Consider renaming to "Grok 4.5 (via xAI API)" to accurately reflect the authentication method.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At config/opencode/opencode.jsonc, line 203:
<comment>The display name "Grok 4.5 (via xAI subscription)" is misleading — `XAI_API_KEY` is used for pay-as-you-go access through the xAI Console, not subscription-based OAuth. Consider renaming to "Grok 4.5 (via xAI API)" to accurately reflect the authentication method.</comment>
<file context>
@@ -193,6 +193,17 @@
+ },
+ "models": {
+ "grok-4.5": {
+ "name": "Grok 4.5 (via xAI subscription)"
+ }
+ }
</file context>
| "name": "Grok 4.5 (via xAI subscription)" | |
| "name": "Grok 4.5 (via xAI API)" |
| OPENCLAW_GATEWAY_TOKEN=your-gateway-token-here | ||
| # OpenCode API key for OpenCode Go access via cliproxyapi | ||
| OPENCODE_API_KEY=your-opencode-api-key-here | ||
| # xAI API key for Grok access via x.ai subscription (used by opencode xai provider) |
There was a problem hiding this comment.
P2: The comment says "via x.ai subscription" but XAI_API_KEY is actually for pay-as-you-go API access through the xAI Console (console.x.ai). xAI subscriptions (SuperGrok / X Premium) authenticate via OAuth, not API keys. This will confuse developers trying to set up their environment.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .env.example, line 16:
<comment>The comment says "via x.ai subscription" but `XAI_API_KEY` is actually for pay-as-you-go API access through the xAI Console (`console.x.ai`). xAI subscriptions (SuperGrok / X Premium) authenticate via OAuth, not API keys. This will confuse developers trying to set up their environment.</comment>
<file context>
@@ -13,5 +13,7 @@ OPENCLAW_ANTHROPIC_API_KEY=sk-ant-api03-your-key-here
OPENCLAW_GATEWAY_TOKEN=your-gateway-token-here
# OpenCode API key for OpenCode Go access via cliproxyapi
OPENCODE_API_KEY=your-opencode-api-key-here
+# xAI API key for Grok access via x.ai subscription (used by opencode xai provider)
+XAI_API_KEY=xai-your-key-here
# Paperclip database URL
</file context>
| # xAI API key for Grok access via x.ai subscription (used by opencode xai provider) | |
| # xAI API key for Grok access via xAI Console (used by opencode xai provider) |
Summary
grok→grok-4.5tomodels.jsonmodeltoxai/grok-4.5(small_model stays on GLM-4.7)xaiprovider block to opencode config, authed viaXAI_API_KEY(x.ai subscription)XAI_API_KEYin.env.exampleGenerated
config/opencode/opencode.jsoncwas regenerated from the template viascripts/llm-update.sh.Test plan
jq empty models.jsonpassesscripts/llm-update.shregeneratesopencode.jsoncwithxai/grok-4.5as default and thexaiprovider blockXAI_API_KEYin.envand confirm opencode connects to Grok🤖 Generated with Claude Code
Summary by cubic
Defaulted OpenCode to
xai/grok-4.5via the x.ai subscription and added anxaiprovider.small_modelstays oncliproxyapi/glm-4.7.New Features
grok→grok-4.5inmodels.json.xai/grok-4.5inconfig/opencode/opencode.jsoncandconfig/opencode/opencode.tpl.jsonc.xaiprovider withXAI_API_KEYauth; documented in.env.example.Migration
XAI_API_KEYin your.envto enable Grok via x.ai.scripts/llm-update.shto regenerate config.Written for commit aa13845. Summary will update on new commits.