How boykopovar/grok3api works
Project type and purpose
• This is a Python client library (package name grok3api) for interacting with the Grok 3 API.
• It handles automatic cookie retrieval (via an embedded undetected Chrome driver), sends requests (text and image attachments) to Grok, parses responses (text + generated images), and optionally exposes an OpenAI-compatible HTTP server.
File structure
• Top-level files:
– Dockerfile (for containerizing the optional server)
– pyproject.toml (packaging configuration)
– README.md, LICENSE, .gitignore
– assets (example images)
– docs (English and Russian documentation)
• Core package (grok3api/):
– client.py (public API entry point: GrokClient)
– driver.py (manages HTTP requests, Cloudflare bypass, cookie retrieval)
– history.py (conversation history management)
– logger.py (logging facility)
– server.py (OpenAI-compatible REST server wrapper around GrokClient)
– types/ (data models: GrokResponse, GeneratedImage)
• tests/ (example clients, Telegram bot, unit tests)
README for additional insights
• The library automatically fetches cookies via Chrome.
• GrokClient.ask() supports text questions, image attachments, custom parameters, and returns typed responses.
• There’s an example of running a local server (server.py) that implements OpenAI’s Chat Completion API.
Summary
• Dataflow from user code to Grok via the driver and back.
• How the server module adapts the same client for HTTP.