Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jtsang4/claude-to-chatgpt
This project converts the API of Anthropic's Claude model to the OpenAI Chat API format.
https://github.com/jtsang4/claude-to-chatgpt
anthropic chatgpt claude claude-ai openai
Last synced: 30 days ago
JSON representation
This project converts the API of Anthropic's Claude model to the OpenAI Chat API format.
- Host: GitHub
- URL: https://github.com/jtsang4/claude-to-chatgpt
- Owner: jtsang4
- License: mit
- Created: 2023-05-10T01:03:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-18T08:35:25.000Z (3 months ago)
- Last Synced: 2024-09-27T03:21:20.105Z (about 1 month ago)
- Topics: anthropic, chatgpt, claude, claude-ai, openai
- Language: Python
- Homepage:
- Size: 53.7 KB
- Stars: 1,248
- Watchers: 19
- Forks: 149
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - jtsang4/claude-to-chatgpt - This project converts the API of Anthropic's Claude model to the OpenAI Chat API format. (Python)
- awesome-ChatGPT-repositories - claude-to-chatgpt - This project converts the API of Anthropic's Claude model to the OpenAI Chat API format. (Openai)
- StarryDivineSky - jtsang4/claude-to-chatgpt
- awesome-chatgpt - jtsang4/claude-to-chatgpt - This project converts the API of Anthropic's Claude model to the OpenAI Chat API format. (Other / Other sdk/libraries)
README
English | 简体中文 | 日本語This project converts the API of Anthropic's Claude model to the OpenAI Chat API format.
* ✨ Call Claude API like OpenAI ChatGPT API
* 💦 Support streaming response
* 🐻 Support `claude-instant-1`, `claude-2` models
* 🌩️ Deploy by Cloudflare Workers or Docker## Getting Started
You can run this project using Cloudflare Workers or Docker:
### Deployment
#### Using Cloudflare Workers
By using Cloudflare Workers, you don't need a server to deploy this project.
1. Create a Cloudflare Worker
2. Paste the code in [`cloudflare-worker.js`](https://github.com/jtsang4/claude-to-chatgpt/blob/main/cloudflare-worker.js) to Cloudflare Worker "Quick Edit" Editor
3. Save and deploy
4. (Optional) Set custom domain for your Cloudflare WorkerThe Cloudfalre Workers support 100k requests a day, If you need to call more than that, you can use Docker to deploy as below.
#### Using Docker
```bash
docker run -p 8000:8000 wtzeng/claude-to-chatgpt:latest
```#### Using Docker Compose
```bash
docker-compose up
```The API will then be available at http://localhost:8000. API endpoint: `/v1/chat/completions`
### Usage
When you input the model parameter as `gpt-3.5-turbo` or `gpt-3.5-turbo-0613`, it will be substituted with `claude-instant-1`. otherwise, `claude-2` will be utilized.
#### GUI
Here are some recommended GUI software that supports this project:
* [Bin-Huang/chatbox](https://github.com/Bin-Huang/chatbox)
* [Yidadaa/ChatGPT-Next-Web](https://github.com/Yidadaa/ChatGPT-Next-Web)#### CLI
```bash
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $CLAUDE_API_KEY" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "Hello!"}]
}'
```## Conversion Details
The Claude Completion API has an endpoint `/v1/complete` which takes the following JSON request:
```json
{
"prompt": "\n\nHuman: Hello, AI.\n\nAssistant: ",
"model": "claude-instant-1",
"max_tokens_to_sample": 100,
"temperature": 1,
"stream": true
}
```And returns JSON with choices and completions.
The OpenAI Chat API has a similar `/v1/chat/completions` endpoint which takes:
```json
{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "Hello, AI."
}
],
"max_tokens": 100,
"temperature": 1,
"stream": true
}
```And returns JSON with a response string.
This project converts between these two APIs, get completions from the Claude model and formatting them as OpenAI Chat responses.
## License
This project is licensed under the MIT License - see the LICENSE file for details.