explaingit

blockedpath/pi-xai-oauth

Analysis updated 2026-06-24

11TypeScriptAudience · developerComplexity · 2/5Setup · easy

TLDR

A plug-in for the pi CLI that adds xAI Grok as a provider using xAI's real OAuth flow, so you log in via browser instead of pasting an API key.

Mindmap

mindmap
  root((pi-xai-oauth))
    Inputs
      pi prompt
      OAuth browser login
    Outputs
      Grok responses
      Refreshed tokens
      Tool call results
    Use Cases
      Use Grok from terminal
      Multi-agent research
      Web and X search
    Tech Stack
      TypeScript
      Node
      OAuth PKCE
      xAI API
      pi CLI
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add Grok 4.3 as your default pi CLI model with one npx install command

USE CASE 2

Log into xAI with OAuth and PKCE instead of managing an API key file

USE CASE 3

Call xai_multi_agent or xai_web_search as tools from a pi session

USE CASE 4

Reuse existing Grok CLI credentials at ~/.grok/auth.json to skip a fresh login

What is it built with?

TypeScriptNodeOAuthpi

How does it compare?

blockedpath/pi-xai-oauthanousss007/ng-blatuidzmprt/csharppainkiller
Stars111111
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasymoderateeasy
Complexity2/53/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Needs the pi CLI installed plus an active SuperGrok account, tool calls count against your xAI rate limits.

In plain English

pi-xai-oauth is a plug-in for a CLI tool called pi that adds xAI's Grok model as a provider you can talk to from the command line. The point of the package is that you log into xAI with its real OAuth flow, the same one the official Grok CLI uses, instead of having to copy and paste an API key. Once installed it makes Grok 4.3 (and a couple of older Grok 4.2 variants) available as the default model, with a 1 million token context window and three reasoning depth levels: low, medium, and high. The one-line install is npx pi-xai-oauth, which runs a setup script that installs the package into pi, sets xai-auth as the default provider, sets grok-4.3 as the default model, and turns on high thinking by default. There is also a manual route: pi install npm:pi-xai-oauth followed by editing ~/.pi/agent/settings.json to set the defaults yourself. The How It Works section describes the OAuth dance. Running pi /login xai-auth starts a local HTTP server on 127.0.0.1, builds an xAI authorize URL with a PKCE challenge, opens your default browser to xAI's login page, catches the redirect after you approve, and exchanges the code for access and refresh tokens. Refresh tokens are stored and rotated automatically before they expire. The plug-in also detects existing Grok CLI credentials at ~/.grok/auth.json and offers to reuse them. If localhost callbacks are blocked (for example on a VPN, inside Docker, or over SSH), the terminal UI shows a text field where you paste the redirect URL by hand. On top of the OAuth provider, the package registers five custom tools that call the xAI API directly: xai_generate_text for plain text generation with reasoning, xai_multi_agent for deep multi-agent research with a configurable number of agents, xai_web_search for web search, xai_x_search for X (Twitter) search, and xai_code_execution for asking Grok to analyse or simulate Python code. The README is clear that these count against your SuperGrok rate limits. Usage is straightforward once authenticated: pi "some prompt", or pi --model grok-4.3 "prompt", and you can pick reasoning depth inline with a syntax like grok-4.3:high. A quick reference table summarises commands for install, update, remove, login, and listing packages.

Copy-paste prompts

Prompt 1
Walk me through the one-line npx pi-xai-oauth install and what it changes in ~/.pi/agent/settings.json
Prompt 2
Explain the OAuth PKCE flow pi-xai-oauth uses when localhost callbacks are blocked over SSH
Prompt 3
Write a pi command that runs grok-4.3 with high reasoning depth on a custom prompt
Prompt 4
Compare the five xai_* tools and pick the right one for analysing Python code with Grok

Frequently asked questions

What is pi-xai-oauth?

A plug-in for the pi CLI that adds xAI Grok as a provider using xAI's real OAuth flow, so you log in via browser instead of pasting an API key.

What language is pi-xai-oauth written in?

Mainly TypeScript. The stack also includes TypeScript, Node, OAuth.

How hard is pi-xai-oauth to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is pi-xai-oauth for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.