explaingit

yforc/consolex2api

11PythonAudience · developerComplexity · 3/5Setup · moderate

TLDR

A Python gateway that wraps xAI's console.x.ai so any tool built for the OpenAI API can talk to Grok models instead, with a multi-account pool and a browser-based admin dashboard to manage accounts.

Mindmap

mindmap
  root((consolex2api))
    What it does
      OpenAI-compatible API
      Routes to Grok models
      Multi-account pooling
    Endpoints
      Chat completions
      Responses API
      Real-time voice
    Account Pool
      SQLite database
      SSO token storage
      Enable or disable accounts
    Admin Dashboard
      Import accounts
      Filter by status
      Configure settings
    Deployment
      Python direct run
      Docker Compose
      Environment file
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

Things people build with this

USE CASE 1

Point an existing OpenAI API script or tool at Grok models without modifying any code.

USE CASE 2

Distribute traffic across multiple xAI accounts to stay within per-account rate limits.

USE CASE 3

Use real-time voice with Grok models through a WebSocket connection that passes audio in both directions.

USE CASE 4

Self-host an OpenAI-compatible API endpoint backed by Grok with a browser dashboard for account management.

Tech stack

PythonSQLiteDockerFastAPI

Getting it running

Difficulty · moderate Time to first run · 30min

Requires xAI console.x.ai SSO tokens for each account you want to add to the pool, imported through the admin dashboard or a text file.

In plain English

ConsoleX2API is a Python gateway that wraps xAI's console.x.ai platform so it behaves like an OpenAI-compatible API. Many AI tools, scripts, and applications are built to talk to OpenAI's API format. This project lets those same tools connect to Grok models through the console.x.ai backend without changing the tool itself. The gateway accepts standard API requests in the OpenAI format for chat completions, responses, and real-time voice, then translates and forwards them to console.x.ai upstream. It preserves parameters like tool use and reasoning effort that the upstream supports. Image inputs in the OpenAI format are automatically converted to the format the upstream expects. Real-time voice is supported through a WebSocket connection that passes audio data in both directions. A key feature is the multi-account pool. console.x.ai uses SSO login sessions, and each account belongs to a team. This gateway stores multiple accounts in a local SQLite database, each with its own team ID, so traffic can be spread across them. You import accounts through a browser-based admin dashboard or a text file, one account per line with its SSO token and team ID. The dashboard also lets you enable or disable individual accounts, filter by account status, and configure settings like proxy address, model list, and default generation parameters. Deployment options include running it directly with Python or using Docker Compose, which handles the SQLite database as a persistent volume. Configuration is done through an environment file where you set your gateway API key, admin key, and upstream proxy if needed. The project is written in Chinese and the README is in Chinese, though an English README is also linked from the project. It does not support image or video generation endpoints, only the chat and voice interfaces.

Copy-paste prompts

Prompt 1
Help me deploy consolex2api with Docker Compose and add my xAI SSO token so I can point an OpenAI SDK client at Grok.
Prompt 2
Show me how to import multiple xAI accounts into consolex2api using the text-file format so requests are spread across them.
Prompt 3
Rewrite this Python script that calls openai.ChatCompletion.create to route through my consolex2api gateway to Grok with no other changes.
Prompt 4
How does consolex2api decide which account in the pool to route a request to, and how do I check per-account usage from the dashboard?
Prompt 5
Walk me through accessing the consolex2api admin dashboard, adding an account via the browser, and verifying it is active.
Open on GitHub → Explain another repo

← yforc on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.