claude2
claude2 copied to clipboard
Claude2 to OpenAI API
Claude2
Claude2 转 OpenAI API 标准接口,Origin: claude-to-chatgpt
curl https://claude2-0bbi.onrender.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"}],
"stream": true
}'
编译
Go 1.20 及以上版本。
git clone https://github.com/gngpp/claude2.git && cd claude2
go mod tidy
go build -ldflags "-s -w -extldflags -static" main.go
其他
使用 -c
指定配置文件 config-dev.yaml
使用 -http_proxy
设置 http_proxy
例如 http://127.0.0.1:8000
go run main.go -c config-dev.yaml -http_proxy http://127.0.0.1:8000
配置
配置文件如果不存在,程序会自动创建 config.yaml
。
如果启动后填写的配置信息有误,直接修改配置文件并保存即可,程序会自动重新加载。
配置项 | 说明 | 示例值 |
---|---|---|
claude | Claude 相关配置 | |
session-keys | 当前对话session唯一标识数组,非必填 支持在 Header Authorization 中设置 Bearer sessionKey 参考 Authentication Header优先级大于配置文件 |
[sk-1, sk-2] |
http-proxy | 代理配置,可选 (包含但不限于)注意在Docker中的连通性 可能需要更换 http://127.0.0.1:8000 为宿主机IP如 http://192.168.1.2:8000 |
http://127.0.0.1:8000 |
tls-cert | TLS证书路径 | /etc/tls.pem |
tls-key | TLS证书密钥路径 | /etc/tls.key |
listen-host | 监听主机 | 0.0.0.0:8000 |