Skip to content

pingfury108/APIBridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

APIBridge

Claude到OpenAI格式转换代理工具

功能

  • 接收Claude格式的API请求
  • 转换为OpenAI格式并转发到目标服务
  • 将OpenAI格式响应转换回Claude格式
  • 纯格式转换,不涉及认证处理

使用方法

CLI参数

# 基础用法
apibridge --target-url http://your-openai-service.com

# 指定端口
apibridge --target-url http://your-openai-service.com --port 3000

# 指定主机
apibridge --target-url http://your-openai-service.com --host 0.0.0.0

环境变量

# 环境变量优先于CLI参数
export TARGET_URL=http://your-openai-service.com
export PORT=3000
export HOST=0.0.0.0
apibridge

API接口

主要转换接口

  • POST /v1/messages - Claude Messages API转换为OpenAI Chat Completion

其他接口

  • 其他所有路由直接代理转发到目标服务

示例

启动代理

apibridge --target-url http://localhost:8000 --port 8080

使用Claude格式请求

curl -X POST http://localhost:8080/v1/messages \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-3-sonnet-20240229",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": "Hello, how are you?"
      }
    ]
  }'

构建

cargo build --release

运行

cargo run -- --target-url http://your-service.com

About

Claude到OpenAI格式转换代理工具

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages