---
title: "Execute Agent Insights free-form SQL"
method: POST
path: "/v1/internal/analytics-queries/projects/{projectId}"
tags: ["System analytics queries"]
---

# Execute Agent Insights free-form SQL

`POST /v1/internal/analytics-queries/projects/{projectId}`

Runs Ollie-generated read-only SQL bounded to the caller's workspace and the requested project. Returns 501 when the Agent Insights toggle is off.

## Path parameters

- `projectId` string, uuid, required

## Request body

- AnalyticsQueryRequest
  - `query` string, required — Read-only ClickHouse SQL. Must return exactly one column named `result` produced via toJSONString(...)

## Response `200`

Query results

- AnalyticsQueryResponse
  - `results` JsonNode[]

## Other responses

- `400` — Bad Request
- `422` — Unprocessable Content
- `501` — Agent Insights queries are not enabled

---

[API](https://skmtc.net/comet-ml/apis/opik-rest-api.md) · [All operations](https://skmtc.net/comet-ml/apis/opik-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/comet-ml/opik-rest-api/versions/4ed2fbc97cc3/schema)
