Skip to content
19 linesCodeBlameRaw
1-- Search embeddings, reported to billing (src/embed-billing.ts): each
2-- workspace's month of embedding tokens (`doc_embed_usage`) goes to
3-- billing as source `context` at Workers AI's price, and a workspace
4-- without the plan is held to a monthly token budget.
5--
6-- Usage is kept by workspace id; billing knows workspaces by slug. The slug
7-- is noted whenever the service looks a workspace up, with the plan billing
8-- last said it is on (NULL before it has: held to the budget like a free
9-- one) and the month's tokens last reported.
10CREATE TABLE workspace_billing (
11 workspace_id TEXT PRIMARY KEY,
12 slug TEXT NOT NULL,
13 -- 'free' or 'paid'.
14 plan TEXT,
15 plan_at TEXT,
16 noted_month TEXT,
17 noted_tokens INTEGER NOT NULL DEFAULT 0,
18 noted_at TEXT
19);