# grok2api | Chenyme | Knowledge Base | Instagit

面向 Grok Build、Grok Web 与 Grok Console 的多账号 API 网关

GitHub Stars: 6k

Repository: https://github.com/chenyme/grok2api

---

## Articles

### [How to Migrate Accounts from the Legacy Python Version of Grok to Grok2API](/chenyme/grok2api/how-to-migrate-accounts-from-legacy-python-version-of-grok)

Migrate accounts from legacy Python Grok to Grok2API by exporting SSO tokens to a file and importing via the HTTP endpoint. Deduplicate entries and sync metadata automatically.

- Tags: migration-guide
- Published: 2026-08-09

### [Grok config.yaml Configuration Options: Complete Reference for chenyme/grok2api](/chenyme/grok2api/what-configuration-options-are-available-in-groks-config.yaml)

Explore Grok config.yaml options for server, auth, database, and more. Get a complete reference for chenyme/grok2api configuration settings to optimize your setup.

- Tags: api-reference
- Published: 2026-08-09

### [Asynchronous Video Job Processing in Grok: Architecture and Implementation](/chenyme/grok2api/explain-asynchronous-video-job-processing-in-grok)

Discover Grok's asynchronous video job processing architecture. Learn how clients submit requests, poll for completion, and retrieve content while background workers handle rendering.

- Tags: architecture
- Published: 2026-08-09

### [How Quota and Concurrency Guards Protect Upstream Accounts in Grok](/chenyme/grok2api/how-do-quota-and-concurrency-guards-protect-upstream-accounts-in-grok)

Grok uses quota and concurrency guards to protect upstream accounts. Learn how these features prevent resource exhaustion and ensure reliable service by limiting usage and simultaneous requests.

- Tags: deep-dive
- Published: 2026-08-09

### [How to Debug Grok Egress Connection Failures and Transport Errors](/chenyme/grok2api/how-to-debug-grok-egress-connection-failures-and-transport-errors)

Debug Grok egress connection failures and transport errors by inspecting API JSON, using neterror helpers, and verifying node health metrics. Resolve your Grok issues efficiently.

- Tags: how-to-guide
- Published: 2026-08-09

### [How Sticky Session Routing Preserves Client Session Continuity in Grok](/chenyme/grok2api/how-does-sticky-session-routing-preserve-client-session-continuity-in-grok)

Learn how Grok's sticky session routing maintains client session continuity by binding clients to specific backend nodes using an affinity key for a set duration. Ensure seamless user experiences.

- Tags: deep-dive
- Published: 2026-08-09

### [How the Grok Audit Service Tracks Usage and Client Billing in chenyme/grok2api](/chenyme/grok2api/how-does-grok-audit-service-track-usage-and-client-billing)

Learn how the Grok audit service tracks usage and client billing in chenyme/grok2api using SQLite audit records and fixed-point USD ticks for accurate pricing.

- Tags: how-to-guide
- Published: 2026-08-09

### [How to Configure Media Storage, Archival, and Retrieval in Grok](/chenyme/grok2api/how-to-configure-media-storage-archival-and-retrieval-in-grok)

Configure media storage, archival, and retrieval in Grok using its three-layer subsystem. Learn about YAML drivers, metadata management, and HTTP endpoints for efficient media handling.

- Tags: how-to-guide
- Published: 2026-08-09

### [Grok API Endpoints for Responses, Chat, Messages, Images, and Videos: A Complete Technical Guide](/chenyme/grok2api/grok-api-endpoints-for-responses-chat-messages-images-and-videos)

Explore Grok API endpoints for text responses, chat, messages, image generation, and video jobs. This guide details OpenAI-compatible endpoints for Grok2API, enabling seamless integration with your applications.

- Tags: deep-dive
- Published: 2026-08-09

### [How Bounded Failover Works in a Grok Provider: Mechanism and Implementation](/chenyme/grok2api/how-does-bounded-failover-work-within-grok-provider)

Discover how bounded failover in Grok provider caps request retries, reroutes to fresh credentials, and prevents infinite loops. Learn the mechanism and implementation.

- Tags: internals
- Published: 2026-08-09

### [Grok Egress Manager Architecture and Scopes: Deep Dive into chenyme/grok2api](/chenyme/grok2api/what-is-architecture-of-grok-egress-manager-and-its-scopes)

Explore the Grok egress manager architecture and scopes in chenyme/grok2api. Understand its multi-layered design, proxy orchestration, and five scopes: Build, Web, Console, WebAsset, and ConsoleAsset.

- Tags: deep-dive
- Published: 2026-08-09

### [How to Configure Egress Proxy Pools with Fallback and Balancing in Grok2API](/chenyme/grok2api/how-to-configure-egress-proxy-pools-with-fallback-and-balancing)

Configure egress proxy pools with fallback and balancing in Grok2API. Optimize traffic distribution and prevent cascade failures with smart routing policies.

- Tags: how-to-guide
- Published: 2026-08-09

### [How the Grok Gateway Performs Dynamic Model Discovery Per Account](/chenyme/grok2api/how-does-grok-gateway-perform-dynamic-model-discovery-per-account)

Discover how the Grok gateway dynamically discovers models per account. Learn about generated routes and idempotent discovery using a partial unique index.

- Tags: internals
- Published: 2026-08-09

### [Security Best Practices for Grok Production Deployments](/chenyme/grok2api/what-are-security-best-practices-for-grok-production-deployments)

Secure your chenyme/grok2api production deployment with best practices. Learn to implement short-lived JWT tokens, AES-256-GCM encryption, and hardened configuration for robust security.

- Tags: best-practices
- Published: 2026-08-09

### [How to Configure FlareSolverr for Cloudflare Clearance in Grok Web/Console](/chenyme/grok2api/how-to-configure-flaresolverr-for-cloudflare-clearance-in-grok-web-console)

Learn how to configure FlareSolverr for Cloudflare clearance in Grok Web/Console. Get automatic cf_clearance and __cf_bm cookies for seamless access.

- Tags: how-to-guide
- Published: 2026-08-09

### [How Stored Responses and Session Compaction Work in the Grok Gateway](/chenyme/grok2api/how-do-stored-responses-and-session-compaction-work-in-grok-gateway)

Discover how Grok gateway uses stored responses and session compaction to optimize API performance. Learn about LRU caching and merging entries to eliminate duplicates and refresh TTLs.

- Tags: internals
- Published: 2026-08-09

### [How to Configure Client Keys with Model Allowlists and Rate Limits in Grok2API](/chenyme/grok2api/configure-client-keys-with-model-allowlists-and-rate-limits)

Learn how to configure client keys with model allowlists and rate limits in Grok2API. Control access with RPM and concurrency limits for secure API management.

- Tags: how-to-guide
- Published: 2026-08-09

### [How Account Linking Works Between Grok Web, Build, and Console in grok2api](/chenyme/grok2api/how-does-account-linking-work-between-grok-web-build-and-console)

Discover how Grok Web, Build, and Console accounts link using association tables and PostgreSQL advisory locks for consistent cross-provider operations.

- Tags: internals
- Published: 2026-08-09

### [Grok Build vs Web vs Console Provider Implementations: Key Differences in Grok2API](/chenyme/grok2api/key-differences-between-grok-build-web-and-console-provider-implementations)

Explore Grok Build vs Web vs Console provider differences in Grok2API. Understand token CLI, session cookies, and OAuth authentication for optimal API interaction.

- Tags: deep-dive
- Published: 2026-08-09

### [How to Set Up and Configure Egress Quality Guard for Active Node Monitoring in Grok2API](/chenyme/grok2api/how-to-set-up-and-configure-egress-quality-guard-for-active-node-monitoring)

Configure Egress Quality Guard for active node monitoring in Grok2API. Automatically quarantine underperforming nodes to ensure optimal latency throughput and output quality without manual intervention.

- Tags: how-to-guide
- Published: 2026-08-09

### [Prompt Cache Affinity in Grok2API: How It Works with Codex and Claude Code](/chenyme/grok2api/what-is-prompt-cache-affinity-and-how-does-it-work-with-codex-and-claude-code)

Discover prompt cache affinity in Grok2API. Learn how this session-binding mechanism ensures deterministic prompt reuse across Codex and Claude Code for improved performance.

- Tags: deep-dive
- Published: 2026-08-09

### [How to Configure PostgreSQL and Redis for Multi-Instance Grok Deployment](/chenyme/grok2api/how-to-configure-postgresql-and-redis-for-multi-instance-grok-deployment)

Deploy Grok2API in multi-instance mode by configuring PostgreSQL and Redis. Learn how to set up unique instance IDs and shared media storage for a successful deployment.

- Tags: how-to-guide
- Published: 2026-08-09

### [Immediate Egress Failure Probe and Bounded Retry Mechanism in Grok2API](/chenyme/grok2api/explain-immediate-egress-failure-probe-and-bounded-retry-mechanism)

Understand Grok2API's immediate egress failure probe and bounded retry mechanism. Rapidly validate proxy health and prevent resource exhaustion with on-demand checks and limited concurrent operations.

- Tags: internals
- Published: 2026-08-09

### [How the Grok Provider Registry Routes Requests: Architecture and Implementation](/chenyme/grok2api/how-does-provider-registry-route-requests-in-grok)

Discover how the Grok provider registry routes requests via a type-safe lookup system, mapping credentials to adapters, validating operations, and dispatching to upstream implementations.

- Tags: architecture
- Published: 2026-08-09

### [What Is the Provider Registry in Grok2API? Architecture, Implementation, and Usage](/chenyme/grok2api/role-provider-registry-grok2api-architecture)

Discover the Provider Registry in Grok2API. Learn how it catalogs provider metadata and adapter implementations to enable runtime capability discovery and request routing.

- Tags: architecture
- Published: 2026-07-16

### [Grok Web vs Grok Console SSO Authentication: What’s the Difference in Grok2API](/chenyme/grok2api/grok-web-vs-grok-console-sso-authentication)

Understand Grok Web vs Grok Console SSO authentication differences in Grok2API. Learn how browser tokens compare to dashboard tokens for API functionality.

- Tags: deep-dive
- Published: 2026-07-16

### [How to Enable and Configure the Admin Dashboard in Grok2API](/chenyme/grok2api/enable-configure-admin-dashboard-grok2api)

Learn how to enable and configure the admin dashboard in Grok2API. Secure routes, authenticate, and access dashboard data with our easy-to-follow guide.

- Tags: how-to-guide
- Published: 2026-07-16

### [How Cooldown Periods Drive Provider Failover in Grok2API](/chenyme/grok2api/grok2api-cooldown-periods-provider-failover)

Discover how cooldown periods in Grok2API enable provider failover by temporarily removing failing providers, ensuring automatic routing to healthy accounts and preventing retry loops.

- Tags: internals
- Published: 2026-07-16

### [How to Integrate Grok2API with an Existing Application: Complete Technical Guide](/chenyme/grok2api/integrate-grok2api-existing-application)

Learn to integrate Grok2API with your application. This guide covers server setup, JWT authentication, and consuming RESTful endpoints for inference and media handling. Get started today.

- Tags: how-to-guide
- Published: 2026-07-16

### [How Grok2API Implements Account Pooling for Different Grok Providers](/chenyme/grok2api/grok2api-account-pooling-grok-providers)

Learn how Grok2API uses account pooling with dedicated batch.Pool instances to manage resources across Build, Web, and Console providers, ensuring fair concurrency and throttling.

- Tags: how-to-guide
- Published: 2026-07-16

### [Grok2API Media Storage Support: Local Filesystem Implementation Explained](/chenyme/grok2api/grok2api-media-storage-options)

Grok2API supports local filesystem media storage, including JPEG, PNG, WebP, and GIF. Learn about its implementation with atomic writes and path traversal protection.

- Tags: deep-dive
- Published: 2026-07-16

### [How to Use the Grok2API Chat Completions Endpoint](/chenyme/grok2api/how-to-use-grok2api-chat-completions-endpoint)

Learn to use the Grok2API Chat Completions endpoint. Send POST requests to get OpenAI-compatible chat responses from Grok's powerful models.

- Tags: how-to-guide
- Published: 2026-07-16

### [Security Implications of the credentialEncryptionKey in Grok2API](/chenyme/grok2api/security-implications-credentialencryptionkey-grok2api)

Discover the security implications of the credentialEncryptionKey in Grok2API. Learn how this key protects OAuth credentials and what happens if it's exposed.

- Tags: security
- Published: 2026-07-16

### [How Grok2API Handles Account Failover Between Provider Accounts](/chenyme/grok2api/grok2api-failover-provider-accounts)

Learn how Grok2API ensures high availability by handling account failover. Discover its pre-response mechanism for seamless switching on 401 or 403 errors.

- Tags: internals
- Published: 2026-07-16

### [How to Set Up Grok2API for Local Development with SQLite](/chenyme/grok2api/setup-grok2api-local-development-sqlite)

Easily set up Grok2API for local development with SQLite. Configure your API to use SQLite with a simple change in config yaml for a dependency-free local environment.

- Tags: how-to-guide
- Published: 2026-07-16

### [How Grok2API Manages Concurrency Limits Per Account: Architecture and Implementation](/chenyme/grok2api/grok2api-concurrency-limits-per-account)

Discover how Grok2API manages concurrency limits per account using its ConcurrencyLimiter interface with Redis Lua scripts or in-memory maps for efficient lease acquisition.

- Tags: architecture
- Published: 2026-07-16

### [Supported Database Drivers for Grok2API Persistence: SQLite and PostgreSQL Explained](/chenyme/grok2api/grok2api-database-drivers-persistence)

Explore Grok2API's supported database persistence drivers: SQLite and PostgreSQL. Learn how to configure your database for seamless integration with the Grok2API repository. Optimize your data storage now.

- Tags: api-reference
- Published: 2026-07-16

### [What Is the Log Masking Feature in Grok2API? Implementation and Usage Guide](/chenyme/grok2api/grok2api-log-masking-feature)

Discover Grok2API's log masking feature. Learn how it automatically redacts sensitive data from logs by intercepting and replacing matching values with masked strings.

- Tags: how-to-guide
- Published: 2026-07-16

### [How to Configure Grok2API to Use Redis as Its Runtime Store](/chenyme/grok2api/configure-grok2api-redis-runtime-store)

Configure Grok2API to use Redis as its runtime store by updating config yaml. Learn how to connect and enable distributed state for your gateway instances.

- Tags: how-to-guide
- Published: 2026-07-16

### [How Grok2API Handles Session Sticky with a Custom TTL: Implementation Guide](/chenyme/grok2api/grok2api-session-sticky-custom-ttl)

Learn how Grok2API handles session sticky with a custom TTL, ensuring consistent routing by binding requests to credential IDs with configurable expiry times. Get the implementation guide.

- Tags: how-to-guide
- Published: 2026-07-16

### [Authentication Methods for Grok Build Provider in Grok2API: OAuth 2.0 Implementation Guide](/chenyme/grok2api/grok-build-provider-authentication-methods)

Explore Grok2API authentication for Grok Build provider. Learn about OAuth 2.0 authorization code and device flows. Master token refresh for secure access.

- Tags: how-to-guide
- Published: 2026-07-16

