AriGPT API Documentation
You can make AriGPT requests using the official AriGPT API.
At any point AriGPT API may return a rate limiting response with HTTP code 429 and JSON:
{
"error": "You are being rate limited, please try again later"
}
For sample API usage see gptapi.py.
Routes:
GET /gpt/api/config-- Request configurationYou must call to this API every time you make a
POSTrequest. This request will return JSON:{ "nonce": "string", "difficulty": N, }And this route will return a
__Host-sessioncookie which you must include with every API call.With this JSON data, you must solve a Proof-of-Work challenge: find such ASCII string
Swith all digits (0-9) that is less or equal to 32 bytes but not empty, such thatSHA256(nonce + S).hex()starts with at leastdifficultyzero (0) characters.e.g.,
state: nonce = "9c2e" difficulty = 5 hence one possible solution, solution = "30078260" because, SHA256("9c2e" + "30078260") = SHA256("9c2e30078260") = "00000627dded0e0b3632ef7d0496e40ac34ac80dd42afa628eecd5b7414dee64"Proof-of-Work tokens expire after 16 minutes and cannot be re-used after one request. You must use a new token.
POST /gpt/api/query-- Post a new AriGPT queryYou must
POSTJSON data such that it has the following scheme:{ "solution": "... your proof of work solution", "prompt": "... your AriGPT prompt", }If you omit one or both of the keys, or omit the
__Host-sessioncookie, you will receive an error response with HTTP code 400 and a JSON body including a human readable error in the"error"key. On invalid Proof-of-Work solution, you will also receive an error JSON response with HTTP code 401.On success, you will receive a JSON response in the following scheme:
{ "id": "... uuid" }e.g.,
{ "id": "27b9ab92-db72-4eb3-a8f7-4d4f70297a10" }This is the question ID.
GET /gpt/api/answer/<id>-- Get AriGPT threadTo get an AriGPT question thread in JSON, make a request to this API. Upon request you will receive one of two responses:
- An error response (404): Returns a human readable error in the
"error"key with HTTP code 404. Indicates that the question has not been answered or does not exist yet. - A success response in the scheme:
{ "question": "... question", "answer": "... answer (markdown)", "answeree": "... Ari ID (e.g., af546cbf796eebbf3c03)", "time": ... timestamp, (optional) "files": [ { "filename": "filename", "mimetype": "some/mimetype", "size": ... file size in bytes }, { "filename": "filename1", "mimetype": "some/mimetype", "size": ... file size in bytes } ] }The question is the original question. The answer is the markdown answer by the answeree (an Ari). The timestamp is a UNIX timestamp indicating when the question was created. The optionally present
filesarray includes an array of filenames related to this question.- An error response (404): Returns a human readable error in the
GET /gpt/answer/<id>/file/<filename>-- Get file contentUpon request, this will return the file content of a requested file related to the question.
GET /gpt/api/stats-- Get statistics of AriGPTUpon request, this route will return JSON indicating AriGPT statistics useful for API usage:
{ "count": ... question count, "files": ... files count, "pages": ... pages count }GET /gpt/api/files- Get all files hosted on AriGPTUpon request this will return a JSON array of objects describing files and their relation to questions:
[ { "filename": "filename", "mimetype": "some/mimetype", "size": ... file size in bytes, "question": "question ID (e.g., 27b9ab92-db72-4eb3-a8f7-4d4f70297a10)", }, { "filename": "filename1", "mimetype": "some/mimetype", "size": ... file size in bytes, "question": "question ID (e.g., 27b9ab92-db72-4eb3-a8f7-5d4f70297a13)", }, ... ]GET /gpt/api/page/<n>-- Get a list of questions on a specific pageUpon request this route will return an array of JSON objects similar to the
/gpt/api/answer/<id>route, except multiple in one list:[ { "question": "... question", "answer": "... answer (markdown)", "answeree": "... Ari ID (e.g., af546cbf796eebbf3c03)", "time": ... timestamp, (optional) "files": [ { "filename": "filename", "mimetype": "some/mimetype", "size": ... file size in bytes }, { "filename": "filename1", "mimetype": "some/mimetype", "size": ... file size in bytes } ] }, { "question": "... question", "answer": "... answer (markdown)", "answeree": "... Ari ID (e.g., af546cbf796eebbf3c03)", "time": ... timestamp, (optional) "files": [ { "filename": "filename", "mimetype": "some/mimetype", "size": ... file size in bytes }, { "filename": "filename1", "mimetype": "some/mimetype", "size": ... file size in bytes } ] }, ... ]