/**
 * Token-usage extraction from chat-completions responses and SSE streams.
 *
 * `captureFetchToRawSink` records the raw provider triple but deliberately does
 * not interpret token usage — cost is a per-consumer axis. Three consumers each
 * re-implement the same `usage` parser on top of the captured response (the
 * OpenAI `prompt_tokens`/`completion_tokens` shape, the Anthropic
 * `input_tokens`/`output_tokens` shape, and the camelCase variants), plus an
 * SSE accumulator that sums the per-chunk `usage` deltas. This is the one
 * canonical version.
 *
 * Both functions return `null` (not a silent `{ input: 0, output: 0 }`) when no
 * usage is present, so a caller can tell "no usage reported" from "zero tokens".
 */
export interface ExtractedUsage {
    input: number;
    output: number;
    /** Cached prompt tokens, when the provider reports them. */
    cached?: number;
}
/**
 * Pull `{ input, output, cached? }` from a parsed chat-completions response
 * body. Accepts a top-level `usage` object (the common case) or a body that IS
 * the usage object. Returns null when neither an input nor an output count is
 * present — callers must inspect for null rather than treat it as zero cost.
 */
export declare function extractUsage(body: unknown): ExtractedUsage | null;
/**
 * Sum token usage across an SSE response body. Each `data:` line is parsed and
 * fed to `extractUsage`; the per-chunk counts are accumulated. The `[DONE]`
 * sentinel and non-JSON lines are skipped. Returns null when no chunk carried
 * usage — distinguishing a usage-less stream from a genuine zero.
 *
 * Providers report SSE usage in two ways: a single terminal chunk with the full
 * totals, or incremental per-chunk deltas. Summing is correct for the delta
 * case and harmless for the terminal case (one non-null chunk ⇒ the total).
 */
export declare function extractUsageFromSse(text: string): ExtractedUsage | null;
/**
 * Extract usage from an HTTP `Response` without consuming the caller's body:
 * clones, reads the text, and tries the JSON parser first, then the SSE
 * accumulator. Best-effort — returns null on any read/parse miss so a usage tee
 * never takes down the underlying call.
 */
export declare function extractUsageFromResponse(response: Response): Promise<ExtractedUsage | null>;
//# sourceMappingURL=extract-usage.d.ts.map