grokcli-2api  by HM2899

Grok API proxy for OpenAI and Anthropic compatibility

Created 2 weeks ago

New!

452 stars

Top 65.9% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides a proxy service that translates Grok AI's OIDC authentication into OpenAI and Anthropic compatible API endpoints. It targets developers and power users needing to integrate Grok AI into existing applications or workflows that expect standard API formats, offering benefits like simplified multi-account management and enhanced usability.

How It Works

The system employs a FastAPI backend with a multi-worker architecture, utilizing PostgreSQL for persistent storage of accounts, keys, and settings, and Redis for managing hot states like session stickiness and caching. It intercepts Grok OIDC sessions, converts them into compatible API calls, and manages multiple accounts through various polling strategies (round-robin, least-used, random) with intelligent cooling and load balancing for in-flight requests. Key features include session stickiness, prompt caching, and a web management console for administration.

Quick Start & Requirements

The recommended installation method is via Docker Compose. Clone the repository, copy the .env.example to .env, configure essential environment variables (e.g., GROK2API_ADMIN_PASSWORD, PostgreSQL credentials), and run docker compose up -d --build. Prerequisites include Docker, Docker Compose, and a Grok account. The system requires PostgreSQL and Redis, which are managed internally by Docker Compose.

Highlighted Details

  • API Compatibility: Offers full compatibility with OpenAI (/v1/chat/completions, /v1/models, SSE) and Anthropic (/v1/messages, tools/tool_use) API specifications.
  • Multi-Account Management: Advanced polling strategies with intelligent cooling, expiration handling, and in-flight request load balancing.
  • Session Stickiness & Prompt Caching: Implements mechanisms to maintain session continuity and leverage prompt caching for performance.
  • Web Management Console: A comprehensive UI for managing accounts, API keys, protocol registrations, monitoring usage, and system settings.
  • Protocol Registration: Built-in engine for registering services requiring temporary emails and CAPTCHA solving.
  • Observability: Detailed usage metrics (TTFT, latency, reasoning effort), task logging, and stream reliability features.
  • CLIProxyAPI Sync: Synchronizes local account pools with CLIProxyAPI's auth directory.

Maintenance & Community

The project is maintained by HM2899. Specific details regarding community channels (like Discord/Slack), notable contributors, or sponsorships are not provided in the README snippet.

Licensing & Compatibility

The README indicates a LICENSE file exists within the repository, but the specific license type and its terms are not detailed in the provided text. Compatibility for commercial use is implied, but users must adhere to xAI's service terms for automated registration and account usage.

Limitations & Caveats

The specific license is not detailed, which may pose an adoption risk. Protocol registration relies on external CAPTCHA services or an inline solver, adding complexity. Sensitive credentials can be exported, requiring careful handling. The project's utility is dependent on the availability and terms of Grok AI. Configuration requires understanding Docker Compose networking and environment variables.

Health Check
Last Commit

6 days ago

Responsiveness

Inactive

Pull Requests (30d)
9
Issues (30d)
9
Star History
460 stars in the last 18 days

Explore Similar Projects

Feedback? Help us improve.