Skip to main content

Usage Overview

Track AI token consumption and cost estimates across your workspace with aggregate usage stats and per-document breakdowns via the Talonic Usage API endpoints.

The Usage API provides visibility into AI token consumption and cost estimates across your workspace. Every AI operation — extraction, classification, matching, resolution — is metered and logged with input/output token counts, the model used, and an estimated USD cost. Use these endpoints to monitor spending, optimize pipeline configuration, and audit AI operations.

Four endpoints cover aggregate, document, pipeline, and run views. The aggregate endpoint returns workspace-wide totals with a breakdown by operation type and model over a configurable date range. The per-document endpoint drills into a specific document to show every AI call made during its processing lifecycle, including cache token utilization and per-operation cost estimates. The per-pipeline and per-run endpoints (below) narrow the same accounting to one pipeline or one /v1/run request, so a single Spec run or a single ingest call can be costed in isolation.

Cost estimates are computed from the model-specific token pricing at the time of the API call. Input tokens, output tokens, cache read tokens, and cache creation tokens are each priced at their respective rates — cache creation (prompt cache writes) bills at 1.25× the fresh input rate. Cache read tokens represent prompt cache hits where previously cached input was reused at a significantly lower rate than fresh input tokens — high cache utilization indicates efficient prompt reuse across similar documents.

Usage data is available immediately after each AI operation completes. There is no delay or batching — the token counts and cost estimates are recorded synchronously as part of the operation lifecycle. Historical data is retained indefinitely and can be queried over any date range.

cost_estimate_usd (returned by the document, pipeline, and run endpoints) is Talonic's own estimate of the underlying AI provider's charge for the tokens billed on that call — a provider-cost figure, computed from model-specific per-token pricing. It is a different currency from GET /v1/usage/credits, which reports your organization's own credit-ledger consumption (the price Talonic charges you). The two numbers do not reconcile against each other: one estimates what Talonic pays its model provider, the other reports what your workspace spent in credits.

Usage tracking is automatic and requires no configuration. Every AI operation performed by the platform (extraction, classification, triage, resolution, matching) is metered and available through these endpoints.
There are two usage views. This endpoint (GET /v1/usage) reports raw AI token and call counts. GET /v1/usage/credits (see Credit Usage below) reports per-function CREDIT consumption from your organization's credit ledger. Use the first to understand token cost, the second to see where credits went.
Model and cost visibility are gated by your organization's "Cost control endpoints" approval. Without it, the aggregate and per-document endpoints stay available but redact model and every cost field (the response carries "cost_fields": "redacted"), and the per-pipeline and per-run endpoints below return 404 — their existence is not advertised to unapproved organizations. Approved organizations also need an API key carrying the usage scope to call the per-pipeline and per-run endpoints; the usage scope is grantable only through owner+ key management, not via self-serve key creation. Organizations carry the approval by default; shared individual workspaces do not.
GET/v1/usage

Query parameters

fromstringISO 8601 date for the start of the period (default: 30 days ago).
tostringISO 8601 date for the end of the period (default: now).

Aggregate Response

Response fields

period.fromstringISO 8601 start of the reporting period.
period.tostringISO 8601 end of the reporting period.
totals.input_tokensintegerTotal UNCACHED input tokens consumed across all operations (cached tokens are reported separately).
totals.output_tokensintegerTotal output tokens produced across all operations.
totals.cache_read_tokensintegerTotal tokens served from the provider prompt cache. Captured from provider response metadata, never assumed.
totals.cache_creation_tokensintegerTotal tokens written to the provider prompt cache (Anthropic prompt caching only; 0 for other providers).
totals.callsintegerTotal number of AI operations performed.
breakdownarrayPer-operation-type and per-model usage breakdown.
breakdown[].operation_typestringOperation category (e.g. extraction, classification, matching).
breakdown[].modelstringAI model used for this operation group.
breakdown[].input_tokensintegerUncached input tokens consumed by this group.
breakdown[].output_tokensintegerOutput tokens produced by this group.
breakdown[].cache_read_tokensintegerPrompt cache read tokens for this group.
breakdown[].cache_creation_tokensintegerPrompt cache write tokens for this group (Anthropic only).
breakdown[].callsintegerNumber of calls in this group.
cost_fieldsstringOnly present, set to `"redacted"`, for organizations without the "Cost control endpoints" approval — signals that `breakdown[].model` has been omitted from every row. Absent for approved organizations.
links.selfstringSelf-link to this endpoint.

Response — Aggregate usage

{
  "period": { "from": "2026-04-14T00:00:00.000Z", "to": "2026-05-14T00:00:00.000Z" },
  "totals": { "input_tokens": 8940120, "output_tokens": 1274580, "cache_read_tokens": 3120040, "cache_creation_tokens": 421800, "calls": 2764 },
  "breakdown": [
    {
      "operation_type": "extraction",
      "model": "claude-sonnet-4-20250514",
      "input_tokens": 7896420,
      "output_tokens": 1127040,
      "cache_read_tokens": 2988100,
      "cache_creation_tokens": 398200,
      "calls": 1842
    },
    {
      "operation_type": "classification",
      "model": "claude-haiku-3-5",
      "input_tokens": 1043700,
      "output_tokens": 147540,
      "cache_read_tokens": 131940,
      "cache_creation_tokens": 23600,
      "calls": 922
    }
  ],
  "links": { "self": "/v1/usage" }
}

Per-Document Usage

The per-document endpoint returns every AI operation performed on a specific document along with token counts, cache utilization, and cost estimates. This is useful for understanding why a particular document was expensive to process — for example, a large multi-page PDF that required multiple extraction chunks, or a document that triggered classification retries.

GET/v1/usage/documents/:id

Path parameters

iduuidThe document UUID.

Document Response

Response fields

document_idstringUUID of the document.
totals.input_tokensintegerTotal UNCACHED input tokens across all operations for this document (cached tokens are reported separately).
totals.output_tokensintegerTotal output tokens across all operations for this document.
totals.cache_read_tokensintegerTotal prompt cache read tokens for this document.
totals.cache_creation_tokensintegerTotal prompt cache write tokens for this document (Anthropic only).
totals.cost_estimate_usdnumberTotal estimated cost in USD for all operations on this document. Omitted for organizations without the "Cost control endpoints" approval.
totals.callsintegerTotal number of AI operations performed on this document.
entriesarrayIndividual AI operation log entries.
entries[].idstringLog entry UUID.
entries[].operation_typestringOperation category (e.g. extraction, classification).
entries[].modelstringAI model used for this operation. Omitted for organizations without the "Cost control endpoints" approval.
entries[].input_tokensintegerInput tokens consumed.
entries[].output_tokensintegerOutput tokens produced.
entries[].cache_read_tokensintegerPrompt cache read tokens (reused cached input). Captured from provider response metadata, never assumed.
entries[].cache_creation_tokensintegerPrompt cache write tokens (Anthropic prompt caching only; 0 for other providers).
entries[].cost_estimate_usdnumberEstimated cost in USD for this operation. Omitted for organizations without the "Cost control endpoints" approval.
entries[].created_atstringISO 8601 timestamp of the operation.
cost_fieldsstringOnly present, set to `"redacted"`, for organizations without the "Cost control endpoints" approval — signals that `model` and every `cost_estimate_usd` field have been omitted. Absent for approved organizations.
links.selfstringSelf-link to this document usage endpoint.
links.documentstringLink to the document resource.

Response — Per-document usage

{
  "document_id": "d4e5f6a7-b8c9-0123-d456-e7f8a9b0c1d2",
  "totals": {
    "input_tokens": 12480,
    "output_tokens": 1890,
    "cache_read_tokens": 2048,
    "cache_creation_tokens": 1024,
    "cost_estimate_usd": 0.058,
    "calls": 3
  },
  "entries": [
    {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "operation_type": "extraction",
      "model": "claude-sonnet-4-20250514",
      "input_tokens": 8640,
      "output_tokens": 1245,
      "cache_read_tokens": 2048,
      "cache_creation_tokens": 1024,
      "cost_estimate_usd": 0.041,
      "created_at": "2026-05-13T14:22:10.000Z"
    },
    {
      "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "operation_type": "classification",
      "model": "claude-haiku-3-5",
      "input_tokens": 3840,
      "output_tokens": 645,
      "cache_read_tokens": 0,
      "cache_creation_tokens": 0,
      "cost_estimate_usd": 0.017,
      "created_at": "2026-05-13T14:21:45.000Z"
    }
  ],
  "links": {
    "self": "/v1/usage/documents/d4e5f6a7-b8c9-0123-d456-e7f8a9b0c1d2",
    "document": "/v1/documents/d4e5f6a7-b8c9-0123-d456-e7f8a9b0c1d2"
  }
}

Per-Pipeline Usage

The per-pipeline endpoint returns AI usage for one pipeline: totals, a breakdown by operation type and model, and a per-document rollup. This is the view to reach for when you want to cost a single Spec run in isolation — for example, comparing the actual spend of two pipeline configurations, or checking a pipeline against a budget before scaling it up.

Gated. Requires your organization's "Cost control endpoints" approval — without it this route returns 404 (its existence is not advertised) — and an API key carrying the usage scope (403 otherwise). The usage scope is grantable only through owner+ key management; it cannot be self-minted and is never included in a self-serve key's default scopes.
GET/v1/usage/pipelines/:id

Path parameters

iduuidThe pipeline UUID.

Query parameters

fromstringISO 8601 date for the start of the period (default: last 90 days).
tostringISO 8601 date for the end of the period (default: now).

Pipeline Response

Response fields

pipeline_idstringUUID of the pipeline.
period.fromstringISO 8601 start of the reporting period.
period.tostringISO 8601 end of the reporting period.
scopestringFixed code identifying the attribution rule: always `pipeline_calls_only` on this endpoint.
scope_notestringHuman-readable statement of what this response covers: pipeline-stamped calls only. The ingest OCR leg (shared across runs) is excluded by design.
totals.input_tokensintegerTotal input tokens across all pipeline-stamped calls.
totals.output_tokensintegerTotal output tokens across all pipeline-stamped calls.
totals.cache_read_tokensintegerTotal prompt cache read tokens (reused cached input).
totals.cache_creation_tokensintegerTotal prompt cache write tokens, billed at 1.25× the fresh input rate.
totals.callsintegerTotal number of AI operations attributed to the pipeline.
totals.cost_estimate_usdnumberTotal estimated cost in USD across all pipeline-stamped calls.
breakdownarrayPer-operation-type and per-model usage breakdown, same shape as the aggregate endpoint plus cache and cost fields.
documentsarrayPer-document rollup of the same pipeline-stamped calls.
documents[].document_idstringUUID of the document.
documents[].filenamestringThe document's filename, or null if it could not be resolved.
documents[].input_tokensintegerInput tokens attributed to this document.
documents[].output_tokensintegerOutput tokens attributed to this document.
documents[].callsintegerNumber of calls attributed to this document.
documents[].cost_estimate_usdnumberEstimated cost in USD attributed to this document.
links.selfstringSelf-link to this endpoint.
links.pipelinestringLink to the pipeline resource.

Response — Pipeline usage

{
  "pipeline_id": "b3c4d5e6-f7a8-9012-bcde-f34567890123",
  "period": { "from": "2026-04-22T00:00:00.000Z", "to": "2026-07-21T00:00:00.000Z" },
  "scope": "pipeline_calls_only",
  "scope_note": "Calls stamped with this pipeline id in call metadata. The shared ingest OCR leg is excluded.",
  "totals": {
    "input_tokens": 428900,
    "output_tokens": 61240,
    "cache_read_tokens": 112000,
    "cache_creation_tokens": 18500,
    "calls": 96,
    "cost_estimate_usd": 2.14
  },
  "breakdown": [
    {
      "operation_type": "extraction",
      "model": "claude-sonnet-4-20250514",
      "input_tokens": 402100,
      "output_tokens": 57980,
      "cache_read_tokens": 112000,
      "cache_creation_tokens": 18500,
      "calls": 84,
      "cost_estimate_usd": 2.01
    },
    {
      "operation_type": "resolution",
      "model": "claude-haiku-3-5",
      "input_tokens": 26800,
      "output_tokens": 3260,
      "cache_read_tokens": 0,
      "cache_creation_tokens": 0,
      "calls": 12,
      "cost_estimate_usd": 0.13
    }
  ],
  "documents": [
    {
      "document_id": "d4e5f6a7-b8c9-0123-d456-e7f8a9b0c1d2",
      "filename": "invoice-04521.pdf",
      "input_tokens": 12480,
      "output_tokens": 1890,
      "calls": 3,
      "cost_estimate_usd": 0.058
    }
  ],
  "links": {
    "self": "/v1/usage/pipelines/b3c4d5e6-f7a8-9012-bcde-f34567890123",
    "pipeline": "/v1/pipelines/b3c4d5e6-f7a8-9012-bcde-f34567890123"
  }
}

Per-Run Usage

The per-run endpoint returns AI usage for one /v1/run request — the same shape as the per-pipeline endpoint, keyed by the run request id instead of the pipeline id. Use it when you submitted documents through POST /v1/run and want to cost that specific call, independent of whatever else is happening on the underlying pipeline.

A run that is still ingesting, or that failed before a pipeline was created, has a null pipeline_id; the endpoint still returns 200 with zero totals and a scope_note explaining why, rather than 404, since pollers hit this window constantly. A legacy run request that predates per-request document tracking (no documents[] echo recorded) returns the same zero-total shape with its own scope_note, even when pipeline_id is set. Attribution otherwise intersects the run's pipeline stamp, the run's own documents[] echo, and the run's active time window (open-ended while the run is live; bounded a few minutes past updated_at once terminal) — this is documented as approximate under shared-pipeline concurrency (append mode, or several runs targeting the same pipeline). A document skipped by dedup or extraction-reuse legitimately shows up with all-zero counts.

Gated identically to the per-pipeline endpoint. Requires your organization's "Cost control endpoints" approval (404 otherwise) and an API key carrying the usage scope (403 otherwise, approved organizations only).
GET/v1/usage/runs/:id

Path parameters

iduuidThe /v1/run request id (the run_id returned by POST /v1/run and GET /v1/run/:id).

Query parameters

fromstringISO 8601 date for the start of the period (default: last 90 days).
tostringISO 8601 date for the end of the period (default: now).

Run Response

Response fields

run_idstringUUID of the /v1/run request.
pipeline_idstringUUID of the pipeline the run resolved to, or null while still ingesting / if it failed before a pipeline was created.
period.fromstringISO 8601 start of the reporting period.
period.tostringISO 8601 end of the reporting period.
scopestringFixed code identifying the attribution rule: always `run_attributed_calls` on this endpoint.
scope_notestringHuman-readable attribution statement: pipeline-stamped calls limited to this run's documents and time window, approximate under shared-pipeline concurrency. Explains the zero-totals case (still ingesting, failed pre-pipeline, or a legacy echo-less run) when applicable.
totals.input_tokensintegerTotal input tokens attributed to the run. Zero if still ingesting or failed pre-pipeline.
totals.output_tokensintegerTotal output tokens attributed to the run.
totals.cache_read_tokensintegerTotal prompt cache read tokens (reused cached input).
totals.cache_creation_tokensintegerTotal prompt cache write tokens, billed at 1.25× the fresh input rate.
totals.callsintegerTotal number of AI operations attributed to the run.
totals.cost_estimate_usdnumberTotal estimated cost in USD attributed to the run.
breakdownarrayPer-operation-type and per-model usage breakdown, same shape as the per-pipeline endpoint.
documentsarrayPer-document rollup, limited to this run's documents[] echo. A dedup/extraction-reuse-skipped document legitimately appears with all-zero counts.
documents[].document_idstringUUID of the document.
documents[].filenamestringThe document's filename. Omitted on the zero-totals placeholder rows returned for a still-ingesting/pre-pipeline or legacy echo-less run.
documents[].input_tokensintegerInput tokens attributed to this document.
documents[].output_tokensintegerOutput tokens attributed to this document.
documents[].callsintegerNumber of calls attributed to this document.
documents[].cost_estimate_usdnumberEstimated cost in USD attributed to this document.
links.selfstringSelf-link to this endpoint.
links.runstringLink to poll the /v1/run request (GET /v1/run/:id).

Response — Run usage (still ingesting)

{
  "run_id": "c4d5e6f7-a8b9-0123-cdef-456789012345",
  "pipeline_id": null,
  "period": { "from": "2026-04-22T00:00:00.000Z", "to": "2026-07-21T00:00:00.000Z" },
  "scope": "run_attributed_calls",
  "scope_note": "No pipeline exists for this run yet (still ingesting, or failed before pipeline creation) — no attributable LLM calls.",
  "totals": {
    "input_tokens": 0,
    "output_tokens": 0,
    "cache_read_tokens": 0,
    "cache_creation_tokens": 0,
    "calls": 0,
    "cost_estimate_usd": 0
  },
  "breakdown": [],
  "documents": [
    { "document_id": "d4e5f6a7-b8c9-0123-d456-e7f8a9b0c1d2", "input_tokens": 0, "output_tokens": 0, "calls": 0, "cost_estimate_usd": 0 }
  ],
  "links": {
    "self": "/v1/usage/runs/c4d5e6f7-a8b9-0123-cdef-456789012345",
    "run": "/v1/run/c4d5e6f7-a8b9-0123-cdef-456789012345"
  }
}

Example Request

cURL — Aggregate usage for the last 7 days

curl "https://api.talonic.com/v1/usage?from=2026-06-26T00:00:00Z&to=2026-07-03T00:00:00Z" \
  -H "Authorization: Bearer $TALONIC_API_KEY"

cURL — Pipeline usage (usage-scoped key)

curl "https://api.talonic.com/v1/usage/pipelines/b3c4d5e6-f7a8-9012-bcde-f34567890123" \
  -H "Authorization: Bearer $TALONIC_USAGE_SCOPED_KEY"

Errors

Error responses

401unauthorizedMissing or invalid API key.
403forbiddenPer-pipeline and per-run endpoints only: the org has Cost control endpoints approval but the API key lacks the usage scope.
404not_foundAggregate/per-document: no usage records exist for the document. Per-pipeline/per-run: the pipeline or run is not owned by your organization, OR your organization lacks the Cost control endpoints approval (the route is hidden, not merely forbidden — this check runs before the scope check, so an unapproved org never sees a 403 naming the usage scope).
429rate_limitedToo many requests. Retry after the period indicated in the Retry-After header.