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"
}'

Search API for Distributed RAG

The /api/v2/rag/search/ endpoint allows SereninyGPT to query documents for a given tenant via API. This is useful when you want to:

  • Use documentation stored on a remote machine
  • Share documentation across multiple SerenityGPT instances
  • Enable cross-tenant or cross-project search

See configuration for more details.

Note: This endpoint is intended for use by other backend services, not for direct user queries

Endpoint

POST /api/v2/rag/search/

Request Body

{
  "query": "How to get started?",
  "filters": { ... },
  "search_mode": "semantic",  // or "keyword"
  "question_metadata": { ... }
}

Example Request

curl -X POST \
  '<ROOT_URL>/api/v2/rag/search/' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <YOUR_API_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
    "query": "How to get started?",
    "search_mode": "semantic"
  }'