askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
ai_usage.json · 2.3 KB · 69 lines
| 1 | { |
| 2 | "name": "ai_usage", |
| 3 | "title": "AI Usage", |
| 4 | "version": 2, |
| 5 | "description": "Append-only per-turn AI cost record: tokens and cost for one /api/ai/chat call. Written server-side by the chat handler itself (never by the client) so cost recording is authoritative -- a caller cannot omit or falsify it the way it could a client-written shell_commands row. cost_cents is null when the turn cannot be priced (no ai_prices row matched, an unknown cache rate, or a prompt above the row's price_max_prompt_tokens); tokens are always recorded regardless.", |
| 6 | "fields": [ |
| 7 | { |
| 8 | "name": "id" |
| 9 | }, |
| 10 | { |
| 11 | "name": "owner_id", |
| 12 | "type": "text", |
| 13 | "label": "Owner", |
| 14 | "help": "The user who made the chat call" |
| 15 | }, |
| 16 | { |
| 17 | "name": "provider", |
| 18 | "type": "text", |
| 19 | "required": true, |
| 20 | "label": "Provider" |
| 21 | }, |
| 22 | { |
| 23 | "name": "model", |
| 24 | "type": "text", |
| 25 | "required": true, |
| 26 | "label": "Model" |
| 27 | }, |
| 28 | { |
| 29 | "name": "tokens_in", |
| 30 | "type": "int", |
| 31 | "required": true, |
| 32 | "label": "Input Tokens" |
| 33 | }, |
| 34 | { |
| 35 | "name": "tokens_out", |
| 36 | "type": "int", |
| 37 | "required": true, |
| 38 | "label": "Output Tokens" |
| 39 | }, |
| 40 | { |
| 41 | "name": "tokens_cache_read", |
| 42 | "type": "int", |
| 43 | "label": "Cache Read Tokens", |
| 44 | "help": "Prompt tokens served from the provider's prompt cache. Reported beside tokens_in, not inside it, and billed at the cache-read rate" |
| 45 | }, |
| 46 | { |
| 47 | "name": "tokens_cache_write", |
| 48 | "type": "int", |
| 49 | "label": "Cache Write Tokens", |
| 50 | "help": "Prompt tokens written to the provider's prompt cache this turn. Reported beside tokens_in, not inside it, and billed at the cache-write rate" |
| 51 | }, |
| 52 | { |
| 53 | "name": "cost_cents", |
| 54 | "type": "int", |
| 55 | "label": "Cost (cents)", |
| 56 | "help": "Null when the turn cannot be priced: no ai_prices row matched (provider, model), the turn used prompt cache and the row has no rate for it, or a prompt went over the row's price_max_prompt_tokens. Tokens are still recorded" |
| 57 | }, |
| 58 | { |
| 59 | "name": "created_at", |
| 60 | "type": "datetime", |
| 61 | "label": "Created", |
| 62 | "read_only": true |
| 63 | } |
| 64 | ], |
| 65 | "views": { |
| 66 | "list_mode": "feed", |
| 67 | "list_fields": ["provider", "model", "tokens_in", "tokens_out", "tokens_cache_read", "tokens_cache_write", "cost_cents", "created_at"] |
| 68 | } |
| 69 | } |