• Stars
    star
    1,235
  • Rank 37,736 (Top 0.8 %)
  • Language
    Python
  • License
    MIT License
  • Created over 1 year ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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-v1.3, claude-v1.3-100k 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-0301, it will be substituted with claude-v1.3. otherwise, claude-v1.3-100k 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-v1.3",
  "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.

More Repositories

1

bob-plugin-claude-translator

一个让 Bob 翻译可以使用 Anthropic Claude API 的插件
JavaScript
88
star
2

umi-plugin-antd-type-icon

🎁 Add <Icon type="iconType" /> component for antd@4 and only import icons you need.
TypeScript
12
star
3

caslin

🌗An application feature management JS framework to support multi-environments, multi-roles, multi-scenarios.
TypeScript
10
star
4

monaco-cs-editor

📟 A monaco-eidtor running in C-S mode follow LSP(https://microsoft.github.io/language-server-protocol/).
JavaScript
5
star
5

graph-editing-playground

Exploration in graph editing framework.
TypeScript
3
star
6

satumjs-website

An offical website for satumjs. https://satumjs.github.io/website
JavaScript
2
star
7

reacooks

🎣 React Hooks for making developing React application easier.
TypeScript
2
star
8

eslint-config

Opinionated eslint configs.
JavaScript
2
star
9

micro-fe-demo

TypeScript
2
star
10

ttl-db

A key-value store which supports expiration time based on IndexedDB.
TypeScript
1
star
11

wbpck-bundler

A project to learn how to pack Node's modules, heavily basic on https://github.com/adamisntdead/wbpck-bundler
JavaScript
1
star
12

zhihu-collection

一个知乎收藏夹搜索插件 | A plugin to search on Zhihu collection.
JavaScript
1
star
13

umi-plugin-externals

📤 A umi plugin to help you make local built JS module as webpack external bundle.
TypeScript
1
star
14

demo-open-source

A project for open source cooporation showcase.
TypeScript
1
star
15

blog

Astro
1
star
16

raycast-extensions

Raycast extensions repo
TypeScript
1
star
17

make-real

TypeScript
1
star