- Every question asked of Claude is recorded: when, the kind of list, the model, the tokens read and written (also for an answer that was no name but was billed) and how it ended: a name made, a name taken from the kept ones, or a failure and why. Nothing of the facts that were sent is recorded. Records older than a year are removed (migration 0022). - GET /providers/anthropic/usage (admin) gives the totals of the last days (1 to 365, 30 by default), a row for each day with calls and an estimate of the cost in dollars, worked out from the tokens and the price of the model. It says it is an estimate and flags calls to a model whose price is not known. - A Costs section in the admin area shows the last 7, 30 or 90 days.
17 lines
910 B
SQL
17 lines
910 B
SQL
-- What the calls to Claude cost: one row for each question asked of the provider, with the tokens that were billed and how
|
|
-- it ended. Nothing of the facts that were sent is kept: no artist, no genre, no name. Rows older than a year are removed.
|
|
|
|
CREATE TABLE claude_usage (
|
|
id INTEGER PRIMARY KEY,
|
|
at INTEGER NOT NULL, -- unix seconds
|
|
kind TEXT NOT NULL, -- playlist, mix or smart
|
|
model TEXT NOT NULL,
|
|
outcome TEXT NOT NULL, -- made, kept or failed
|
|
reason TEXT NOT NULL DEFAULT '',-- for a failure
|
|
input_tokens INTEGER NOT NULL DEFAULT 0,
|
|
output_tokens INTEGER NOT NULL DEFAULT 0,
|
|
cache_read_tokens INTEGER NOT NULL DEFAULT 0,
|
|
cache_write_tokens INTEGER NOT NULL DEFAULT 0
|
|
);
|
|
|
|
CREATE INDEX idx_claude_usage_at ON claude_usage(at);
|