g1t/services/billing/migrations/0030_token_usage.sql

23 lines951 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Mission control shows model usage, yours and the workspace's: tokens, cost, active days, cache share, each day, and the mix1-- Model tokens, added up per day and run, for usage views: the model proxy
2-- reports what each answer used. Billing still prices runs from AI
3-- Gateway, never from these.
4CREATE TABLE token_usage (
5 -- YYYY-MM-DD, UTC.
6 day TEXT NOT NULL,
7 workspace TEXT NOT NULL,
8 -- The person the run was for, by username; empty when nobody asked.
9 person TEXT NOT NULL DEFAULT '',
10 -- The model session's id, one per run (runs.session_id).
11 session TEXT NOT NULL,
12 model TEXT NOT NULL,
13 -- On g1t's hosted models: small or large.
14 tier TEXT,
15 input INTEGER NOT NULL DEFAULT 0,
16 output INTEGER NOT NULL DEFAULT 0,
17 cache_read INTEGER NOT NULL DEFAULT 0,
18 cache_write INTEGER NOT NULL DEFAULT 0,
19 requests INTEGER NOT NULL DEFAULT 0,
20 PRIMARY KEY (day, workspace, person, session, model)
21);
22CREATE INDEX token_usage_by_workspace_day ON token_usage (workspace, day);
23CREATE INDEX token_usage_by_person_day ON token_usage (workspace, person, day);