Skip to content

Repository files navigation

wpcom-ai

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.


What it does

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-5 or claude-opus-5 automatically
  • 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 codingtools and tool_choice are preserved and forwarded for full Claude Code CLI compatibility

Supported Models

Model ID
Claude Sonnet 5 claude-sonnet-5
Claude Opus 5 claude-opus-5

Quick Start

1. Configure accounts

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"

2. Run the gateway

go run cmd/gateway/main.go

Gateway starts on http://127.0.0.1:8085.

3. Point your AI tool at the gateway

Claude Code CLI:

claude config set apiBaseUrl http://127.0.0.1:8085
claude config set apiKey "Bearer YOUR_GATEWAY_TOKEN"

Architecture

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

Limitations

  • 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-5 and claude-opus-5 models are available

Tech Stack

  • Language: Go 1.21+
  • Key libraries: tidwall/gjson, tidwall/sjson, google/uuid
  • Observability: log/slog structured JSON logging, Prometheus metrics (/metrics)
  • Health check: /health endpoint

License

MIT

About

HTTP reverse proxy for WordPress.com AI API — enables Claude Code CLI and other AI tools to use WordPress.com's Claude infrastructure with multi-account rotation and zero-allocation SSE streaming.

Topics

Resources

Code of conduct

Security policy

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages