gitmyhub

opencode-grok-auth

TypeScript ★ 12 updated 1mo ago

OpenCode plugin that signs in to xAI Grok through the SuperGrok OAuth/PKCE flow instead of using an XAI_API_KEY.

An OpenCode plugin that lets you use xAI's Grok models by logging in through xAI's browser-based OAuth flow instead of managing an API key, supporting four Grok model variants.

TypeScriptBunOAuthxAI Groksetup: moderatecomplexity 3/5

This is a plugin for OpenCode, an AI coding tool, that adds support for xAI's Grok language models. Normally, connecting to Grok requires an API key. This plugin takes a different approach: it logs you in through xAI's own OAuth flow, the same login mechanism used by the SuperGrok subscription service, so you can use Grok inside OpenCode without managing an API key.

OAuth is a standard way of handling logins where you approve access in a browser rather than copying a token from a dashboard. When you run the login command, the plugin opens a browser window pointing to xAI's authorization page, you sign in with your xAI account, and the plugin receives a short-lived access token that it stores and refreshes automatically in the background. The token is only ever sent to xAI's own API address, and the plugin includes a safety check that blocks it from going anywhere else.

The plugin registers four Grok models in OpenCode's provider list: a general-purpose model, a reasoning-focused variant, a faster non-reasoning variant, and a multi-agent variant. You select which one to use from within OpenCode the same way you would select any other supported model.

Installation is currently manual. You build the plugin locally using Bun, a JavaScript runtime, place the output file in OpenCode's global plugins folder, and add a provider block to OpenCode's configuration file. The README includes step-by-step instructions for Windows, with PowerShell commands for each step. Once published to npm, the setup will be simpler.

The plugin is released under the MIT license. The README credits the implementation pattern to two other open-source projects: an Antigravity Auth plugin by a separate author and xAI OAuth work by Nous Research.

Where it fits