CHouseUI
Using CHouse UIAgents

AI activity

What CHouse's own AI costs and sends out: tokens, estimated cost, ClickHouse queries and the data sent to LLM providers, per request.

In the app
AI Governance › AI activity/ai/usage
AI Governance › AI activity in CHouse UI
AI Governance › AI activity

AI Governance › AI activity (/ai/usage) shows what CHouse's own AI costs and what data it sends out: every request of the chat and of the AI features, with its tokens, estimated cost, the ClickHouse queries it ran and the data that went to the LLM provider. That includes AI features an MCP agent or the chouse CLI starts with a token (ai_optimize, doctor_scan, chouse ai optimize): each request says where it came from. What those agents do outside CHouse's AI is under Sessions.

Prompt and response text are not stored. The chat keeps the question and the final answer in its thread, as before.

Who sees what

PermissionSees
ai_usage:viewEveryone's AI requests. Admin and Super Admin have it
ai:chat or ai:optimizeTheir own requests only; the tab says Your AI requests

What the tab shows

SectionWhat it shows
TilesRequests, tokens (in and out), estimated cost, bytes ClickHouse read for the AI, and rows sent to providers
By originRequests, tokens and cost split by where they came from (see below)
Data sent to providersEach ClickHouse table, or CHouse record type (users, audit log, tokens…), that reached a model: columns, rows, users and providers. Most rows first; the top 100 are listed, with Top 100 of N when there are more, and the search finds any of them
Usage by modelRequests, tokens, the share of input served from the provider's cache, and cost per model
Recent AI requestsNewest first, 25, 50 or 100 per page. Each request with its user, agent, tokens, cost, ClickHouse read, rows sent and status; an MCP or token request also names its client and token. Filter by origin, and search by user, agent, feature, table, client or token name

Pick Today, 7 days or 30 days at the top. The two top panels keep the same size and scroll inside; so does a long page of requests.

Where a request came from

OriginStarted by
CHouse UISomeone signed in to the UI: the chat, or an AI button such as Optimize
MCP agentsAn agent over MCP, with a personal access token. The request names the agent (Claude Code, Cursor, …) and the token
Access tokensA direct token caller such as the chouse CLI or a script, named by its client and token
BackgroundCHouse itself: scheduled Doctor scans and automatic diagnoses
Not recordedRequests recorded before origins were tracked

A token that was deleted afterwards shows as a deleted token; its requests keep their origin.

Reading a request

Click a request to open it. Its steps read from Start at the top to Finished (or Timed out, Failed) at the bottom, in the order they began:

PartMeaning
#3 · +1.1sThe step's place in the order, and how long after the start it began
IndentationWho works for whom: a subagent's steps sit one level in from the agent that handed it the work, and a tool one level in from the agent that called it
✨ LLM callOne call to the model, by the agent named on it, with its tokens and cost
🔧 ToolOne tool call, with the data it returned to the model (Sent …) and the ClickHouse queries it ran
Hands to …The agent passed the work to a subagent
Calls …The agent asked for a tool
Answers …A subagent finished and passed its answer back up
Final answerThe step that produced the reply

Query logs on a query opens it in Query logs; a query on another connection names that connection instead, because Query logs reads the active one. For your own chat requests, Open in chat opens the conversation it came from.

How it is measured

  • Tokens are what the provider reports for each call. A call that times out, is stopped, or gets no usage from the provider counts no tokens; the request then shows ≥ and a note says the totals are a lower bound.
  • ClickHouse cost comes from each query's own statistics as it finishes, so it needs no access to system.query_log. Every query the AI runs gets a query_id starting chouse-ai- and an ai_request_id in its log_comment, so system.query_log ties it to the request too.
  • Data sent is everything a tool returned to the model, counted once per tool call. Sending the growing conversation back on later turns is already in the input tokens.

From agents, the CLI and the chat

The same data is available outside the tab, with the same permissions:

  • MCP: get_ai_usage, get_ai_data_egress, list_ai_requests and get_ai_request (see MCP tools).
  • CLI: chouse ai usage [--by origin|model], chouse ai egress, chouse ai requests [--origin …] and chouse ai request <id> (see CLI reference).
  • Chat: ask CHouse Admin, for example "what did MCP agents spend on AI this week?".

Prices

Cost is estimated from the price you give each model in Admin › AI Models › Provider models (USD per 1M tokens: input, output, and optionally cached input and cache write). See AI models.

  • A model without a price shows tokens but no cost (–, never $0), and a banner names it with a link to set one.
  • The Est. cost tile then sums the priced models only.
  • A price applies to requests from then on; past costs don't change.

Keeping data

Requests are kept for 30 days and then deleted, hourly, by every server. Change it with AI_USAGE_RETENTION_DAYS (1–365; see environment variables).

Edit this page on GitHub ↗