Skip to main content

Local proxy that exposes Claude CLI as an OpenAI-compatible API server

Project description

claude-code-relay

OpenAI-compatible API server that wraps your local Claude CLI.

Demo

Why?

Creating API keys is friction when you just want to experiment. You already pay for Claude Code subscription - use it.

Quick Start

Node

bunx claude-code-relay serve          # easiest
npx claude-code-relay serve           # npm alternative
npm i -g claude-code-relay && claude-code-relay serve  # global install

Python

uvx claude-code-relay serve           # easiest
pipx run claude-code-relay serve      # pipx alternative
pip install claude-code-relay && claude-code-relay serve  # global install

Server runs at http://localhost:52014/v1

Usage

from openai import OpenAI
client = OpenAI(base_url="http://localhost:52014/v1", api_key="x")
client.chat.completions.create(model="sonnet", messages=[{"role": "user", "content": "Hi"}])
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "http://localhost:52014/v1", apiKey: "x" });
await client.chat.completions.create({ model: "sonnet", messages: [{ role: "user", content: "Hi" }] });

Models

Model Aliases
sonnet claude-3-sonnet, claude-sonnet-4
opus claude-3-opus, claude-opus-4
haiku claude-3-haiku

Default: unrecognized models (e.g., gpt-4) map to sonnet

Options

claude-code-relay serve [options]
  -p, --port <port>      Port (default: 52014)
  --host <host>          Host (default: 127.0.0.1)
  --claude-path <path>   Claude CLI path
  --timeout <seconds>    Timeout (default: 300)
  -v, --verbose          Verbose logging

Environment: CLAUDE_CLI_PATH, CLAUDE_CODE_RELAY_PORT, CLAUDE_CODE_RELAY_HOST, CLAUDE_CODE_RELAY_TIMEOUT, CLAUDE_CODE_RELAY_VERBOSE

Limitations

  • usage tokens always 0
  • temperature, max_tokens, top_p ignored
  • No tools/functions support

Examples

See examples/ for Node and Python demos.

License

MIT. Unofficial - comply with Anthropic ToS.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claude_code_relay-0.0.9.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claude_code_relay-0.0.9-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file claude_code_relay-0.0.9.tar.gz.

File metadata

  • Download URL: claude_code_relay-0.0.9.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for claude_code_relay-0.0.9.tar.gz
Algorithm Hash digest
SHA256 44d664dc8205e4df1022a284a023cf597c0504a0f3584665a3a747c70ef355a8
MD5 54b91fb09ffa6c8f72daa067c777473e
BLAKE2b-256 bd8fb8702521df4f7fad6fbdc8b0a0cf5035a73eec3e164446ebf1788232745f

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_code_relay-0.0.9.tar.gz:

Publisher: python-publish.yml on DreamTeamMobile/claude-code-relay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file claude_code_relay-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for claude_code_relay-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 5b2e7a77910b3610ff36bea58996f968a73f5120c3b1153e2623118b7d7d6ee5
MD5 e9ebe849e8b5578874bbb928f9aa9560
BLAKE2b-256 3ded3d5fbb0b23107e34e91f09c43624eec93b835235b0a23d27ddd78a0c0cf3

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_code_relay-0.0.9-py3-none-any.whl:

Publisher: python-publish.yml on DreamTeamMobile/claude-code-relay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page