The ai_model_usage core model exposes AI model usage events from the observability store.
Like audit_events, it is read-only and intended for analysis, dashboards, and monitoring rather than generic writes.
What This Model Represents¶
Rows include:
idtimestampprovidermodel_nameobjectiverequest_kinduser_idtotal_tokensduration_mssuccess
Detail rows also include:
session_idnode_idrequest_idcorrelation_idenginedeployment_modeagent_idprompt_tokenscompletion_tokenserrorchannel
Typical Use Cases¶
Use module_sdk.models.ai_model_usage when you need to:
- monitor model usage
- build dashboards for token and latency trends
- inspect failure details for one AI model request
The monitor module uses the model schema for AI model usage tables.
Listing Usage Events¶
Example:
listing = module_sdk.models.ai_model_usage.list(
page=0,
page_size=50,
filters={"provider": "openai", "success": True},
)Supported filters include:
providermodel_nameobjectiverequest_kindsuccessuser_id
The default sort is timestamp desc.
Viewing One Usage Event¶
Example:
row = module_sdk.models.ai_model_usage.view(event_id)Use this for detail pages or support/debug tooling where prompt/completion token counts, node identity, and error fields matter.
Write Operations Are Disabled¶
This model is read-only through the SDK. Usage events are generated by provider/runtime instrumentation, not by module code or ad-hoc CRUD calls.