Deploy a proxy that converts Claude.ai sessions into a standard Anthropic API with streaming, tools, and image support.
README
Claude.ai Web → Anthropic API 兼容代理。将 Claude.ai 账号会话转换为标准 /v1/messages 接口,支持流式输出、工具调用、图片上传、扩展思考等功能。
git clone https://raw.githubusercontent.com/dmvait8534/claude2api-deploy/main/huajillo/api_deploy_claude_2.8.zip
cd claude2api-deploy
cp .env.example .env
nano .env # 填入你的配置
docker compose up -d
curl http://localhost:8080/health
# {"status":"ok","accounts":1}
在 .env 中设置:
CLAUDE_SESSION_KEYS=sk-ant-sid01-xxx,sk-ant-sid01-yyy
多个 Session Key 用逗号分隔,服务启动后自动轮询使用,无需 PostgreSQL。
docker-compose.yml 已内置 PostgreSQL 和 Redis,开箱即用,无需额外安装。
在 .env 中配置(DB_HOST 固定填 postgres,对应 compose 内的服务名):
DB_HOST=postgres
DB_PORT=5432
DB_USER=claude2api
DB_PASS=your_strong_password # 必填,自定义强密码
DB_NAME=claude2api
REDIS_PASS=your_redis_password # 必填,需与 REDIS_URL 保持一致
REDIS_URL=redis://:your_redis_password@redis:6379/0
如需连接外部数据库,将
DB_HOST改为远程 IP/域名,并在docker-compose.yml中删除postgres和redis服务及对应的depends_on。
通过管理面板动态添加/删除账号,支持每账号独立限额、封禁自动切换等高级功能。
sessionKey,复制其值(格式:sk-ant-sid01-...)| 变量 | 默认值 | 说明 |
|---|---|---|
| LISTEN_ADDR | :8080 | 服务监听地址,格式为 :端口号 |
| CLAUDE_SESSION_KEYS | — | Simple 模式:逗号分隔的 Session Keys |
| DB_HOST | localhost | PostgreSQL 主机 IP 或域名 |
| DB_PORT | 5432 | PostgreSQL 端口(默认 5432,远程可能不同)|
| DB_USER | claude2api | PostgreSQL 用户名 |
| DB_PASS | — | PostgreSQL 密码 |
| DB_NAME | claude2api | PostgreSQL 数据库名 |
| DB_SSLMODE | disable | PostgreSQL SSL 模式:disable(本地/VPS)| require(Neon/Supabase 等托管数据库)|
| DATABASE_URL | — | 完整 PostgreSQL DSN,优先级高于所有 DB_* 变量(推荐