Ask AI SRE
const url = 'https://app.tunnelhq.com/api/v1/ai-sre/ask';const options = { method: 'POST', headers: { 'X-Project-Id': 'prj_12', 'X-API-Key': '<X-API-Key>', 'Content-Type': 'application/json' }, body: '{"question":"Why did it go down?","incident_id":"inc_418"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://app.tunnelhq.com/api/v1/ai-sre/ask \ --header 'Content-Type: application/json' \ --header 'X-API-Key: <X-API-Key>' \ --header 'X-Project-Id: prj_12' \ --data '{ "question": "Why did it go down?", "incident_id": "inc_418" }'Starts a new AI SRE conversation with your question, and answers at once with its id. AI SRE runs its own
checks, which takes from a few seconds to a few minutes. Read the answer with
Get an AI SRE conversation,
and read it again while running is true.
- Each answer counts toward the project’s monthly limit. A project has up to 3 answers being written at once.
- AI SRE changes nothing through the API. A change it suggests comes back with a link, and a person signed in to the dashboard approves it there. No route approves a change.
- Needs a role that can mute and pause monitors (Owner, Admin, and Manager by default). The key’s own person is the one who asked.
Need an API key? See Getting an API key.
Authorizations
Section titled “Authorizations”Parameters
Section titled “ Parameters ”Header Parameters
Section titled “Header Parameters”The project, as prj_12 or 12. A workspace key can only reach its own workspace’s projects.
Example
prj_12Request Bodyrequired
Section titled “Request Bodyrequired”object
The question, in plain words. A pasted list of servers fits whole.
The tunnel or check the question is about, as srv_81 or 81.
Files for this question, from Add a file to an AI SRE question, as att_91. Your own files, not yet sent. Up to 5, and 40 PDF pages across them.
The incident the question is about, as inc_418 or 418. The answer is kept with the incident, so asking about it again opens the same conversation, as Investigate does in the dashboard.
Example
{ "question": "Why did it go down?", "incident_id": "inc_418"}Responses
Section titled “ Responses ”The conversation is started, and its answer is being written.
object
The conversation.
The conversation’s page in the dashboard.
Example
{ "id": 54, "running": true, "url": "https://app.tunnelhq.com/ai-sre/c/54"}Headers
Section titled “Headers”Requests the workspace’s plan allows per minute.
Requests left in the current minute.
Unix time, in seconds, when the current minute ends.
The question is empty or too long, the monitor isn’t in the project, or the X-Project-Id header is missing or malformed.
object
The HTTP status, repeated.
What went wrong.
More detail, on some errors.
Seconds to wait, on the 429 for wrong keys.
Examples
{ "error": true, "code": 400, "message": "Write a question first."}{ "error": true, "code": 400, "message": "A question can be up to 20,000 characters. Add a longer list as a file."}{ "error": true, "code": 400, "message": "monitor_id must be a tunnel or check id, such as srv_81."}{ "error": true, "code": 400, "message": "That monitor isn't in this project."}The API key is missing, wrong, expired, switched off, or no longer valid.
object
The HTTP status, repeated.
What went wrong.
More detail, on some errors.
Seconds to wait, on the 429 for wrong keys.
Examples
{ "error": true, "code": 401, "message": "API key is required. Provide X-API-Key header or Authorization: Bearer <key>"}{ "error": true, "code": 401, "message": "Invalid or expired API key"}{ "error": true, "code": 401, "message": "API key has expired"}{ "error": true, "code": 401, "message": "API key owner account is inactive"}{ "error": true, "code": 401, "message": "This API key's workspace access has been removed"}The role can’t mute and pause monitors, which asking AI SRE needs, or the key can’t reach this project.
object
The HTTP status, repeated.
What went wrong.
More detail, on some errors.
Seconds to wait, on the 429 for wrong keys.
Examples
{ "error": true, "code": 403, "message": "Asking AI SRE needs a role that can mute and pause monitors."}{ "error": true, "code": 403, "message": "You do not have access to this project"}The project has used its answers for the month, already has 3 answers being written, or a usage limit was reached (see the other operations’ 429).
object
The HTTP status, repeated.
What went wrong.
More detail, on some errors.
Seconds to wait, on the 429 for wrong keys.
Examples
{ "error": true, "code": 429, "message": "This project has used all its AI SRE answers for this month. An owner can raise the limit in AI SRE settings."}{ "error": true, "code": 429, "message": "AI SRE is already answering 3 questions for this project. Ask again when one is done."}Something failed on TunnelHQ’s side.
object
The HTTP status, repeated.
What went wrong.
More detail, on some errors.
Seconds to wait, on the 429 for wrong keys.
Example
{ "error": true, "code": 500, "message": "Internal server error"}This TunnelHQ server can’t run AI SRE now.
object
The HTTP status, repeated.
What went wrong.
More detail, on some errors.
Seconds to wait, on the 429 for wrong keys.
Examples
{ "error": true, "code": 503, "message": "AI SRE is switched off on this server."}{ "error": true, "code": 503, "message": "AI SRE has no API key on this server."}