Purpose
claude-to-chatgpt is an API conversion layer project whose main purpose is to convert Anthropic's Claude model API into the OpenAI Chat API format. Through this conversion, developers can call the Claude models in the same way as calling the OpenAI ChatGPT API, thereby reusing existing OpenAI API clients, SDKs, or GUI tools.
Main capabilities
- API format conversion: Converts Claude's Completion API (endpoint
/v1/complete) into OpenAI's Chat API (endpoint/v1/chat/completions) format, obtains completion results from the Claude model, and formats them as an OpenAI Chat response. - Streaming response support: Supports streaming responses, consistent with the behavior of the OpenAI API.
- Model compatibility: Supports
claude-instant-1andclaude-2models. When the input model parameter isgpt-3.5-turboorgpt-3.5-turbo-0613, it is replaced withclaude-instant-1; otherwiseclaude-2is used. - Multiple deployment methods: Supports deployment via Cloudflare Workers or Docker.
Usage
Deploy via Cloudflare Workers
- Create a Cloudflare Worker.
- Paste the code from
cloudflare-worker.jsinto the "Quick Edit" editor of the Cloudflare Worker. - Save and deploy.
- (Optional) Set a custom domain for the Cloudflare Worker.
Cloudflare Workers supports 100,000 requests per day. If the call volume exceeds this limit, Docker deployment can be used.
Deploy via Docker
After deploying with Docker, the API will be available at http://localhost:8000 , and the API endpoint is /v1/chat/completions.
Recommended GUI clients
The project recommends the following GUI software that supports this conversion layer:
- Bin-Huang/chatbox
- Yidadaa/ChatGPT-Next-Web
Use cases
- Wanting to switch to or test Claude models without modifying existing OpenAI API call code.
- Using third-party GUI clients that only support the OpenAI API (such as Chatbox and ChatGPT-Next-Web) to connect to Claude models.
- Quickly deploying a Claude-to-OpenAI format conversion service in a serverless environment.
Limitations
- The conversion only involves adaptation at the API format level and does not change the capabilities and limitations of the Claude models themselves.
- The free version of Cloudflare Workers is limited to 100,000 requests per day; beyond that, Docker deployment is required.
- The model mapping rules are fixed:
gpt-3.5-turboorgpt-3.5-turbo-0613maps toclaude-instant-1, and others map toclaude-2. - The project uses the MIT license.