Insights

Generate insights query from prompt

Translates a natural language prompt into an Insights SQL query.

post/insights/query/prompt

Request

  • Base URL: https://api.inngest.com/v2
  • URL: https://api.inngest.com/v2/insights/query/prompt
  • Auth: API key in header Authorization

Request body

promptstring

Natural language description of the query to generate

Example request

{
  "prompt": "Show me the top 10 functions by failure rate in the last 7 days"
}

Response

Query generated successfully

Example response

{
  "data": {
    "sql": "SELECT function_id, COUNT(*) AS total, countIf(status = 'Failed') AS failures, failures / total AS failure_rate FROM function_runs WHERE started_at >= now() - INTERVAL 7 DAY GROUP BY function_id ORDER BY failure_rate DESC LIMIT 10",
    "summary": "This query retrieves the top 10 functions with the highest failure rate over the past week, showing the total number of runs, number of failures, and calculated failure rate for each function."
  }
}

Changes

No recorded changes to this operation across all 2 revisions of this API.