OpenAI-compatible
Chat Completions, Responses, Anthropic Messages — point existing SDKs at your local gateway.
Turn local Grok CLI (grok -p headless) into a production
OpenAI-compatible HTTP API. CLI: gctoac / gcoa, default port 3847.
Turn local Grok into a production OpenAI-compatible gateway — architecture, APIs, Admin, queue, and security at a glance.
grok -p headlessClient (OpenAI SDK / curl / Open WebUI)
│ Authorization: Bearer gk_live_...
▼
Express Gateway :3847
· auth · rate limit · safe/agent
· enqueue ChatJob (AES-GCM) · SSE gog.queue
· proxy-aware client IP · auto-ban
· encrypted audit · Admin /admin
│
▼
In-process worker (lease / fair poll / concurrency)
│
▼
grok -p … (local Grok CLI)
Chat Completions, Responses, Anthropic Messages — point existing SDKs at your local gateway.
AES-256-GCM for prompts, responses, files, and queue payloads; API keys stored as scrypt hashes.
At-least-once, fair polling, backpressure, and dead-letter; recover in-flight jobs after restart.
Rate limits, auto-ban, blacklist, reverse-proxy IP sources — production-grade abuse protection.
| Feature | Details |
|---|---|
| OpenAI API | POST /v1/chat/completions, POST /v1/responses, GET /v1/models |
| Anthropic API | POST /v1/messages (Bearer or x-api-key) |
| Thinking | reasoning_content + Grok thought + grok.* meta |
| Documents | Type-sniff upload, encrypted storage, download |
| Safe / Agent | Per-key policy; optional global force-safe |
| Encryption | AES-256-GCM for prompts, responses, files, queue payloads |
| Admin Panel | OTP login; queue / media / system / PM2 / DDoS / API capabilities |
| Media library | Generate / edit / image-to-video, assets & jobs, lightbox preview |
| Chat queue | SQLite jobs, fair poll, pause/drain, dead-letter, Idempotency-Key |
| DDoS center | Live connections, blacklist, auto-ban, presets, reverse-proxy IP |
| CLI | Lifecycle, settings, queue, ddos, keys, docs, chats, stats, admin otp |
| Ops | SQLite, PM2, log trim (>5MB), self-update |
Endpoints, capability matrix, Thinking mapping, and Safe / Agent policy.
GET /health liveness; GET /ready DB + Grok; GET /v1/modelsPOST /v1/chat/completions (queued; optional Idempotency-Key); stream may emit gog.queue then OpenAI chunksPOST /v1/responses text subset; POST /v1/messages Anthropic-style/v1/documents upload / list / soft-delete; Admin keys /v1/api-keysAuthorization: Bearer gk_live_…include_reasoning, cwd (agent only), session_id, document_ids| Capability | Chat | Responses | Anthropic | Admin switch |
|---|---|---|---|---|
| Text + stream | ✅ | ✅ | ✅ | Protocol toggles |
| Vision / images | ✅ | ✅ | ✅ | vision |
| Images generations + edits | ✅ | — | — | imagesApi + agent |
Files /v1/files | ✅ | — | — | filesOpenAiAlias |
| Videos async | ✅ mock | — | — | videoApi |
| Audio speech / transcriptions | ✅ mock / 503 | — | — | audioApi |
| Tools / tool_use | ✅ | ✅ | ✅ | tools |
| JSON schema | ✅ | ✅ | passthrough | structuredOutput |
| Reasoning effort | ✅ | ✅ | thinking→effort | reasoningEffort |
| Assistants-lite | — | — | — | assistantsEmulation |
Not claimed: full official cloud parity (embeddings / realtime need separate backends). Grok CLI has no temperature-style sampling knobs; optional strictSampling rejects those params.
thought → reasoning_content / stream deltatext → content; end → finish_reason + grok.sessionId / stopReasoninclude_reasoning: trueGROK_SAFE_MODE=true or Admin security settingsOTP-gated ops panel — chat, keys, media, queue, DDoS, PM2, and system status.
gctoac admin otp (5-minute one-shot); session ~12h; can disable panel and re-enable via CLI admin onEncryption, keys, documents, durable queue, DDoS, and security notes.
gctoac key create|list|show|update|revoke|activatedocument_idsQUEUE_BACKEND=sqlite (redis / kafka reserved).env; never leak OTP / admin keygctoac / gcoa lifecycle, hot policy reload, and production deployment notes.
gctoac / gcoagrok loginnpm i -g github:…)/v1, Admin /admin/, health; change PORT and sync CORS / Admin URL~/.gctoac/ (GCTOAC_HOME / --home)Real Admin UI previews and a four-step launch path.

24h KPIs, queue depth, keys / media, recent API chats, Safety summary.

Multi-turn chat, reasoning, attachments, history.

Per-model / per-key stats and gateway rate-limit summary.

Policy, traffic, blacklist, reverse-proxy IP.

Pause / drain, dead-letter, concurrency and fairness.

gctoac detached ↔ PM2, port 3847.

Node / Grok CLI / PM2 health and one-click update.
npm install -g grok-cli-to-openai-compatible
gctoac doctor && gctoac setup && gctoac start
gctoac admin otp
gctoac key create
# http://127.0.0.1:3847/v1
MIT open source · YSK Limited. Turn local Grok into a production OpenAI-compatible gateway.