Run grok via OpenRouter by borrowing codex's harness - #47
Merged
Merged
Conversation
Grok's own CLI can't be repointed at OpenRouter, but its model (x-ai/grok-build-0.1) is on OpenRouter - so grok stops being native-only: its OpenRouter leg runs through codex's read-only `exec` harness pointed at that model. A signed-in-but-out-of-credits grok now falls back to OpenRouter and succeeds on the user's key instead of hard-failing on xAI's 403. The "grok borrows codex" fact lives in one place, `openrouter_runner()` (grok -> codex, everyone else -> self); command(), reads_stdin(), and the capability checks all derive the executing CLI from it. codex's exec command is factored into `codex_exec_command(repo, or_model)`, shared by codex's own two legs and grok's OpenRouter leg. Because that leg spawns codex, not grok: - openrouter_reachable() (used for selection/forcing) requires the borrowed runner to be installable, so grok isn't planned onto a route that can't build; openrouter_capable() adds the run-time Vibe-home check on top - prewarm/update bootstrap the runner too (codex for grok), but only when a key makes the fallback reachable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Grok's own CLI can't be repointed at OpenRouter, but its model (
x-ai/grok-build-0.1) is on OpenRouter — so grok stops being native-only: its OpenRouter leg runsx-ai/grok-build-0.1through codex's read-onlyexecharness. A signed-in-but-out-of-credits grok now falls back to OpenRouter and succeeds on the user's key instead of hard-failing on xAI's 403.openrouter_runner()(grok→codex, else self);command()/reads_stdin()/capability checks all derive from itcodex_exec_command(repo, or_model), shared by codex (both legs) and grok's OpenRouter legopenrouter_reachable()(selection/forcing) requires the borrowed runner to be installable, so grok isn't planned onto a route that can't build;openrouter_capable()adds the run-time Vibe-home checkTwo
/code-review+/postmortemthispasses (borrowed-harness dependency, prewarm, selection-gate consensus findings all fixed). Build + clippy clean; native-fail→OpenRouter fallback and forced-OpenRouter both verified live (x-ai/grok-build-0.1returns real answers on the OpenRouter key).