explaingit

islee23520/opencode-xai-oauth

12TypeScriptAudience · vibe coderComplexity · 3/5ActiveSetup · moderate

TLDR

Unofficial OpenCode plugin that adds xAI OAuth login plus tools for Grok text, web and X search, image, TTS, and video generation, with reasoning-effort variants for grok-4.3.

Mindmap

mindmap
  root((opencode-xai-oauth))
    Inputs
      xAI OAuth tokens
      API key fallback
      User prompts
    Outputs
      Grok text replies
      Generated images
      TTS audio
      Generated video
    Use Cases
      Login to xAI from OpenCode
      Run Grok with reasoning effort
      Search X from the TUI
    Tech Stack
      TypeScript
      Bun
      OpenCode
      OAuth

Things people build with this

USE CASE 1

Log into xAI Grok from OpenCode using a personal OAuth flow

USE CASE 2

Call Grok image, TTS, and video generation from the OpenCode TUI

USE CASE 3

Run X search with handle filters and date bounds from a coding session

USE CASE 4

Pick low, medium, or high reasoning effort for grok-4.3 queries

Tech stack

TypeScriptBunOpenCodeOAuthNode.js

Getting it running

Difficulty · moderate Time to first run · 30min

Unofficial OAuth flow for personal use only; xAI ToS applies and the author recommends the official API for production.

In plain English

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.

Copy-paste prompts

Prompt 1
Add opencode-xai-oauth to my opencode.json plugin list and run opencode auth login to authenticate against xAI.
Prompt 2
Use the /xai-image slash command from opencode-xai-oauth to generate three Grok Imagine variants from a prompt I will provide.
Prompt 3
Switch my grok-4.3 calls in opencode-xai-oauth to high reasoning effort and explain how the metadata flags it as reasoning-capable.
Prompt 4
Run xai_x_search through opencode-xai-oauth with a handle filter and a one-week date range, then summarize the results.
Prompt 5
Build opencode-xai-oauth from source with bun install and bun run build and link it as a local OpenCode plugin.
Open on GitHub → Explain another repo

Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.