{"id":13455611,"url":"https://github.com/fatwang2/coze2openai","last_synced_at":"2025-10-26T12:47:37.394Z","repository":{"id":233310940,"uuid":"786949941","full_name":"fatwang2/coze2openai","owner":"fatwang2","description":"Turn Coze API into OpenAI","archived":false,"fork":false,"pushed_at":"2024-10-28T10:41:32.000Z","size":2998,"stargazers_count":633,"open_issues_count":6,"forks_count":153,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-24T16:15:15.990Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://coze2openai.vercel.app","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fatwang2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"fatwang2"}},"created_at":"2024-04-15T15:54:50.000Z","updated_at":"2025-05-16T09:35:48.000Z","dependencies_parsed_at":"2024-04-15T18:27:33.604Z","dependency_job_id":"040beafd-75f6-4811-b01b-444ebed0d279","html_url":"https://github.com/fatwang2/coze2openai","commit_stats":null,"previous_names":["fatwang2/coze2openai"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/fatwang2/coze2openai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatwang2%2Fcoze2openai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatwang2%2Fcoze2openai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatwang2%2Fcoze2openai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatwang2%2Fcoze2openai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fatwang2","download_url":"https://codeload.github.com/fatwang2/coze2openai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatwang2%2Fcoze2openai/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281107100,"owners_count":26444787,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-26T02:00:06.575Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T08:01:08.045Z","updated_at":"2025-10-26T12:47:37.360Z","avatar_url":"https://github.com/fatwang2.png","language":"JavaScript","funding_links":["https://github.com/sponsors/fatwang2","https://www.buymeacoffee.com/fatwang2"],"categories":["JavaScript"],"sub_categories":[],"readme":"## C2O\n**English** · [中文](README_CN.md) \n\n**Use Coze on your favorite OpenAI client.**\n\nThis project converts the Coze API to the OpenAI API format, giving you access to [Coze](https://www.coze.com) LLMs, knowledge base, plugins, and workflows within your preferred OpenAI clients. \n\n## Features\n- Convert Coze API into an OpenAI API\n- Support streaming and blocking\n- Supports multi-bot switching\n\n## Preparation\n1. Register with [coze.com](https://www.coze.com) or [coze.cn](https://www.coze.cn)and obtain your API token\n![cozeapitoken](pictures/token.png)\n\n2. Create your bot and publish it to the API\n![cozeapi](pictures/api.png)\n\n3. Obtain the bot's ID,the number after the bot parameter, and configure it as an environment variable\n```bash\nhttps://www.coze.com/space/73428668341****/bot/73428668*****\n```\n\n## Deployment\n### Zeabur\n[![Deploy on Zeabur](https://zeabur.com/button.svg)](https://zeabur.com/templates/BZ515Z?referralCode=fatwang2)\n\n### Vercel\n[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/fatwang2/coze2openai\u0026env=BOT_ID\u0026envDescription=COZE_BOT_ID)\n\n**Note:** Vercel's serverless functions have a 10-second timeout limit.\n\n### Railway\n[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/yM5tQL?referralCode=mDim7U)\n\n### Docker Deployment\n\n1. Ensure Docker and Docker Compose are installed on your machine.\n\n2. Clone the project repository:\n   ```\n   git clone https://github.com/your-username/coze2openai.git\n   cd coze2openai\n   ```\n\n3. Create and configure the `.env` file:\n   ```\n   cp .env.template .env\n   ```\n   Edit the `.env` file and fill in your BOT_ID and other necessary configurations.\n\n4. Build and start the Docker container:\n   ```\n   docker-compose up -d\n   ```\n\n5. Visit `http://localhost:3000` to confirm that the service is running correctly.\n\nTo stop the service, run:\n```\ndocker-compose down\n```\n\nNote: The Dockerfile uses Taobao NPM mirror, you can comment out or replace other different mirror:\n```Dockerfile\nENV NPM_CONFIG_REGISTRY=https://registry.npmmirror.com/\nENV PNPM_REGISTRY=https://registry.npmmirror.com/\n```\n\n### Local Deployment\n1. Set the environment variable on `.env` file\n```bash\nBOT_ID=xxxx\n```\n\n2. Install dependencies \n```bash\npnpm install\n```\n\n3. Run the project\n```bash\npnpm start\n```\n\n## Usage\n1. OpenAI Clients\n\n![botgem](pictures/usage.png)\n\n2. Code\n\n```JavaScript\nconst response = await fetch('http://localhost:3000/v1/chat/completions', {\n  method: 'POST',\n  headers: {\n    'Content-Type': 'application/json',\n    'Authorization': 'Bearer YOUR_COZE_API_KEY',\n  },\n  body: JSON.stringify({\n    model: 'model_name',\n    messages: [\n      { role: 'system', content: 'You are a helpful assistant.' },\n      { role: 'user', content: 'Hello, how are you?' },\n    ],\n  }),\n});\n\nconst data = await response.json();\nconsole.log(data);\n```\n## Environment Variable\nThis project provides some additional configuration items set with environment variables:\n\n| Environment Variable | Required | Description                                                                                                                                                               | Example                                                                                                              |\n| -------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |\n| `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*****`|\n| `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\"}`|\n| `COZE_API_BASE`     | No      | Choose coze.com or coze.cn | `api.coze.com, api.coze.cn`|\n\n## Roadmap\n**Coming Soon**\n*   Image support\n*   Audio-to-text\n*   Text-to-audio\n\n**Available Now**\n*   Coze.cn\n*   Multi-bot switching\n*   Workflow, Plugins, Knowledge base\n*   Continuous dialogue with the history of chat\n*   Zeabur \u0026 Vercel \u0026 Railway deployment\n*   Streaming \u0026 Blocking\n*   Docker deployment\n\n## Contact\nFeel free to reach out for any questions or feedback\n\n[X](https://sum4all.site/twitter)\\\n[telegram](https://sum4all.site/telegram)\n\n\u003ca href=\"https://www.buymeacoffee.com/fatwang2\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" style=\"height: 60px !important;width: 217px !important;\" \u003e\u003c/a\u003e\n\n## License\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffatwang2%2Fcoze2openai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffatwang2%2Fcoze2openai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffatwang2%2Fcoze2openai/lists"}