# Grok2API

> Multi-account API gateway that exposes Grok Build, Grok Web, and Grok Console through OpenAI- and Anthropic-compatible APIs.

Grok2API is an open-source Go gateway with a built-in React admin console, published by chenyme under the MIT license. It manages separate account pools for Grok Build, Grok Web, and Grok Console and exposes them through unified OpenAI- and Anthropic-compatible endpoints. The latest release listed is v3.1.8.

## What It Is

Grok2API is a self-hosted API gateway and account manager. Administrators connect Grok accounts, let the gateway sync quota and model capabilities, create client keys, and then call `/v1/*` endpoints such as Responses, Chat Completions, Anthropic Messages, Images, Videos, TTS, and STT. Supported clients include Codex, Claude Code, and OpenAI- or Anthropic-compatible SDKs. The README states the project is for technical research and learning, and asks users to comply with Grok's terms of use and local laws.

## Providers and Routing

Each provider keeps its own credentials, quota, health, cooldown, concurrency, and model capabilities. Grok Build uses OAuth or Device OAuth with models discovered per account. Grok Web and Grok Console use SSO with built-in catalogs, and Web models are filtered by account tier. The Model Routes page lists provider-qualified routes. Routing features include provider pinning, sticky sessions, quota and concurrency guards, and bounded failover.

## Egress and Network Handling

The egress layer supports HTTP, SOCKS, Resin, and Trojan/VLESS/Shadowsocks/VMess tunnels, with subscriptions, probes, proxy pools, and per-scope fallback. An optional Egress Quality Guard sidecar probes nodes and can quarantine them. FlareSolverr integration can refresh Cloudflare clearance for Web and Console.

## Deployment and Operations

Official Docker images support linux/amd64 and linux/arm64. A single instance uses SQLite with in-memory runtime state. Multiple instances use PostgreSQL, Redis, and shared media storage. The admin console provides a dashboard, client keys with model allowlists and RPM, concurrency, spend, and expiry limits, audits, runtime settings, and media libraries.

## Features
- Multi-account pools for Grok Build, Web, and Console
- OpenAI-compatible Responses and Chat Completions
- Anthropic Messages API
- Image generation and editing
- Asynchronous video jobs
- TTS, STT, and Realtime proxy
- Bulk account import/export and quota sync
- Provider pinning, sticky sessions, and failover
- Client keys with RPM, concurrency, spend, and expiry limits
- Egress proxy pools with HTTP/SOCKS and tunnel protocols
- FlareSolverr Cloudflare clearance
- React admin console with audits
- SQLite or PostgreSQL with Memory or Redis storage

## Integrations
Codex, Claude Code, OpenAI-compatible SDKs, Anthropic-compatible SDKs, Docker, PostgreSQL, Redis, FlareSolverr, Resin, Nginx

## Platforms
LINUX, WEB, API, CLI

## Pricing
Open Source

## Version
v3.1.8

## Links
- Website: https://github.com/chenyme/grok2api
- Documentation: https://github.com/chenyme/grok2api/blob/main/backend/README.md
- Repository: https://github.com/chenyme/grok2api
- EveryDev.ai: https://www.everydev.ai/tools/grok2api
