{"id":21098311,"url":"https://github.com/aurorax-neo/coze-chat-proxy","last_synced_at":"2025-05-16T16:32:09.853Z","repository":{"id":219420846,"uuid":"748518575","full_name":"aurorax-neo/coze-chat-proxy","owner":"aurorax-neo","description":"a coze chat proxy","archived":true,"fork":false,"pushed_at":"2024-02-23T09:34:02.000Z","size":62,"stargazers_count":75,"open_issues_count":2,"forks_count":17,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-25T07:33:23.408Z","etag":null,"topics":["api","chat","coze"],"latest_commit_sha":null,"homepage":"","language":"Go","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/aurorax-neo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2024-01-26T06:37:31.000Z","updated_at":"2024-08-13T04:00:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"7d72ef4a-6808-4ec6-a723-68a3af630081","html_url":"https://github.com/aurorax-neo/coze-chat-proxy","commit_stats":null,"previous_names":["aurorax-neo/coze-chat-proxy"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aurorax-neo%2Fcoze-chat-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aurorax-neo%2Fcoze-chat-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aurorax-neo%2Fcoze-chat-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aurorax-neo%2Fcoze-chat-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aurorax-neo","download_url":"https://codeload.github.com/aurorax-neo/coze-chat-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254567489,"owners_count":22092776,"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","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":["api","chat","coze"],"created_at":"2024-11-19T22:54:32.660Z","updated_at":"2025-05-16T16:32:09.848Z","avatar_url":"https://github.com/aurorax-neo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# coze-chat-proxy\n\n##### 核心：[coze-discord-proxy](https://github.com/deanxv/coze-discord-proxy)\n\n### 特性：\n\n- 机器人可自定义`model`\n- 支持多个机器人，添加到json列表即可，同模型（model）轮训请求\n- 因转api，暂时上下文采用消息拼接（最长2000，discord bot 限制）\n\n## 如何使用\n\n1. 打开 [discord开发者平台](https://discord.com/developers/applications) 。\n2. 创建bot-01,并记录bot专属的`token`和`id(COZE_BOT_ID)`,此bot为被coze托管的bot。\n3. 创建bot-02,并记录bot专属的`token(BOT_TOKEN)`,此bot为向bot-01发送与接收bot-01返回的消息。\n4. 两个bot开通对应权限(`Send Messages`,`Read Message History`等)并邀请进服务器,记录服务器ID(`GUILD_ID`) 。\n5. 打开 [coze官网](https://www.coze.com) 创建自己bot。\n6. 创建好后public，配置discord-bot的`token`,即bot-01的`token`,点击完成后在discord的服务器中可看到bot-01在线并可以@使用。\n7. 配置环境变量或`.env`文件（环境变量优先生效），并启动本项目。\n8. 访问接口地址，接口见下文\n\n## 配置\n\n### 环境变量\n\n1. `LOG_LEVEL：info`  日志等级，默认` info`\n\n2. `SERVER_PORT：8080`  服务端口,，默认`8080`\n\n3. `BOT_CONFIG：bot.json` discord-bot配置文件，默认`bot.json`\n\n4. `AUTH_TOKEN`:`123456` 请求头校验的值（前后端统一）,配置此参数后，每次发起请求时请求头加上`Authorization`\n   参数，即`header`中添加 `Authorization：Bearer 123456`，默认`1234567890:ABCDEFGHIJKLMNOPQRSTUVWXYZ`\n\n###### 也可使用与程序同目录下 `.env` 文件配置上述字段\n\n\n### bot.json配置\n\n###### 支持多个机器人，添加到json列表即可，同模型（model）轮训请求\n\n```\n[\n  {\n    \"model\": \"gpt-3.5-turbo\", // bot模型可自定义，与请求接口保持一致 可自定义\n    \"bot_token\": \"MTI************\", //见如何使用.3\n    \"coze_bot_id\": \"120**********\", //见如何使用.2\n    \"guild_id\": \"103************\", //见如何使用.4\n    \"channel_id\": \"120*********\" //在所在服务器 创建频道 记录id\n  },\n  {\n    \"model\": \"dall-e-3\", // bot模型可自定义，与请求接口保持一致 可自定义\n    \"bot_token\": \"MTI************\", //见如何使用.3\n    \"coze_bot_id\": \"120**********\", //见如何使用.2\n    \"guild_id\": \"103************\", //见如何使用.4\n    \"channel_id\": \"120*********\" //在所在服务器 创建频道 记录id\n  }\n]\n```\n\n### docker部署\n\n##### 1 .创建文件夹\n\n```\nmkdir -p $PWD/coze-chat-proxy\n```\n\n##### 2.拉取镜像启动\n\n###### 注：AUTH_TOKEN自行替换；tag替换为release版本号，如：0.0.1\n\n```\ndocker run -itd  --name=coze-chat-proxy -p 8080:8080  -v $PWD/coze-chat-proxy:/data:/app/data -v $PWD/coze-chat-proxy/log:/app/log  -e AUTH_TOKEN=\u003cAUTH_TOKEN\u003e \\\nregistry.cn-hangzhou.aliyuncs.com/aurorax/coze-chat-proxy:\u003ctag\u003e\n```\n\n##### 3.修改`$PWD/coze-chat-proxy/data`目录下`bot.json`并重启容器\n\n## 接口\n\n#### /v1/chat/completions\n\n###### 支持返回stream和json\n\n```\nhttp://\u003cip\u003e:\u003cport\u003e/v1/chat/completions\n```\n\n##### 示例\n\n```\ncurl --location --request POST 'http://127.0.0.1:8080/v1/chat/completions' \\\n--header 'Authorization: Bearer ****' \\\n--header 'User-Agent: Apifox/1.0.0 (https://apifox.com)' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n    \"model\": \"gpt-3.5-turbo\",\n    \"messages\": [\n        {\n            \"role\": \"user\",\n            \"content\": \"西红柿炒钢丝球怎么做？\"\n        }\n    ],\n    \"stream\": false,\n}'\n```\n\n#### /v1/images/generations\n\n###### 仅支持返回json\n\n```\nhttp://\u003cip\u003e:\u003cport\u003e/v1/images/generations\n```\n\n##### 示例\n\n```\ncurl --location --request POST 'http://127.0.0.1:8080/v1/images/generations' \\\n--header 'Authorization: Bearer ****' \\\n--header 'User-Agent: Apifox/1.0.0 (https://apifox.com)' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n    \"model\": \"dall-e-3\",\n    \"prompt\": \"A cute dog\",\n    \"n\": 1,\n    \"size\": \"1024x1024\"\n}'\n```\n\n###### 注：此接口coze bot 需特殊设置，参考 [how_to_create_coze_agent](https://github.com/Feiyuyu0503/free-dall-e-proxy/blob/main/docs/how_to_create_coze_agent.md) 此配置稳定出图\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faurorax-neo%2Fcoze-chat-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faurorax-neo%2Fcoze-chat-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faurorax-neo%2Fcoze-chat-proxy/lists"}