SuperGrok account pool · credit-aware routing · OpenAI-compatible proxy · Imagine media · remote MCP
Turn multiple SuperGrok OAuth sessions into one local API for chat, images, videos, and agents.
- Multi-account SuperGrok OAuth — Device Code login, expired-account re-auth, CPA/Sub2API JSON import
- Credit-aware routing — Auto / Manual modes, sticky seats, failover when exhausted
- OpenAI-compatible proxy —
/v1/chat/completions,/v1/responses, live/v1/models - Imagine media APIs — image generate/edit, video generate/edit/extend/status, TTS / voices / realtime client secrets
- Media Studio console — online image/video generation, streaming AI prompt polish, MCP config panel
- Remote MCP — Streamable HTTP at
/mcpwith Bearer API key (no local checkout required) - Multi-user console — accounts, keys, usage, server-side log search, contribute/leaderboard
- Operational details — outbound proxy auto-detect, request logging, sticky
request_id → accountfor async video jobs
git clone https://github.com/aaravarr/grok-api.git
cd grok-api
npm install
npm run dev- Complete setup / login
- Add a SuperGrok account (OAuth or CPA JSON)
- Create an API key
- Call the proxy or connect MCP
curl http://127.0.0.1:8787/v1/chat/completions \
-H "Authorization: Bearer gk_your_key" \
-H "Content-Type: application/json" \
-d '{"model":"grok-4.5","messages":[{"role":"user","content":"hello"}]}'import OpenAI from "openai";
const client = new OpenAI({
apiKey: "gk_your_key",
baseURL: "http://127.0.0.1:8787/v1",
});| Route | Purpose |
|---|---|
/overview |
Usage snapshot and shortcuts |
/accounts |
SuperGrok seats, OAuth / CPA import, re-auth |
/keys |
API keys (view/copy when full secret is stored) |
/media |
Media Studio + MCP setup |
/usage |
Token / request analytics |
/logs |
Server-side searchable request logs |
/contribute |
Share seats into the pool |
/settings |
Upstream / proxy / log policy |
UI design tokens live in DESIGN.md. Contributor notes live in AGENTS.md.
| Method | Path | Notes |
|---|---|---|
POST |
/v1/chat/completions |
Chat |
POST |
/v1/responses |
Responses-compatible entry |
GET |
/v1/models |
Live upstream models |
POST |
/v1/images/generations |
Text → image |
POST |
/v1/images/edits |
Image edit |
POST |
/v1/videos/generations |
Text/image → video (async) |
POST |
/v1/videos/edits |
Video edit (async) |
POST |
/v1/videos/extensions |
Video extend (async) |
GET |
/v1/videos/:requestId |
Video status |
ALL |
/mcp |
Remote MCP |
GET |
/health |
Health check |
Optional header: x-account-id to pin a pool account.
grok-imagine-videosupports text-to-video and image-to-videogrok-imagine-video-1.5is image-to-video only- Async video jobs are sticky to the creating account via
request_id → accountmapping - Media traffic consumes SuperGrok credits
Preferred remote config:
{
"mcpServers": {
"grok-api": {
"url": "http://127.0.0.1:8787/mcp",
"headers": {
"Authorization": "Bearer gk_xxx"
}
}
}
}Tools include image/video generate, edit, extend, and status polling.
Full details: MCP.md
request → API key auth → pick account
Manual: fixed seat
Auto: healthy current, else next
→ credit check for that seat
→ OAuth bearer → api.x.ai
→ exhausted / retryable → mark + rotate (Auto)
For async video status polls, the server reuses the account that created the request_id when possible.
| Variable | Default | Description |
|---|---|---|
PORT |
8787 |
Listen port |
HOST |
127.0.0.1 |
Bind address |
DATA_DIR |
./data |
Runtime state directory |
XAI_BASE_URL |
https://api.x.ai/v1 |
Inference upstream |
HTTPS_PROXY / HTTP_PROXY |
auto | Optional outbound proxy; otherwise system proxy / Settings UI |
ADMIN_TOKEN |
empty | Optional emergency admin token for /api/admin/* |
Local state stays under data/ (accounts.json, users.json, logs, video job map). Do not commit secrets.
| Item | Behavior |
|---|---|
| New keys | Full secret can be stored for redisplay / Media Studio / MCP config |
| Legacy keys | Hash/prefix only → paste full secret or create a new key |
| Auth header | Authorization: Bearer gk_... on /v1/* and /mcp |
npm run dev # hot reload
npm run start # normal local server
npm run typecheck # tsc --noEmit
npm run build # compileAfter code changes to a non-watch process, restart the local server.
Unofficial · not affiliated with xAI · respect their ToS · credentials stay local.