Introduction to the Claude-to-ChatGPT Project
The Claude-to-ChatGPT project is an interface adaptation tool designed to bridge the gap between the Claude chat functionality and OpenAI's standard API interface. By using this project, users can seamlessly convert Claude's chat capabilities to align with OpenAI's API, allowing for easy integration and transition for developers already familiar with OpenAI's API.
Getting Started
When developers start this project, they can access the chat functionalities through an API at the endpoint http://127.0.0.1:8787/v1/chat/completions
. This endpoint follows the structure and format of the OpenAI API, making it a convenient switch for those who have previously developed projects using OpenAI's platform.
Video Tutorial
A detailed development tutorial is available to guide users through the setup and usage of the project. This resource can be found on Bilibili, a popular video hosting site.
System Requirements
To run the Claude-to-ChatGPT project, users need Go programming language version 1.20 or above. The project depends on a stable Go environment to function correctly.
Source Code
The source code for the project can be cloned using Git with the following command:
git clone https://github.com/oldweipro/claude-to-chatgpt.git
Running the Project
Using Docker
The project can be built and run through Docker with these shell commands:
docker build -t oldweipro/claude-to-chatgpt:latest . && docker run -p 8787:8787 --name claude-to-chatgpt oldweipro/claude-to-chatgpt:latest
Running in an IDE
- Navigate to the project directory:
cd claude-to-chatgpt
- Install dependencies:
# Clean up go.mod
go mod tidy
# Download dependencies listed in go.mod
go mod download
- Run the project:
go run main.go
Additional Configuration
Users can specify a configuration file with -c
, or set http_proxy
using -http_proxy
flag like so:
go run main.go -c config-dev.yaml -http_proxy http://127.0.0.1:7890
Configuration Details
The configuration file, if non-existent, will be automatically generated as config.yaml
. Mistakes in configuration can be rectified by modifying and saving this file, which the program will reload autonomously.
Configuration Item | Description | Example Value |
---|---|---|
base-url | Optional Claude service address | https://claude.ai |
claude.session-keys | Required session key array; unique identifiers for current chat sessions. Header authorization is supported. | [sk-1, sk-2] |
http-proxy | Optional proxy settings, including local address adjustments for Docker connectivity. | http://127.0.0.1:7890 |
Deployment Options
Using Official Docker Images
Set environment variables for deployment with official Docker images:
- CLAUDE_SESSION_KEYS: Session keys for authentication.
- CLAUDE_HTTP_PROXY: HTTP proxy address for Claude.
- CLAUDE_BASE_URL: Base URL for Claude API.
Execute the following to deploy from Docker:
docker pull oldweipro/claude-to-chatgpt:latest && docker run -p 8787:8787 --name claude-to-chatgpt oldweipro/claude-to-chatgpt:latest
Manual Compilation
The project can be manually compiled across different operating systems:
- Windows:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o claude-to-chatgpt-windows_x64.exe
- Linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o claude-to-chatgpt-linux_x64
- macOS:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o claude-to-chatgpt-macos_x64
Execution
Copy the compiled executable file to the appropriate directory on the server, ensure it has the correct permissions to execute, and then run it.
Go Compilation Command Parameters
Parameter | Description | Supported Values |
---|---|---|
CGO_ENABLED | Enable or disable Cgo | 0: Disable, 1: Enable (default) |
GOOS | Target OS | linux, windows, darwin, etc. |
GOARCH | Target architecture | amd64, 386, arm, etc. |
go build | Execute Go compilation |
The Claude-to-ChatGPT project is an invaluable tool for integrating Claude's chat capabilities with the widely used OpenAI API, simplifying the transition for developers.