grok2api  by TQZHR

Grok API wrapper for multimodal AI services

Created 3 weeks ago

New!

342 stars

Top 81.1% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides a self-hostable API for Grok, enhancing the original chenyme/grok2api with features like automatic D1+KV provisioning for Cloudflare Workers and a comprehensive management panel. It targets developers and power users seeking a flexible, feature-rich solution for accessing Grok models, offering streamlined deployment via Docker or Cloudflare Workers and integrated tools for managing tokens and API keys.

How It Works

The core architecture utilizes FastAPI for the backend, with a separate TypeScript implementation for Cloudflare Workers leveraging D1 and KV storage. It supports streaming/non-streaming conversations, image generation/editing, and deep thinking capabilities. Key design choices include unified management semantics across local, Docker, and Cloudflare deployments, advanced token filtering and status checks, and an automated registration process that integrates a local Turnstile Solver.

Quick Start & Requirements

  • Primary install/run command:
    • Docker: docker compose up -d
    • Local Dev: uv sync, uv run main.py
    • Cloudflare Workers: Deploy via .github/workflows/cloudflare-workers.yml (requires CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID secrets).
  • Non-default prerequisites: Docker, Cloudflare account and API tokens, uv package manager.
  • Links: Cloudflare deployment workflow: .github/workflows/cloudflare-workers.yml.

Highlighted Details

  • Admin Panel: A web-based management interface (/login) offers comprehensive control over tokens, API keys, data centers, configuration, and cache, with full mobile adaptation.
  • Token Management: Features advanced filtering by type (SSO, SuperSSO) and status (active, invalid, out-of-quota), batch operations, and an automated registration process that includes agreeing to terms, setting age, and enabling NSFW.
  • API Key Management: Includes statistics, search, filtering, and an enhanced dialog for creating and managing API keys.
  • Model Support: Supports various grok models for chat, image generation, and video generation, with detailed usage counts and account type requirements.
  • API Compatibility: Implements OpenAI-compatible endpoints for chat completions, image generations, and image edits.

Maintenance & Community

No specific details regarding maintainers, community channels (like Discord/Slack), or roadmap are provided in the README.

Licensing & Compatibility

The project includes a disclaimer stating it is "for learning and research purposes only" and users must comply with Grok's terms and legal regulations, implying potential restrictions on commercial use. No explicit open-source license is listed.

Limitations & Caveats

Anonymous pulls from GHCR may be denied, requiring Docker login or building from source. The "一键刷新 NSFW" button is not available on the Cloudflare Workers deployment. The "learning and research" disclaimer suggests potential limitations for commercial applications. The imagine_ws_experimental image generation method is noted as experimental. Default admin credentials (admin/admin) require immediate change for production environments.

Health Check
Last Commit

5 days ago

Responsiveness

Inactive

Pull Requests (30d)
12
Issues (30d)
23
Star History
344 stars in the last 27 days

Explore Similar Projects

Starred by Pawel Garbacki Pawel Garbacki(Cofounder of Fireworks AI), Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), and
2 more.

gpt4free by xtekky

0.1%
66k
API package for multi-provider LLM requests (GPT-4.1, Gemini 2.5, Deepseek R1)
Created 2 years ago
Updated 1 day ago
Feedback? Help us improve.