Skip to content

feat(opencode): add grok 4.5 and default to it via x.ai subscription - #2030

Merged
shunkakinoki merged 1 commit into
mainfrom
worktree-sequential-sprouting-reef
Jul 8, 2026
Merged

feat(opencode): add grok 4.5 and default to it via x.ai subscription#2030
shunkakinoki merged 1 commit into
mainfrom
worktree-sequential-sprouting-reef

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add grokgrok-4.5 to models.json
  • Set opencode default model to xai/grok-4.5 (small_model stays on GLM-4.7)
  • Add xai provider block to opencode config, authed via XAI_API_KEY (x.ai subscription)
  • Document XAI_API_KEY in .env.example

Generated config/opencode/opencode.jsonc was regenerated from the template via scripts/llm-update.sh.

Test plan

  • jq empty models.json passes
  • scripts/llm-update.sh regenerates opencode.jsonc with xai/grok-4.5 as default and the xai provider block
  • Set XAI_API_KEY in .env and confirm opencode connects to Grok

🤖 Generated with Claude Code


Summary by cubic

Defaulted OpenCode to xai/grok-4.5 via the x.ai subscription and added an xai provider. small_model stays on cliproxyapi/glm-4.7.

  • New Features

    • Added grokgrok-4.5 in models.json.
    • Set default model to xai/grok-4.5 in config/opencode/opencode.jsonc and config/opencode/opencode.tpl.jsonc.
    • Added xai provider with XAI_API_KEY auth; documented in .env.example.
  • Migration

    • Set XAI_API_KEY in your .env to enable Grok via x.ai.
    • If using the template, run scripts/llm-update.sh to regenerate config.

Written for commit aa13845. Summary will update on new commits.

Review in cubic

@indent-zero

indent-zero Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor
PR Summary

Adds Grok 4.5 as an opencode provider via xAI and makes it the new default model. This lets bare opencode invocations use the author's xAI subscription instead of the cliproxyapi/GLM path, while shortcut fish functions (which pass an explicit model) are unaffected.

  • Register grokgrok-4.5 alias in models.json so the template substitution pipeline emits __GROK__ / __GROK_PRETTY__ / __GROK_NONDOT__.
  • Add a new xai provider block to config/opencode/opencode.tpl.jsonc (and regenerated opencode.jsonc) exposing grok-4.5 (display: Grok 4.5 (via xAI subscription)), keyed by {env:XAI_API_KEY}.
  • Flip the top-level opencode default model from cliproxyapi/glm-4.7 to xai/grok-4.5; small_model intentionally stays on cliproxyapi/glm-4.7.
  • Document XAI_API_KEY in .env.example.

Issues

1 potential issue found:

  • small_model still points to cliproxyapi/glm-4.7 while the default model flips to xai/grok-4.5; users who only set XAI_API_KEY will hit auth failures on opencode paths that route through small_model. Intentional cost/latency split is fine — confirm or also move small_model to xai/__GROK__. → Autofix

CI Checks

Waiting for CI checks...


⚡ Autofix All Issues

@cursor

cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown

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.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5801df67-1f87-45be-828d-dde3e06ebbee

📥 Commits

Reviewing files that changed from the base of the PR and between 32ef2ba and aa13845.

📒 Files selected for processing (4)
  • .env.example
  • config/opencode/opencode.jsonc
  • config/opencode/opencode.tpl.jsonc
  • models.json

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added support for a new Grok-based model option and updated the default model selection to use it.
    • Added xAI subscription setup details to the environment example for easier configuration.
  • Configuration

    • Updated app configuration templates to include xAI provider settings and the new model mapping.

Walkthrough

Adds an XAI_API_KEY environment variable, configures a new xai provider block in both opencode.jsonc and its template, switches the default root model to xai/grok-4.5, and adds a grok model mapping in models.json.

Changes

xAI Grok provider integration

Layer / File(s) Summary
Add xAI API key
.env.example
Adds XAI_API_KEY placeholder with a comment referencing xAI/Grok subscription access.
Configure xai provider and default model
config/opencode/opencode.jsonc, config/opencode/opencode.tpl.jsonc, models.json
Changes root model to xai/grok-4.5 (or template placeholder xai/__GROK__), adds a new provider.xai block wired to {env:XAI_API_KEY} with a grok-4.5 model entry, and adds a grok -> grok-4.5 mapping in models.json.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • shunkakinoki/dotfiles#289: Both PRs adjust the Opencode AI configuration by changing the root model selection to a Grok-based model.
  • shunkakinoki/dotfiles#573: Both PRs modify config/opencode/opencode.jsonc to change the root model and corresponding provider configuration.

Poem

A rabbit hops with keys in paw,
XAI_API_KEY, new law!
Grok-4.5 now leads the way,
Configs updated, hip hip hooray! 🐇✨
Off to the burrow, code compiles clean.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding Grok 4.5 and making it the default via x.ai.
Description check ✅ Passed The description directly matches the changeset and mentions the new model, provider config, env var, and regeneration step.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-sequential-sprouting-reef

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .env.example
Comment on lines +16 to +17
# xAI API key for Grok access via x.ai subscription (used by opencode xai provider)
XAI_API_KEY=xai-your-key-here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

Comment on lines +202 to +204
"grok-4.5": {
"name": "Grok 4.5 (via xAI subscription)"
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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)"
        }

Comment on lines +202 to +204
"__GROK__": {
"name": "__GROK_PRETTY__ (via xAI subscription)"
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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__",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mesa-dot-dev mesa-dot-dev Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SettingsRead Docs

{
"$schema": "https://opencode.ai/config.json",
"model": "cliproxyapi/glm-4.7",
"model": "xai/grok-4.5",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High

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.

Fix in Cursor • Fix in Claude

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}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium

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.

Fix in Cursor • Fix in Claude

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.

Comment thread .env.example
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium

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.

Fix in Cursor • Fix in Claude

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-dot-dev

mesa-dot-dev Bot commented Jul 8, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Added Grok 4.5 support to opencode, setting it as the default model powered by the x.ai provider.

What changed?

  • .env.example: Added XAI_API_KEY environment variable and comment for x.ai subscription.
  • config/opencode/opencode.tpl.jsonc: Updated default model placeholder to xai/__GROK__ and added configuration template for the xai provider.
  • config/opencode/opencode.jsonc: Regenerated config to default to xai/grok-4.5 and added the xai provider block.
  • models.json: Added mapping for grok to grok-4.5.

Test plan

  • jq empty models.json passes
  • scripts/llm-update.sh regenerates opencode.jsonc with xai/grok-4.5 as default and the xai provider block
  • Set XAI_API_KEY in .env and confirm opencode connects to Grok

🤖 Generated with Claude Code

Description generated by Mesa. Update settings

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
"name": "__GROK_PRETTY__ (via xAI subscription)"
"name": "__GROK_PRETTY__ (via xAI API)"

},
"models": {
"grok-4.5": {
"name": "Grok 4.5 (via xAI subscription)"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
"name": "Grok 4.5 (via xAI subscription)"
"name": "Grok 4.5 (via xAI API)"

Comment thread .env.example
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
# 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)

@shunkakinoki
shunkakinoki merged commit 0621408 into main Jul 8, 2026
37 checks passed
@shunkakinoki
shunkakinoki deleted the worktree-sequential-sprouting-reef branch July 8, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant