Skip to content

API

API docs are at https://ask.serenitygpt.com/api/v2/docs/swagger

Ask a question

curl -X 'POST' \
  '<ROOT_URL>/api/v2/question/' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <INSERT_YOUR_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
  "question": "How to get started?"
}'

will return

{
  "question_id": "xxx",
  "chat_id": "yyy"
}

Then pass the returned question id:

curl -X 'GET' \
  '<ROOT_URL>/api/v2/question/xxx/' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <INSERT_YOUR_TOKEN>'

which will return

{
  "id": "xxx",
  "text": "How to get started ?",
  "response": "<...here will be a partial answer until is_read is true...>",
  "is_ready": true,
   ...
}

The full answer is available once is_ready is true.

Ask a follow-up question

To contintue the same conversation, pass the chat_id when you post a follow-up question.

curl -X 'POST' \
  '<ROOT_URL>/api/v2/question/' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <INSERT_YOUR_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
  "question": "What do I do next?",
  "chat_id", "yyy"
}'