dmvait8534/claude2api-deploy
Deploy a proxy that converts Claude.ai sessions into a standard Anthropic API with streaming, tools, and image support.
Platform-specific configuration:
{
"mcpServers": {
"claude2api-deploy": {
"command": "npx",
"args": [
"-y",
"claude2api-deploy"
]
}
}
}Add the config above to .claude/settings.json under the mcpServers key.
Claude.ai Web → Anthropic API 兼容代理。将 Claude.ai 账号会话转换为标准 /v1/messages 接口,支持流式输出、工具调用、图片上传、扩展思考等功能。
---
git clone https://github.com/realnoob007/claude2api-deploy.git
cd claude2api-deploycp .env.example .env
nano .env # 填入你的配置docker compose up -dcurl 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_* 变量(推荐 Neon/Supabase 使用)| | PROXY_HOST | — | 住宅代理主机(留空则直连 claude.ai)| | PROXY_PORT | 3010 | 代理端口 | | PROXY_USER | — | 代理认证用户名 | | `PR
Loading reviews...