Split out of appx-org/agent-client#2 (per-session usage/cost metrics), implemented in appx-org/agent-client#4.
AssistantMessage.usage.cost is often zero for custom LiteLLM-routed models, so consumers recalculate cost from per-million-token rates. AgentModelRow (GET /v1/sessions/models) and the model row embedded in GET .../sessions/{id}/settings expose contextWindow but no cost rates, which forces every consumer to maintain its own rates map (create-appx-app currently uses LITELLM_COST_*_PER_MILLION env vars plus a hard-coded gpt-5.5 default).
Proposal: add an optional cost object to AgentModelRow:
cost?: {
input: number; // USD per 1M input tokens
output: number; // USD per 1M output tokens
cacheRead: number; // USD per 1M cache-read tokens
cacheWrite: number; // USD per 1M cache-write tokens
}
pi's models.json already carries per-model cost for built-in providers, so for those this is just a passthrough; custom providers could accept the same shape in CustomProviderModel. Consumers would then drop their env-based rates maps and pass model.cost straight into agent-client's aggregateSessionUsage as costRates.
🤖 Generated with Claude Code
Split out of appx-org/agent-client#2 (per-session usage/cost metrics), implemented in appx-org/agent-client#4.
AssistantMessage.usage.costis often zero for custom LiteLLM-routed models, so consumers recalculate cost from per-million-token rates.AgentModelRow(GET /v1/sessions/models) and the model row embedded inGET .../sessions/{id}/settingsexposecontextWindowbut no cost rates, which forces every consumer to maintain its own rates map (create-appx-app currently usesLITELLM_COST_*_PER_MILLIONenv vars plus a hard-coded gpt-5.5 default).Proposal: add an optional
costobject toAgentModelRow:pi's models.json already carries per-model cost for built-in providers, so for those this is just a passthrough; custom providers could accept the same shape in
CustomProviderModel. Consumers would then drop their env-based rates maps and passmodel.coststraight into agent-client'saggregateSessionUsageascostRates.🤖 Generated with Claude Code