cliproxyapi-cloudflare-stack

Deploys a self-hosted OpenAI-compatible LLM API gateway with credential pooling and Cloudflare tunnel exposure.

4|Updated May 16, 2026
One-click install
npx skills add https://github.com/reason-machines/devtools-skills --skill cliproxyapi-cloudflare-stack-reason-machines
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: cliproxyapi-cloudflare-stack
Source: https://github.com/reason-machines/devtools-skills/tree/main/skills/cliproxyapi-cloudflare-stack
Command: npx skills add https://github.com/reason-machines/devtools-skills --skill cliproxyapi-cloudflare-stack-reason-machines

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires wrangler, cloudflared, docker.

What problem does it solve? Running your own LLM API gateway usually requires juggling multiple provider credentials, exposing internal services securely, and handling verification emails manually. This Skill provides a complete self-hosted stack that pools credentials with automatic failover, receives verification emails via Cloudflare Workers, and exposes the gateway over HTTPS without port forwarding. ## Core Features & Use Cases - Multi-Credential Pooling: CLIProxyAPI hot-reloads JSON credential files and automatically fails over between Grok, OpenAI, and Anthropic accounts based on model prefix. - Automated Email Verification: A Cloudflare Worker with D1 database receives and stores verification codes from provider signup emails. - Zero-Port-Forwarding Exposure: Cloudflare Tunnel publishes the internal gateway at a public domain with a single OpenAI-compatible /v1 endpoint. - Use Case: A developer with several Grok and OpenAI accounts deploys the gateway on a VM, syncs credential JSON files, and points the standard OpenAI SDK at their own domain with automatic rotation when one account hits rate limits. ## Quick Start Set up a self-hosted OpenAI-compatible API gateway on my VM with Cloudflare tunnel exposure and multi-credential failover for my Grok and OpenAI accounts.

Frequently Asked Questions about cliproxyapi-cloudflare-stack

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up a self-hosted OpenAI-compatible API gateway?▼

Deploy CLIProxyAPI via the deploy_vm.sh script, which installs Docker, pulls the gateway image, generates an sk- API key, and starts the service on port 5000. Then expose it with a Cloudflare tunnel pointing to localhost:5000.

How to manage multiple LLM API keys with automatic failover?▼

Place one JSON credential file per account in the auth directory with provider, api_key, and status fields. CLIProxyAPI hot-reloads every 30 seconds and routes requests by model prefix, automatically trying the next credential when one is rate limited.

Can I use the OpenAI SDK with a self-hosted LLM proxy?▼

Yes, the gateway exposes a standard /v1 endpoint compatible with the OpenAI SDK. Set base_url to your tunnel domain and api_key to the gateway's sk- token, then call chat.completions normally, including streaming.

How do I receive verification emails programmatically with Cloudflare?▼

Deploy the included Cloudflare Worker with a D1 database binding, then configure Email Routing with a catch-all rule pointing to the worker. Incoming verification codes are stored in D1 and queryable via wrangler d1 execute.

Why does my LLM gateway return 502 Bad Gateway?▼

A 502 means the CLIProxyAPI container is down or has no active credentials. Check docker ps and docker logs for the gateway, verify JSON files exist in /opt/cpa/auth with status active, then restart the container.

What are the limitations of credential pooling for LLM APIs?▼

All pooled credentials share provider rate limits, so exhausting every account still causes failures until limits reset. You must also keep credential JSON files valid and secure, since expired keys require manual updates.