ccproxy-client
v0.1.0
Published
Zero-dependency client for a ccproxy server: an OpenAI/Anthropic-compatible API served by the Claude Code CLI
Maintainers
Readme
ccproxy-client (Node)
Zero-dependency client for a ccproxy server. ccproxy exposes an OpenAI- and Anthropic-compatible HTTP API that is answered by the Claude Code CLI. Project home: https://github.com/wubbyweb/ccproxy
What you need
This package is only an HTTP client. Installing it does not install or require Claude Code. You need two things:
- A running ccproxy server you can reach over HTTP. Claude Code must be installed and logged in on the machine running that server, not on the machine running this client.
- An API key for that server, created in its admin console (
http://<server>:8787/admin).
Two common setups:
| Setup | Who needs Claude Code | Client config |
|---|---|---|
| Same machine: you run the server locally and your app talks to it | you, on this machine | baseURL default http://127.0.0.1:8787 |
| Shared server: someone hosts ccproxy and hands out API keys | only the host machine | baseURL: "https://proxy.example.com" plus the key you were given |
To run a server yourself:
npm install -g ccproxy-server # needs Node 18+ and a logged-in Claude Code CLI
ccproxy serve
ccproxy admin token # sign in at http://127.0.0.1:8787/admin and create a keyInstall
npm install ccproxy-clientNode 18+ (uses global fetch). Also works in browsers.
Use
import { CCProxy } from 'ccproxy-client';
// apiKey and baseURL also come from CCPROXY_API_KEY / CCPROXY_BASE_URL env vars
const client = new CCProxy({ apiKey: 'sk-ccp-...', baseURL: 'http://127.0.0.1:8787' });
// One-liner
console.log(await client.complete('Explain monads in one sentence.'));
// OpenAI-style
const res = await client.chat.completions.create({
model: 'sonnet',
messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(res.choices[0].message.content);
// Streaming
const stream = await client.chat.completions.create({ messages: [{ role: 'user', content: 'Tell me a story' }], stream: true });
for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
// Anthropic-style
const msg = await client.messages.create({ max_tokens: 500, messages: [{ role: 'user', content: 'Hi' }] });
console.log(msg.content[0].text);
// Models and health
console.log((await client.models.list()).map((m) => m.id));
console.log(await client.health());Errors throw CCProxyError with status (HTTP status, 401 for a bad key, 429 for rate limits, 0 for connection failures) and body.
Function calling (tools), response_format, stop sequences and reasoning_effort are passed through; see the project README for what the server supports.
Alternatives
The official openai and @anthropic-ai/sdk packages also work: set baseURL to the server (.../v1 for OpenAI) and use the ccproxy key as the API key.
