MyGit

jtsang4/claude-to-chatgpt

Fork: 149 Star: 1204 (更新于 2024-05-13 17:50:44)

license: MIT

Language: Python .

This project converts the API of Anthropic's Claude model to the OpenAI Chat API format.

最后发布版本: v0.4.0 ( 2023-07-12 04:55:18)

GitHub网址

English | 简体中文 | 日本語

Claude to ChatGPT

release GitHub Repo stars GitHub Repo Badge GitHub Repo Language

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 to Cloudflare Worker "Quick Edit" Editor
  3. Save and deploy
  4. (Optional) Set custom domain for your Cloudflare Worker

The 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

docker run -p 8000:8000 wtzeng/claude-to-chatgpt:latest

Using Docker Compose

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:

CLI

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:

{
  "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:

{
  "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.

最近版本更新:(数据更新于 2024-05-26 10:40:24)

2023-07-12 04:55:18 v0.4.0

2023-06-13 22:16:16 v0.3.3

2023-05-14 22:20:27 v0.3.2

2023-05-14 16:01:59 v0.3.1

2023-05-12 07:44:24 v0.3.0

2023-05-12 01:44:28 v0.2.2

2023-05-12 01:33:07 v0.2.1

2023-05-12 00:55:53 v0.2.0

2023-05-10 20:49:02 v0.1.0

主题(topics):

anthropic, chatgpt, claude, claude-ai, openai

jtsang4/claude-to-chatgpt同语言 Python最近更新仓库

2024-07-06 16:28:39 AUTOMATIC1111/stable-diffusion-webui

2024-07-04 10:17:23 jumpserver/jumpserver

2024-07-03 02:49:43 microsoft/graphrag

2024-07-02 22:55:34 mindsdb/mindsdb

2024-07-02 12:55:09 fishaudio/fish-speech

2024-07-02 11:46:22 Azure-Samples/graphrag-accelerator