usage


Description

{“what”:“One row per LLM API call, with token counts, cost, and latency.”,“why”:“Without it, no auditable record of model usage for cost allocation and monitoring.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:08.638231509+00:00”}

Columns

Column Type Size Nulls Auto Default Children Parents Comments
id bigserial 19 √ nextval('usage_id_seq'::regclass)

{“what”:“Surrogate primary key, auto-incrementing integer.”,“why”:“Uniquely identifies each usage row for joins and updates.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:08.749568782+00:00”}

request_id uuid 2147483647 null

{“what”:“UUID of the originating API request.”,“why”:“Links usage to the caller’s request for debugging and deduplication.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:08.858560161+00:00”}

ts timestamptz 35,6 now()

{“what”:“Timestamp when the usage record was created.”,“why”:“Enables time-based aggregation and billing periods.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:08.893711602+00:00”}

provider text 2147483647 null

{“what”:“Name of the LLM provider (e.g., OpenAI, Anthropic).”,“why”:“Distinguishes costs and metrics across different vendors.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:08.919560123+00:00”}

route text 2147483647 null

{“what”:“API endpoint or route that handled the request.”,“why”:“Identifies which service feature generated the usage.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:08.946427948+00:00”}

model text 2147483647 null

{“what”:“Model identifier (e.g., gpt-4o, claude-3).”,“why”:“Needed to apply correct pricing and capacity planning.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:08.982568919+00:00”}

from_service text 2147483647 'unknown'::text

{“what”:“Internal service that initiated the request.”,“why”:“Allows per-team or per-service cost attribution.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:09.097597403+00:00”}

service_tier text 2147483647 √ null

{“what”:“Tier of service (e.g., free, pro) if applicable.”,“why”:“Differentiates pricing or quotas by customer tier.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:09.184589699+00:00”}

stream bool 1 false

{“what”:“Whether the response was streamed.”,“why”:“Streaming affects latency and cost calculation.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:09.204752810+00:00”}

status int4 10 null

{“what”:“HTTP status code of the API response.”,“why”:“Identifies failed requests for retry and error analysis.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:09.220422420+00:00”}

prompt_tokens int8 19 0

{“what”:“Number of tokens in the input prompt.”,“why”:“Basis for input cost and context length monitoring.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:09.266611250+00:00”}

completion_tokens int8 19 0

{“what”:“Number of tokens generated in the response.”,“why”:“Basis for output cost and generation length.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:09.311580159+00:00”}

cached_tokens int8 19 0

{“what”:“Tokens served from cache, if any.”,“why”:“Cache hits reduce cost; needed for accurate billing.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:09.459211565+00:00”}

reasoning_tokens int8 19 0

{“what”:“Tokens used for reasoning (e.g., chain-of-thought).”,“why”:“Separates reasoning cost from final output.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:09.551255679+00:00”}

cost_reported_usd float8 17,17 √ null

{“what”:“Cost reported by provider in USD.”,“why”:“Provides actual billed amount for reconciliation.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:09.648819059+00:00”}

cost_estimated_usd float8 17,17 0

{“what”:“Estimated cost in USD from internal pricing.”,“why”:“Used when provider cost is unavailable or delayed.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:09.666948197+00:00”}

ttft_ms int8 19 √ null

{“what”:“Time to first token in milliseconds.”,“why”:“Measures perceived latency for streaming responses.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:09.678617302+00:00”}

total_ms int8 19 null

{“what”:“Total request duration in milliseconds.”,“why”:“Monitors API performance and timeout issues.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:09.693926920+00:00”}

output_tok_s float8 17,17 √ null

{“what”:“Output tokens per second (completion_tokens / (total_ms - ttft_ms)).”,“why”:“Indicates generation speed for capacity planning.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:09.711723263+00:00”}

error text 2147483647 √ null

{“what”:“Error message or code if the request failed.”,“why”:“Provides failure reason for debugging and alerting.”,“by”:“fleet-annotator-worker”,“at”:“2026-09-23T04:04:09.729425310+00:00”}

Indexes

Constraint Name Type Sort Column(s)
usage_pkey Primary key Asc id
usage_model_idx Performance Asc/Desc model + ts
usage_provider_idx Performance Asc/Desc provider + ts
usage_ts_idx Performance Desc ts

Relationships