Convert claude to chatgpt form api through Slack
Use the Slack API to send messages to Claude and receive his replies through the Slack API. Then, format the replies in the format of the chatgpt interface and return them to the user, allowing Claude to be used on any platform that supports the chatgpt API.
-
Create a "config" directory in the current directory and add an ".env" file, then fill it with the following content:
# .env CLAUDE_BOT_ID=your_CLAUDE_BOT_ID SLACK_USER_TOKEN=your_SLACK_USER_TOKEN TOKEN=your_TOKEN # any string you like SPLIT_STREAM=true # whether to split the stream, if false will return all the results at once, default true
-
Run
docker run -p 9000:9000 \ -d --restart=always \ --volume ./config:/config \ --name claude-api \ xkrfer/claude-in-slack-api
-
Test
curl --location 'http://127.0.0.1:9000/v1/chat/completions' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer token' \ --data '{ "model": "gpt-3.5-turbo", "messages": [ { "role": "user", "content": "hello" } ], "max_tokens": 100, "temperature": 1, "stream": true }'
-
If you need to reverse proxy using Nginx, you will need to add the following content to your Nginx configuration file:
location / { proxy_pass http://127.0.0.1:9000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header REMOTE-HOST $remote_addr; # support sse proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; chunked_transfer_encoding off; proxy_buffering off; proxy_cache off; proxy_redirect off; proxy_hide_header Cache-Control; }
-
Open https://web.chatboxapp.xyz and enter the address of your server, then you can chat with Claude.
Convert this service to HTTPS in order to avoid potential errors that may arise on other tools.
yokonsan/claude-in-slack-api
jtsang4/claude-to-chatgpt
Bin-Huang/chatbox
如何通过Dockerfile优化Nestjs镜像大小