GithubHelp home page GithubHelp logo

cryptowww / coze2openai Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fatwang2/coze2openai

0.0 0.0 0.0 705 KB

Turn Coze API into OpenAI

Home Page: https://coze2openai.vercel.app

License: MIT License

JavaScript 100.00%

coze2openai's Introduction

C2O

English · 中文

Use Coze on your favorite OpenAI client.

This project converts the Coze API to the OpenAI API format, giving you access to Coze LLMs, knowledge base, plugins, and workflows within your preferred OpenAI clients. 

Features

  • Convert Coze API into an OpenAI API
  • Support streaming and blocking
  • Supports multi-bot switching

Preparation

  1. Register with Coze and obtain your API token cozeapitoken

  2. Create your bot and publish it to the API cozeapi

  3. Obtain the bot's ID,the number after the bot parameter, and configure it as an environment variable

https://www.coze.com/space/73428668341****/bot/73428668*****

Deployment

Zeabur

Deploy on Zeabur

Vercel

Deploy with Vercel

Note: Vercel's serverless functions have a 10-second timeout limit.

Railway

Deploy on Railway

Local Deployment

  1. Set the environment variable on .env file
BOT_ID=xxxx
  1. Install dependencies
pnpm install
  1. Run the project
pnpm start

Usage

const response = await fetch('http://localhost:3000/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_COZE_API_KEY',
  },
  body: JSON.stringify({
    model: 'model_name',
    messages: [
      { role: 'system', content: 'You are a helpful assistant.' },
      { role: 'user', content: 'Hello, how are you?' },
    ],
  }),
});

const data = await response.json();
console.log(data);

Environment Variable

This project provides some additional configuration items set with environment variables:

Environment Variable Required Description Example
BOT_ID Yes The ID of the bot. Obtain it from the Develop page URL of your bot in Coze. The number after the bot parameter is the bot ID. 73428668*****
BOT_CONFIG No Configure different models to correspond to different bot ids to enable fast bot switching on the client side. Models that are not included will request the default BOT_ID {"model_name_1": "bot_id_1", "model_name_2": "bot_id_2", "model_name_3": "bot_id_3"}

Roadmap

Coming Soon

  • Image support
  • Audio-to-text
  • Text-to-audio
  • Docker support

Available Now

  • Multi-bot switching
  • Workflow, Plugins, Knowledge base
  • Continuous dialogue with the history of chat
  • Zeabur & Vercel & Railway deployment
  • Streaming & Blocking

Contact

Feel free to reach out for any questions or feedback

X
telegram

Buy Me A Coffee

License

This project is licensed under the MIT License.

coze2openai's People

Contributors

fatwang2 avatar he0607 avatar y-not-u avatar largecuppanda avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.