import_session_usage
Bulk-import a completed session's usage in a single call — the retroactive counterpart to record_usage, for when a session wasn't instrumented live. Use when a calling agent (e.g. VS Code Copilot Chat) already has a session's turn-by-turn history in its own local store and wants this server to report on it exactly as if it had been tracked live. Accepts a list of entries under one shared session_id; each entry resolves its input and output tokens independently, either from exact counts when known or by estimating from raw turn text using this server's existing token counter. Cost is always computed server-side from current pricing, never trusted from the caller. A malformed entry (no usable tokens/text on one side, or an unresolvable model_name) is reported as its own per-entry failure and does not fail the rest of the batch. Idempotent like record_usage — resubmitting the same entries (same request_id, or the same session_id/model/occurred_at/token-or-text when request_id is omitted) is a no-op. Recorded usage is then readable via analyze_session_usage and GET /usage/session/{session_id}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| org_id | No | Optional organisation ID to attribute this usage to | |
| entries | Yes | Usage entries to import, one per turn/call in the session | |
| session_id | Yes | Shared session ID to tag every entry in this batch with |