A lightweight, high-performance HTTP reverse proxy for the WordPress.com AI API.
Enables local AI coding tools (Claude Code, Cline, Cursor, Aider) to route through WordPress.com's AI infrastructure with credential rotation, session isolation, and SSE streaming support.
⚠️ Note: Requires active WordPress.com account(s) with AI feature access. Monthly token quotas apply per account.
wpcom-ai acts as a local gateway between AI coding clients and the WordPress.com AI proxy endpoint. It:
- Normalizes payloads — flattens array system prompts, strips unsupported fields (
thinking,metadata,context_management,output_config) that cause upstream 400/403 errors - Routes to correct models — maps any request to
claude-sonnet-5orclaude-opus-5automatically - Rotates credentials — round-robin account pool with cooldown and auto-recovery on rate limits
- Streams responses — zero-allocation SSE passthrough for real-time token streaming
- Supports agentic coding —
toolsandtool_choiceare preserved and forwarded for full Claude Code CLI compatibility
| Model | ID |
|---|---|
| Claude Sonnet 5 | claude-sonnet-5 |
| Claude Opus 5 | claude-opus-5 |
Edit config.yaml:
accounts:
tokens:
- "Bearer YOUR_WPCOM_TOKEN_HERE"
server:
port: 8085
upstream_url: "https://public-api.wordpress.com/wpcom/v2/ai-api-proxy/v1/messages"go run cmd/gateway/main.goGateway starts on http://127.0.0.1:8085.
Claude Code CLI:
claude config set apiBaseUrl http://127.0.0.1:8085
claude config set apiKey "Bearer YOUR_GATEWAY_TOKEN"Claude Code CLI / Cline / Cursor
│
▼
wpcom-ai Gateway (127.0.0.1:8085)
│ • Payload normalization
│ • Account rotation
│ • SSE streaming
▼
WordPress.com AI Proxy
│
▼
Anthropic Claude API
- Token quotas are per WordPress.com account per month — scaling requires multiple accounts
thinking(extended reasoning) mode is not supported by the upstream proxy- Only
claude-sonnet-5andclaude-opus-5models are available
- Language: Go 1.21+
- Key libraries:
tidwall/gjson,tidwall/sjson,google/uuid - Observability:
log/slogstructured JSON logging, Prometheus metrics (/metrics) - Health check:
/healthendpoint
MIT