Why I Built This
If you're already paying for Claude Code (Max plan), you have access to an incredibly powerful AI right in your terminal. I wanted to get more out of that subscription β use it from my web apps, Slack bots, CI pipelines, and Python scripts running on other machines.
Anthropic does have an official API, but it's pay-per-token β a separate cost. Since I'm already paying for a subscription, I figured: why not use what I've got?
There are some great open-source wrappers like coder/agentapi and claude-code-api, but they're designed for local use only. I needed something that works remotely too β without having to set up reverse proxies, TLS certificates, and authentication from scratch.
What It Does
claude-api-bridge lets you use your existing Claude Code subscription as a REST API, accessible from anywhere.
One command. That's it.
npx claude-api-bridge start
And you get:
β
Claude Code CLI detected
π API server running on http://localhost:3456
π Admin Token: cab-a1b2c3d4e5f6...
π Public URL: https://random-words.trycloudflare.com
Now you have a real HTTPS endpoint that you can call from any app, anywhere in the world.
How It Works
Your App (anywhere on the internet)
β
β HTTPS
βΌ
Cloudflare Tunnel (automatic SSL, zero config)
β
βΌ
claude-api-bridge (your desktop)
ββ Token Authentication (SHA256)
ββ Request Queue
ββ Claude Code CLI (your subscription)
Your desktop becomes the API server. Claude Code runs locally using your existing subscription. Cloudflare Tunnel handles the networking β no port forwarding, no ngrok, no reverse proxy setup.
Key Features
| Feature | Details |
|---|---|
| π One-command setup | No config files, no environment variables |
| π Remote access | Cloudflare Tunnel with automatic HTTPS |
| π Token management | Create, revoke, expire. SHA256 hashed β never stored in plaintext |
| π¬ Session modes | Stateless (fresh each time) or Stateful (conversation memory) |
| π Web dashboard | Monitor at /dashboard
|
| π Secure | Rate limiting, CSP headers, execution timeout, output size limits |
| πΎ Zero dependencies | SQLite for storage β no Redis, no Postgres |
Quick Example
Python
import requests, time
BASE = "https://your-url.trycloudflare.com"
TOKEN = "cab-your-token"
H = {"Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json"}
def ask(msg):
r = requests.post(f"{BASE}/api/ask", json={"message": msg}, headers=H)
rid = r.json()["requestId"]
while True:
p = requests.get(f"{BASE}/api/ask/{rid}", headers=H).json()
if p["status"] == "completed": return p["response"]
time.sleep(2)
print(ask("Write a function to check if a number is prime"))
JavaScript
async function askClaude(message) {
const res = await fetch(`${BASE_URL}/api/ask`, {
method: "POST",
headers: { Authorization: `Bearer ${TOKEN}`, "Content-Type": "application/json" },
body: JSON.stringify({ message }),
});
const { requestId } = await res.json();
while (true) {
const poll = await fetch(`${BASE_URL}/api/ask/${requestId}`, {
headers: { Authorization: `Bearer ${TOKEN}` },
});
const data = await poll.json();
if (data.status === "completed") return data.response;
await new Promise(r => setTimeout(r, 2000));
}
}
How It Compares
| Feature | claude-api-bridge | coder/agentapi | claude-code-api |
|---|---|---|---|
| Remote access (HTTPS) | β Built-in | β Local only | β Local only |
| Token management | β Full CRUD | β None | β οΈ Static keys |
| Token security | β SHA256 hash | β N/A | β Plaintext |
| Session persistence | β SQLite | β In-memory | β οΈ In-memory |
| Crash recovery | β Auto | β No | β No |
| Zero config | β One command | β One command | β οΈ Config needed |
Limitations (Being Honest)
- Your desktop must be running β Claude CLI executes on your machine
- One request at a time β Claude CLI is single-threaded, requests are queued
- Free tunnel URL changes on restart β use a Cloudflare account for a fixed domain
- Response time varies β typically 10 seconds to 2 minutes depending on the task
Try It
npx claude-api-bridge start
GitHub: github.com/smy383/claude-api-bridge
npm: npmjs.com/package/claude-api-bridge
Star β if you find it useful!
Built by the team behind ttapp β the mobile remote for Claude Code.
Top comments (0)