Skip to main content
cs log-ai is how you manually tell CostHQ about an AI API call. You need this command whenever you are running a manual session or a custom agent workflow that is not already routing traffic through the CostHQ proxy. Each invocation creates one AI usage record attached to the active session (or to the session you specify with -s).

Usage

Flags

Examples

JSON Output

cs log-ai --json returns the logged usage entry plus a pricing object so you can verify how the cost was calculated:
pricing.source values When modelKnown is false, CostHQ cannot calculate cost automatically — you must supply -c <amount> or the entry will be recorded with cost: 0. Use cs pricing set to add a permanent custom price for that model so future calls calculate automatically.

Built-In Pricing Coverage

CostHQ ships with built-in pricing for 42+ models across Anthropic (Claude 3, Claude 3.5, Claude 4 families), OpenAI (GPT-4o, GPT-4, GPT-3.5, o1, o3 families), and OpenAI Codex. For the full list, run:
When you use cs run or the CostHQ proxy, cs log-ai is called automatically for every intercepted API call — you only need this command for manual sessions or custom agent workflows where you control the logging yourself.