- Install Go
go install github.com/ChatGPT-Hackers/ChatGPT-API-server@latest
git clone https://github.com/ChatGPT-Hackers/ChatGPT-API-server/
cd ChatGPT-API-server
go install .
ChatGPT-API-server <port> <ADMIN_KEY>
The admin key can be anything you want. It's just for authenticating yourself.
Take note of your IP address or domain name. This could be localhost
or a remote IP address. The default port is 8080
Check out our firefox agent. More versions in the works.
There is also a Python based client by @ahmetkca (WIP)
(After connecting agents)
$ curl "http://localhost:8080/api/ask" -X POST --header 'Authorization: <SECRET_KEY>' -d '{"content": "Hello world", "conversation_id": "<optional>", "parent_id": "<optional>"}'
router.GET("/client/register", handlers.Client_register) // Used by agent
router.POST("/api/ask", handlers.API_ask) // For making ChatGPT requests
router.GET("/api/connections", handlers.API_getConnections) // For debugging
router.POST("/admin/users/add", handlers.Admin_userAdd) // Adds an API token
router.POST("/admin/users/delete", handlers.Admin_userDel) // Invalidates a token (based on user_id)
router.GET("/admin/users", handlers.Admin_usersGet) // Get all users
N/A. Used for websocket
Headers: Authorization: <USER_TOKEN>
The user token can be set by the admin via /admin/users/add. You can also use the admin key as the token. Both work by default
Data:
{
"content": "Hello world",
"conversation_id": "<optional>",
"parent_id": "<optional>"
}
Do not enter conversation or parent id if not available.
Response:
{
"id": "",
"response_id": "<UUID>",
"conversation_id": "<UUID>",
"content": "<string>",
"error": ""
}
Headers: None
Data: None
Response:
{
"connections": [
{
"Ws": {},
"Id": "<UUID>",
"Heartbeat": "<Time string>",
"LastMessageTime": "<Time string>"
}
]
}
Headers: None
Data:
{
"admin_key": "<string>"
}
Response:
{
"user_id": "<UUID>",
"token": "<UUID>"
}
Headers: None
Data:
{
"admin_key": "<string>",
"user_id": "<UUID>"
}
Response:
{ "message": "User deleted" }
Parameters: ?admin_key=<string>
Example usage: curl "http://localhost:8080/admin/users?admin_key=some_random_key"
Response:
{
"users": [
{
"user_id": "<UUID>",
"token": "<UUID>"
},
{
"user_id": "<UUID>",
"token": "<UUID>"
},
{
"user_id": "<UUID>",
"token": "<UUID>"
},
{
"user_id": "<UUID>",
"token": "<UUID>"
},
...
]
}
open docker-compose.yml
and add your own custom api-key in <api-key>
section
version: "3"
services:
chatgpt-api-server:
build: .
ports:
- "8080:8080"
command: ["ChatGPT-API-server", "8080", "<api-key>"]
then run:
docker-compose up
or docker-compose up -d
(if you want a persistent instance)