Log into xAI Grok from OpenCode using a personal OAuth flow
Call Grok image, TTS, and video generation from the OpenCode TUI
Run X search with handle filters and date bounds from a coding session
Pick low, medium, or high reasoning effort for grok-4.3 queries
Unofficial OAuth flow for personal use only; xAI ToS applies and the author recommends the official API for production.
opencode-xai-oauth is a community plugin for OpenCode, an open source coding assistant. Its job is to wire up authentication and a set of extra tools so users can log into xAI (the company behind the Grok models) through OAuth or an API key, and call xAI features like text generation, web search, X (formerly Twitter) search, text-to-speech, image generation, and video generation from inside OpenCode. The README is clear that this is unofficial and experimental. It is not affiliated with or endorsed by xAI, it uses consumer OAuth flows for personal use, and users are told to read xAI's Terms of Service before using it. The author recommends the official xAI API for any production work. The plugin does not replace OpenCode's built-in xAI provider. Instead, it attaches an OAuth and API-key login flow to it, so the standard opencode auth login command now authenticates against xAI. It also adds metadata for Grok reasoning, exposing low, medium, and high reasoning effort variants for the grok-4.3 model, and marks grok-4.20-reasoning as reasoning-capable without sending unsupported parameters. The custom tools it adds are xai_status (check credentials), xai_generate_text (text via the xAI Responses API), xai_web_search (live web search), xai_x_search (X search with handle filters, date bounds, and media-understanding flags), xai_image_generate (Grok Imagine images), xai_tts (returns base64 audio), and xai_video_generate (text-to-video or image-to-video, submitted and polled async). Slash commands like /xai-text, /xai-image, /xai-tts, and /xai-video make these reachable from the OpenCode TUI. Installation is either through npm (add the package name to the opencode.json plugin list and OpenCode installs and loads it with Bun on startup) or from source with bun install and bun run build. Authentication runs through opencode-xai-oauth login, which stores OAuth tokens at ~/.config/opencode/xai-oauth/auth.json by default, or via an XAI_API_KEY environment variable as a fallback. Release v1.1.5 added runtime token reload so expired OAuth tokens refresh during a live chat without restarting OpenCode.
Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.