Getting started with AI SRE API

How AI SRE API works

Our API follows the JSON:API specification.

API requests to the AI SRE API are authorized using the Bearer Authentication standard: add an Authorization: Bearer $TOKEN header to your requests. The AI SRE API uses the same tokens as the Telemetry API.

Chats run asynchronously. Create a chat or reply to one and the request returns as soon as your message is saved, with the chat in the processing status. Then:

  1. Poll the chat status until it leaves processing.
  2. When the status is awaiting_confirmation, approve or deny each pending confirmation. The agent then continues and the status returns to processing.
  3. When the status is idle, get the chat and read the last ai message. Its text carries the answer as markdown and its artifacts carry any reports.

Write requests to the AI SRE API are limited to 100 per minute per token.

Get a global API token

A global API token is a token valid across all your teams, for managing anything within Better Stack.

With a global API token, pick the team with the team_name parameter, or with team_id set to the team ID shown in Better Stack URLs, like t123.

Global API tokens

Get a Telemetry API token

A Telemetry API token is a team-scoped token for managing your Telemetry resources, including AI SRE chats. You can get a separate API token for each of your teams.

Team-based tokens

Pagination

Lists come in pages, with a pagination object in the response body. To go through every page, request the URL in pagination.next until it's null. To get a specific page, pass the page query parameter.

Query parameters

Parameter Type Value
page Integer The page number to return, starting with 1.
per_page Integer Number of results per page. Defaults to 50, maximum 250, unless the endpoint says otherwise.

Response attributes

Attribute Type Value
pagination.first String The URL of the first page.
pagination.last String The URL of the last page.
pagination.prev String or null The URL of the previous page, or null on the first page.
pagination.next String or null The URL of the next page, or null on the last page.
pagination.total_count Integer The total number of results across all pages.

Example

Example cURL to list chats
curl --request GET \
  --url "https://chat.betterstack.com/api/v3/chats?page=3&per_page=20" \
  --header "Authorization: Bearer $TOKEN"


Example response body listing chats
{
  "data": [
    {
      "id": "41",
      "type": "chat",
      "attributes": {
        chat's attributes omitted...
      }
    },
    {
      "id": "42",
      "type": "chat",
      "attributes": {
        chat's attributes omitted...
      }
    }
  ],
  "pagination": {
    "first": "https://chat.betterstack.com/api/v3/chats?page=1&per_page=20",
    "last": "https://chat.betterstack.com/api/v3/chats?page=3&per_page=20",
    "prev": "https://chat.betterstack.com/api/v3/chats?page=2&per_page=20",
    "next": null
  }
}