Skip to content

cjinghong/claudeclaude

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClaudesClaude

Problem

You're building a local web app that needs LLM API access. But paying per-token through the Anthropic API adds up fast — especially for hobby projects, prototyping, or personal tools where you're iterating constantly. You're already paying for a Claude Pro/Max subscription, but there's no way to use it programmatically.

Solution

ClaudesClaude is a local API proxy that mirrors the Anthropic Messages API — but routes requests through your existing Claude subscription instead of the paid API. Your code talks to localhost:3456 using the same Anthropic SDK and request format it already uses. Just swap the baseURL and you're done. No API keys, no per-token billing.

Screen.Recording.2026-03-18.at.2.01.32.AM.mov

Two modes:

Mode Command Speed Requires
CLI tunnel (default) npx claudesclaude ~3-5s per request Claude Code CLI installed
Browser automation npx claudesclaude --browser ~15-30s per request Google Chrome

Quick Start

Default (CLI tunnel)

Pipes requests through the Claude Code CLI. No browser needed, instant startup.

npx claudesclaude

Requires claude CLI in your PATH. Install it from claude.ai/claude-code.

Browser Mode

Automates Claude's web UI with Puppeteer. Slower but works without the Claude Code CLI.

npx claudesclaude --browser

Opens Chrome, navigates to claude.ai, waits for you to log in (first time only — session is persisted).

Usage

With the Anthropic SDK

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "http://localhost:3456",
  apiKey: "unused",
});

const response = await client.messages.create({
  model: "claude-sonnet-4-20250514",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello!" }],
});

console.log(response.content[0].text);

With curl

curl -X POST http://localhost:3456/v1/messages \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 256,
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Streaming

curl -N -X POST http://localhost:3456/v1/messages \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 256,
    "stream": true,
    "messages": [{"role": "user", "content": "Tell me a story."}]
  }'

API Endpoints

Endpoint Method Description
/v1/messages POST Send a message (matches Anthropic API format)
/v1/models GET List available models
/health GET Check if the session is ready
/debug/screenshot GET PNG screenshot of browser (browser mode only)
/debug/info GET Current page URL and title (browser mode only)

Environment Variables

Variable Default Description
PORT 3456 API server port
HEADLESS false Run Chrome headless (browser mode only)
CHROME_PATH auto-detected Path to Chrome/Chromium (browser mode only)
CLAUDE_CLI_PATH claude Path to Claude Code CLI (CLI mode only)

How It Works

CLI Tunnel Mode

  1. Receives an API request matching the Anthropic Messages format
  2. Spawns claude -p --output-format json as a subprocess
  3. Passes the prompt via stdin, reads structured JSON from stdout
  4. Returns the response in Anthropic API format
  5. For streaming: uses --output-format stream-json --include-partial-messages

Browser Mode

  1. Launches your system Chrome via puppeteer-core
  2. Navigates to claude.ai and waits for login
  3. Persists session in ~/.claudesclaude/browser-data/
  4. For each request: opens a new conversation, pastes the message, waits for response
  5. Extracts response via network interception or DOM parsing
  6. Returns in Anthropic API format

Limitations

  • CLI mode: Requires Claude Code CLI with an active subscription. Each request spawns a new process.
  • Browser mode: Requests processed one at a time (~15-30s each). System prompts prepended as text. No image support. Claude.ai UI changes may break selectors.
  • Both modes: Token counts may be estimates. Model selection maps to Claude CLI aliases (sonnet/opus/haiku).

Disclaimer: This tool may violate Anthropic's Terms of Service. Use at your own risk.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors