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.

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.8.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.8-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: claude_code_relay-0.0.8.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.8.tar.gz
Algorithm Hash digest
SHA256 ee2de46f37960413af4c8d9ae3b5f4f2e24e2edcff7f2d7d369fd260b8589abb
MD5 69397aa8d2a0be7a6a0226d163149da3
BLAKE2b-256 7a91e6b7ce5d5aa7341cb9fd0243f73f6b67e92549b85f4a2314b6543a49453d

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_code_relay-0.0.8.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.8-py3-none-any.whl.

File metadata

File hashes

Hashes for claude_code_relay-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 4196cff0e5c397269cf91ca4ce8c3e0969d56b152b78d131652c04a169785905
MD5 c41453d62767dc5074f8d96a1183873e
BLAKE2b-256 03afcc00f9910bd663cbaa8fde78e3a5b3f7f7c3b53607018eb470905365e35d

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_code_relay-0.0.8-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