claude5
claude5 是一个 Python 包和命令行工具:启动 Claude Code 时按需启动本地 API 转发,将 Anthropic Messages API 转为任意 OpenAI-compatible Chat Completions 上游。
项目包名为 claude5,兼容以下三个命令:
claude2
claude5
cc5
三个命令完全等价,都会调用 claude5.cli:main。
特性
- 使用
claude5、claude2或cc5时才检查/启动本地代理; - Claude Code 退出后,由本次命令启动的本地代理也会退出;
- 首次运行生成
~/.claude5.json配置模板; - 如果检测到旧的
~/.claude2.json,会继续兼容读取; - 不会自动安装 Claude Code;
- 文件读写和捕获的外部命令输出统一使用 UTF-8;
- 不依赖第三方 Python 运行时库。
安装
python -m pip install claude5
安装后会提供三个命令:
claude2 --help
claude5 --help
cc5 --help
配置
首次运行任意命令:
claude5
会创建:
~/.claude5.json
配置模板包含:
{
"base_url": "https://YOUR_OPENAI_COMPATIBLE_ENDPOINT/v1",
"api_key": "PASTE_YOUR_API_KEY_HERE",
"model": "YOUR_MODEL_ID",
"host": "127.0.0.1",
"port": 18080
}
需要修改:
base_url:OpenAI-compatible 上游地址;api_key:上游 API Key;model:模型名称。
配置文件创建时会尝试设置为 600。建议保存在 WSL Linux 文件系统中,不要提交到 Git。
兼容旧配置
新版本优先使用:
~/.claude5.json
如果该文件不存在但旧文件存在:
~/.claude2.json
程序会继续读取内测阶段的旧配置,不会强制迁移或覆盖旧文件。
用法
三个命令的参数完全相同,例如:
claude5 -p "解释当前项目的目录结构"
claude2 -p "检查这个项目的依赖"
cc5 --show-config
claude5 --show-config
-p/--prompt 现在由 claude5 显式声明并转发给 Claude Code;其他未在 Hub 帮助中列出的参数也会继续原样转发。
工作流程
- 读取
~/.claude5.json,必要时兼容读取~/.claude2.json; - 检查
claude命令是否存在; - 检查本地代理是否已监听;
- 没有代理时启动
claude5.proxy; - 将 Claude Code 的 Anthropic 请求转换为 OpenAI-compatible Chat Completions 请求;
- 将上游响应转换回 Anthropic Messages 响应;
- Claude Code 退出后,仅关闭由本次命令启动的代理。
安全说明
- 本地代理默认绑定
127.0.0.1; ~/.claude5.json包含 API Key,应限制文件权限;- 不要把 API Key 写进命令行参数、脚本、日志或版本库;
- 不要把本地代理暴露到公网;
claude2只是兼容命令名,实际加载的是claude5包。
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claude5-0.1.0.tar.gz.
File metadata
- Download URL: claude5-0.1.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.27.0 CPython/3.12.10 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e7074ea95055943f0b7f7fd013f59292c64231242b1cc38694a904c9c1b7c2b
|
|
| MD5 |
4f9a656c337a0a2ca583160dba0c9d0a
|
|
| BLAKE2b-256 |
3edcaa1421fb616c594ea1cf23a89478bce7ef21c20eb5e6467b54c71d1b0500
|
File details
Details for the file claude5-0.1.0-py3-none-any.whl.
File metadata
- Download URL: claude5-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.27.0 CPython/3.12.10 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
862fa056919883db2f8dfc5f68479b1e54071c81f96221977ec2d661c2ca404b
|
|
| MD5 |
adc89450f612ca482ffd3d80b87a3917
|
|
| BLAKE2b-256 |
2ed27473bc35c309eec60423c66e5cd5850dab0f71df35897f211a1b74b99f23
|