@usagetap/sdk 0.9.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 UsageTap
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -110,7 +110,7 @@ const response = await openai.responses.create({
110
110
  });
111
111
  ```
112
112
 
113
- Prefer a zero-boilerplate integration? Keep scrolling—`wrapOpenAI` applies the same entitlement-aware defaults if you omit `model` from your request.
113
+ Prefer a zero-boilerplate integration? Keep scrolling—`wrapOpenAI` applies the same entitlement-aware defaults if you omit `model` from your request.
114
114
 
115
115
  ```ts
116
116
  import { wrapOpenAI } from "@usagetap/sdk/openai";
@@ -121,10 +121,33 @@ const ai = wrapOpenAI(openai, usageTap, {
121
121
  feature: "chat.send",
122
122
  requested: { standard: true, premium: true, search: true, reasoningLevel: "HIGH" },
123
123
  },
124
- });
125
- ```
126
-
127
- > **Heads up:** `UsageTapClient` always negotiates the canonical UsageTap media type by sending `Accept: application/vnd.usagetap.v1+json`. Every response now uses the `{ result, data, correlationId }` envelope exclusively and the begin payload includes `data.idempotency.key` (always matching `callId`), per-meter snapshots, and subscription metadata. Set `autoIdempotency: false` (or pass your own `idempotency`) to skip the SDK's auto-generated key and rely on the server's deterministic fallback when retriable semantics are acceptable.
124
+ });
125
+ ```
126
+
127
+ ### Prompt compression
128
+
129
+ Prompt compression is an explicit step after `call_begin`. `beginCall` only starts the call and returns the `callId`; `promptCompress` compresses locally, records savings metadata against that call, and returns the compressed prompt for your vendor request. Raw prompt content is not sent to UsageTap.
130
+
131
+ ```ts
132
+ const begin = await usageTap.beginCall({
133
+ customerId: "cust_123",
134
+ feature: "chat.send",
135
+ });
136
+
137
+ const compressed = await usageTap.promptCompress({
138
+ callId: begin.data.callId,
139
+ input: "Please summarize this long prompt...",
140
+ });
141
+
142
+ const response = await openai.responses.create({
143
+ model: "gpt5-mini",
144
+ input: compressed.compressedInput as string,
145
+ });
146
+ ```
147
+
148
+ The default heuristic is conservative: it normalizes whitespace, preserves fenced code indentation, minifies valid embedded JSON, and converts eligible JSON data blocks to TOON when that is smaller. Pass `provider: "toon"` to force local TOON-style encoding for structured data. Savings include both character counts and approximate token counts using lightweight regex tokenization (`[\p{L}\p{N}]+|[^\s]`), not a model-specific BPE tokenizer. If compression or savings reporting fails, the SDK returns the original input with zero savings so the vendor call can continue.
149
+
150
+ > **Heads up:** `UsageTapClient` always negotiates the canonical UsageTap media type by sending `Accept: application/vnd.usagetap.v1+json`. Every response now uses the `{ result, data, correlationId }` envelope exclusively and the begin payload includes `data.idempotency.key` (always matching `callId`), per-meter snapshots, and subscription metadata. Set `autoIdempotency: false` (or pass your own `idempotency`) to skip the SDK's auto-generated key and rely on the server's deterministic fallback when retriable semantics are acceptable.
128
151
 
129
152
  ### Streaming helpers
130
153
 
@@ -414,8 +437,9 @@ Key exports from `@usagetap/sdk`:
414
437
  - `createCustomer` – idempotently ensure a customer subscription exists before starting a call.
415
438
  - `changePlan` – switch a customer to a different usage plan with configurable strategy (immediate reset, prorated, or scheduled).
416
439
  - `incrementCustomMeter` – track custom usage metrics beyond standard LLM counters (agent actions, documents, API calls, etc.).
417
- - `checkUsage` – lightweight method to query current usage status without creating a call session.
418
- - `wrapFetch` – wraps a fetch function to automatically instrument OpenAI API calls (minimal integration).
440
+ - `checkUsage` – lightweight method to query current usage status without creating a call session.
441
+ - `promptCompress` / `compressPromptToon` compress prompt input after `call_begin`, return the compressed payload, and record savings metadata for the call.
442
+ - `wrapFetch` – wraps a fetch function to automatically instrument OpenAI API calls (minimal integration).
419
443
  - `createIdempotencyKey` – helper for generating UsageTap-compatible idempotency keys.
420
444
  - Type definitions for canonical UsageTap request/response payloads.
421
445
 
@@ -1,5 +1,5 @@
1
1
  import OpenAI from 'openai';
2
- import { B as BeginCallRequest, U as UsageTapClient, W as WithUsageOptions, V as VendorHints, a as UsageTapSuccessResponse, b as BeginCallResponseBody, E as EndCallRequest } from '../client-CuzjFxMn.cjs';
2
+ import { B as BeginCallRequest, U as UsageTapClient, W as WithUsageOptions, V as VendorHints, a as UsageTapSuccessResponse, b as BeginCallResponseBody, E as EndCallRequest } from '../client-BHNMYvlO.cjs';
3
3
 
4
4
  interface OpenAIAdapterInit {
5
5
  client: OpenAI;
@@ -1,5 +1,5 @@
1
1
  import OpenAI from 'openai';
2
- import { B as BeginCallRequest, U as UsageTapClient, W as WithUsageOptions, V as VendorHints, a as UsageTapSuccessResponse, b as BeginCallResponseBody, E as EndCallRequest } from '../client-CuzjFxMn.js';
2
+ import { B as BeginCallRequest, U as UsageTapClient, W as WithUsageOptions, V as VendorHints, a as UsageTapSuccessResponse, b as BeginCallResponseBody, E as EndCallRequest } from '../client-BHNMYvlO.js';
3
3
 
4
4
  interface OpenAIAdapterInit {
5
5
  client: OpenAI;
@@ -1,6 +1,6 @@
1
1
  import { OpenAIAdapter } from './openai.cjs';
2
2
  import OpenAI from 'openai';
3
- import { U as UsageTapClient } from '../client-CuzjFxMn.cjs';
3
+ import { U as UsageTapClient } from '../client-BHNMYvlO.cjs';
4
4
 
5
5
  interface OpenRouterAdapterInit {
6
6
  client: OpenAI;
@@ -1,6 +1,6 @@
1
1
  import { OpenAIAdapter } from './openai.js';
2
2
  import OpenAI from 'openai';
3
- import { U as UsageTapClient } from '../client-CuzjFxMn.js';
3
+ import { U as UsageTapClient } from '../client-BHNMYvlO.js';
4
4
 
5
5
  interface OpenRouterAdapterInit {
6
6
  client: OpenAI;
@@ -34,6 +34,23 @@ interface MeterSummary {
34
34
  }
35
35
  type MeterSnapshot = Record<string, MeterSummary>;
36
36
  type RemainingRatios = Record<string, number | null | undefined>;
37
+ interface RollingCallsRateLimitState {
38
+ windowType: "rolling_calls";
39
+ limit: number;
40
+ used: number;
41
+ remaining: number;
42
+ windowSeconds: number;
43
+ state: "fresh" | "estimated" | "stale" | "unknown";
44
+ source?: "current_rolling_check" | "call_records";
45
+ nextAvailableAt?: string;
46
+ scope?: {
47
+ callType?: "standard" | "API";
48
+ tier?: "standard" | "premium";
49
+ };
50
+ }
51
+ interface RateLimitsSnapshot {
52
+ rollingCalls?: RollingCallsRateLimitState | Record<string, RollingCallsRateLimitState>;
53
+ }
37
54
  interface SubscriptionSnapshot {
38
55
  id: string | null;
39
56
  usagePlanVersionId: string | null;
@@ -64,6 +81,23 @@ interface VendorHints {
64
81
  maxInputTokens?: number;
65
82
  maxResponseTokens?: number;
66
83
  }
84
+ interface PromptCompressionRequest {
85
+ callId: string;
86
+ input: unknown;
87
+ provider?: "heuristic" | "toon" | "thetokencompany";
88
+ }
89
+ interface PromptCompressionTelemetry {
90
+ provider: "heuristic" | "toon" | "thetokencompany";
91
+ originalCharacters: number;
92
+ compressedCharacters: number;
93
+ savedCharacters: number;
94
+ originalTokens?: number;
95
+ compressedTokens?: number;
96
+ savedTokens?: number;
97
+ tokenSavingsRatio?: number;
98
+ savingsRatio: number;
99
+ techniques: string[];
100
+ }
67
101
  interface BeginCallRequest {
68
102
  customerId: string;
69
103
  requested?: RequestedEntitlements;
@@ -136,6 +170,7 @@ interface BeginCallResponseBody {
136
170
  policy: LimitType;
137
171
  allowed: AllowedEntitlements;
138
172
  entitlementHints: EntitlementHints;
173
+ rateLimits?: RateLimitsSnapshot;
139
174
  meters: MeterSnapshot;
140
175
  remainingRatios: RemainingRatios;
141
176
  subscription: SubscriptionSnapshot;
@@ -291,6 +326,10 @@ interface UsageTapClientOptions {
291
326
  * Allow constructing the client in browser-like environments for testing.
292
327
  */
293
328
  allowBrowser?: boolean;
329
+ /** API key for The Token Company Bear compression API. */
330
+ tokenCompanyApiKey?: string;
331
+ /** Override endpoint for The Token Company compatible compression APIs. */
332
+ tokenCompanyEndpoint?: string;
294
333
  }
295
334
  interface RequestOptions {
296
335
  signal?: AbortSignal;
@@ -303,6 +342,13 @@ interface BeginCallOptions extends RequestOptions {
303
342
  interface EndCallOptions extends RequestOptions {
304
343
  correlationId?: string;
305
344
  }
345
+ interface PromptCompressionOptions extends RequestOptions {
346
+ correlationId?: string;
347
+ }
348
+ interface PromptCompressionResponseBody extends PromptCompressionTelemetry {
349
+ callId: string;
350
+ updated: boolean;
351
+ }
306
352
  interface WithUsageContext {
307
353
  begin: UsageTapSuccessResponse<BeginCallResponseBody>;
308
354
  setUsage: (usage: Partial<Omit<EndCallRequest, "callId" | "error">>) => void;
@@ -330,6 +376,7 @@ interface CheckUsageResponseBody {
330
376
  policy: LimitType;
331
377
  allowed: AllowedEntitlements;
332
378
  entitlementHints: EntitlementHints;
379
+ rateLimits?: RateLimitsSnapshot;
333
380
  meters: MeterSnapshot;
334
381
  remainingRatios: RemainingRatios;
335
382
  subscription: SubscriptionSnapshot;
@@ -424,6 +471,35 @@ interface UsageMetricEvent {
424
471
  correlationId?: string;
425
472
  }
426
473
 
474
+ type PromptCompressionProvider = "heuristic" | "toon" | "thetokencompany";
475
+ interface PromptCompressionInput {
476
+ input: unknown;
477
+ provider?: PromptCompressionProvider;
478
+ tokenCompanyApiKey?: string;
479
+ tokenCompanyEndpoint?: string;
480
+ fetchImpl?: typeof fetch;
481
+ signal?: AbortSignal;
482
+ failOpen?: boolean;
483
+ }
484
+ interface PromptCompressionResult<TInput = unknown> {
485
+ input: TInput;
486
+ compressedInput: unknown;
487
+ provider: PromptCompressionProvider;
488
+ originalCharacters: number;
489
+ compressedCharacters: number;
490
+ savedCharacters: number;
491
+ originalTokens: number;
492
+ compressedTokens: number;
493
+ savedTokens: number;
494
+ tokenSavingsRatio: number;
495
+ savingsRatio: number;
496
+ techniques: string[];
497
+ }
498
+ declare function compressPrompt<TInput = unknown>(options: PromptCompressionInput): Promise<PromptCompressionResult<TInput>>;
499
+ declare function compressPromptHeuristic<TInput = unknown>(input: TInput): PromptCompressionResult<TInput>;
500
+ declare function compressPromptToon<TInput = unknown>(input: TInput): PromptCompressionResult<TInput>;
501
+ declare function estimatePromptTokens(input: unknown): number;
502
+
427
503
  declare class UsageTapClient {
428
504
  private readonly apiKey;
429
505
  private readonly baseUrl;
@@ -437,14 +513,20 @@ declare class UsageTapClient {
437
513
  private readonly metricFn?;
438
514
  private readonly authHeader;
439
515
  private readonly autoIdempotency;
516
+ private readonly tokenCompanyApiKey?;
517
+ private readonly tokenCompanyEndpoint?;
440
518
  constructor(options: UsageTapClientOptions);
441
519
  beginCall(request: BeginCallRequest, options?: BeginCallOptions): Promise<UsageTapSuccessResponse<BeginCallResponseBody>>;
520
+ promptCompress(request: PromptCompressionRequest, options?: PromptCompressionOptions): Promise<PromptCompressionResult & {
521
+ callId: string;
522
+ }>;
442
523
  endCall(request: EndCallRequest, options?: EndCallOptions): Promise<UsageTapSuccessResponse<EndCallResponseBody>>;
443
524
  checkUsage(request: CheckUsageRequest, options?: CheckUsageOptions): Promise<UsageTapSuccessResponse<CheckUsageResponseBody>>;
444
525
  createCustomer(request: CreateCustomerRequest, options?: CreateCustomerOptions): Promise<UsageTapSuccessResponse<CreateCustomerResponseBody>>;
445
526
  changePlan(request: ChangePlanRequest, options?: ChangePlanOptions): Promise<UsageTapSuccessResponse<ChangePlanResponseBody>>;
446
527
  incrementCustomMeter(request: IncrementCustomMeterRequest, options?: IncrementCustomMeterOptions): Promise<UsageTapSuccessResponse<IncrementCustomMeterResponseBody>>;
447
528
  withUsage<T>(beginRequest: BeginCallRequest, handler: (context: WithUsageContext) => Promise<T>, options?: WithUsageOptions): Promise<T>;
529
+ private toPromptCompressionTelemetry;
448
530
  private request;
449
531
  private requestGet;
450
532
  private performFetch;
@@ -457,4 +539,4 @@ declare class UsageTapClient {
457
539
  private toApiError;
458
540
  }
459
541
 
460
- export { type AllowedEntitlements as A, type BeginCallRequest as B, type CreateCustomerOptions as C, type UsageTapErrorResponse as D, type EndCallRequest as E, type UsageTapResultEnvelope as F, type UsageTapResultStatus as G, type UsageTapLogEntry as H, type IncrementCustomMeterOptions as I, type WithUsageContext as J, type SubscriptionSnapshot as K, type LimitType as L, type MeterSummary as M, type ModelHints as N, type IdempotencyMetadata as O, type PlanSummary as P, type UsageMetricEvent as Q, type RemainingRatios as R, type SpendVelocitySnapshot as S, UsageTapClient as U, type VendorHints as V, type WithUsageOptions as W, type UsageTapSuccessResponse as a, type BeginCallResponseBody as b, type BeginCallOptions as c, type CreateCustomerRequest as d, type CreateCustomerResponseBody as e, type CheckUsageOptions as f, type CheckUsageRequest as g, type CheckUsageResponseBody as h, type ChangePlanOptions as i, type ChangePlanRequest as j, type ChangePlanResponseBody as k, type ChangePlanStrategy as l, type IncrementCustomMeterRequest as m, type IncrementCustomMeterResponseBody as n, type CustomMeterSlot as o, type EndCallOptions as p, type EndCallResponseBody as q, type BalanceSummary as r, type SpendVelocityWindow as s, type SpendVelocityWindowKey as t, type EntitlementHints as u, type MeterSnapshot as v, type MeteredUsage as w, type RequestedEntitlements as x, type RetryOptions as y, type UsageTapClientOptions as z };
542
+ export { type UsageTapResultStatus as $, type EndCallResponseBody as A, type BeginCallRequest as B, type CreateCustomerOptions as C, type BalanceSummary as D, type EndCallRequest as E, type SpendVelocityWindow as F, type SpendVelocityWindowKey as G, type EntitlementHints as H, type IncrementCustomMeterOptions as I, type PlanSummary as J, type MeterSnapshot as K, type MeteredUsage as L, type MeterSummary as M, type RemainingRatios as N, type RollingCallsRateLimitState as O, type PromptCompressionInput as P, type RequestedEntitlements as Q, type RateLimitsSnapshot as R, type SpendVelocitySnapshot as S, type AllowedEntitlements as T, UsageTapClient as U, type VendorHints as V, type WithUsageOptions as W, type RetryOptions as X, type UsageTapClientOptions as Y, type UsageTapErrorResponse as Z, type UsageTapResultEnvelope as _, type UsageTapSuccessResponse as a, type UsageTapLogEntry as a0, type WithUsageContext as a1, type LimitType as a2, type SubscriptionSnapshot as a3, type ModelHints as a4, type IdempotencyMetadata as a5, type UsageMetricEvent as a6, type BeginCallResponseBody as b, compressPrompt as c, compressPromptHeuristic as d, compressPromptToon as e, estimatePromptTokens as f, type PromptCompressionProvider as g, type PromptCompressionResult as h, type BeginCallOptions as i, type PromptCompressionRequest as j, type PromptCompressionOptions as k, type PromptCompressionResponseBody as l, type PromptCompressionTelemetry as m, type CreateCustomerRequest as n, type CreateCustomerResponseBody as o, type CheckUsageOptions as p, type CheckUsageRequest as q, type CheckUsageResponseBody as r, type ChangePlanOptions as s, type ChangePlanRequest as t, type ChangePlanResponseBody as u, type ChangePlanStrategy as v, type IncrementCustomMeterRequest as w, type IncrementCustomMeterResponseBody as x, type CustomMeterSlot as y, type EndCallOptions as z };
@@ -34,6 +34,23 @@ interface MeterSummary {
34
34
  }
35
35
  type MeterSnapshot = Record<string, MeterSummary>;
36
36
  type RemainingRatios = Record<string, number | null | undefined>;
37
+ interface RollingCallsRateLimitState {
38
+ windowType: "rolling_calls";
39
+ limit: number;
40
+ used: number;
41
+ remaining: number;
42
+ windowSeconds: number;
43
+ state: "fresh" | "estimated" | "stale" | "unknown";
44
+ source?: "current_rolling_check" | "call_records";
45
+ nextAvailableAt?: string;
46
+ scope?: {
47
+ callType?: "standard" | "API";
48
+ tier?: "standard" | "premium";
49
+ };
50
+ }
51
+ interface RateLimitsSnapshot {
52
+ rollingCalls?: RollingCallsRateLimitState | Record<string, RollingCallsRateLimitState>;
53
+ }
37
54
  interface SubscriptionSnapshot {
38
55
  id: string | null;
39
56
  usagePlanVersionId: string | null;
@@ -64,6 +81,23 @@ interface VendorHints {
64
81
  maxInputTokens?: number;
65
82
  maxResponseTokens?: number;
66
83
  }
84
+ interface PromptCompressionRequest {
85
+ callId: string;
86
+ input: unknown;
87
+ provider?: "heuristic" | "toon" | "thetokencompany";
88
+ }
89
+ interface PromptCompressionTelemetry {
90
+ provider: "heuristic" | "toon" | "thetokencompany";
91
+ originalCharacters: number;
92
+ compressedCharacters: number;
93
+ savedCharacters: number;
94
+ originalTokens?: number;
95
+ compressedTokens?: number;
96
+ savedTokens?: number;
97
+ tokenSavingsRatio?: number;
98
+ savingsRatio: number;
99
+ techniques: string[];
100
+ }
67
101
  interface BeginCallRequest {
68
102
  customerId: string;
69
103
  requested?: RequestedEntitlements;
@@ -136,6 +170,7 @@ interface BeginCallResponseBody {
136
170
  policy: LimitType;
137
171
  allowed: AllowedEntitlements;
138
172
  entitlementHints: EntitlementHints;
173
+ rateLimits?: RateLimitsSnapshot;
139
174
  meters: MeterSnapshot;
140
175
  remainingRatios: RemainingRatios;
141
176
  subscription: SubscriptionSnapshot;
@@ -291,6 +326,10 @@ interface UsageTapClientOptions {
291
326
  * Allow constructing the client in browser-like environments for testing.
292
327
  */
293
328
  allowBrowser?: boolean;
329
+ /** API key for The Token Company Bear compression API. */
330
+ tokenCompanyApiKey?: string;
331
+ /** Override endpoint for The Token Company compatible compression APIs. */
332
+ tokenCompanyEndpoint?: string;
294
333
  }
295
334
  interface RequestOptions {
296
335
  signal?: AbortSignal;
@@ -303,6 +342,13 @@ interface BeginCallOptions extends RequestOptions {
303
342
  interface EndCallOptions extends RequestOptions {
304
343
  correlationId?: string;
305
344
  }
345
+ interface PromptCompressionOptions extends RequestOptions {
346
+ correlationId?: string;
347
+ }
348
+ interface PromptCompressionResponseBody extends PromptCompressionTelemetry {
349
+ callId: string;
350
+ updated: boolean;
351
+ }
306
352
  interface WithUsageContext {
307
353
  begin: UsageTapSuccessResponse<BeginCallResponseBody>;
308
354
  setUsage: (usage: Partial<Omit<EndCallRequest, "callId" | "error">>) => void;
@@ -330,6 +376,7 @@ interface CheckUsageResponseBody {
330
376
  policy: LimitType;
331
377
  allowed: AllowedEntitlements;
332
378
  entitlementHints: EntitlementHints;
379
+ rateLimits?: RateLimitsSnapshot;
333
380
  meters: MeterSnapshot;
334
381
  remainingRatios: RemainingRatios;
335
382
  subscription: SubscriptionSnapshot;
@@ -424,6 +471,35 @@ interface UsageMetricEvent {
424
471
  correlationId?: string;
425
472
  }
426
473
 
474
+ type PromptCompressionProvider = "heuristic" | "toon" | "thetokencompany";
475
+ interface PromptCompressionInput {
476
+ input: unknown;
477
+ provider?: PromptCompressionProvider;
478
+ tokenCompanyApiKey?: string;
479
+ tokenCompanyEndpoint?: string;
480
+ fetchImpl?: typeof fetch;
481
+ signal?: AbortSignal;
482
+ failOpen?: boolean;
483
+ }
484
+ interface PromptCompressionResult<TInput = unknown> {
485
+ input: TInput;
486
+ compressedInput: unknown;
487
+ provider: PromptCompressionProvider;
488
+ originalCharacters: number;
489
+ compressedCharacters: number;
490
+ savedCharacters: number;
491
+ originalTokens: number;
492
+ compressedTokens: number;
493
+ savedTokens: number;
494
+ tokenSavingsRatio: number;
495
+ savingsRatio: number;
496
+ techniques: string[];
497
+ }
498
+ declare function compressPrompt<TInput = unknown>(options: PromptCompressionInput): Promise<PromptCompressionResult<TInput>>;
499
+ declare function compressPromptHeuristic<TInput = unknown>(input: TInput): PromptCompressionResult<TInput>;
500
+ declare function compressPromptToon<TInput = unknown>(input: TInput): PromptCompressionResult<TInput>;
501
+ declare function estimatePromptTokens(input: unknown): number;
502
+
427
503
  declare class UsageTapClient {
428
504
  private readonly apiKey;
429
505
  private readonly baseUrl;
@@ -437,14 +513,20 @@ declare class UsageTapClient {
437
513
  private readonly metricFn?;
438
514
  private readonly authHeader;
439
515
  private readonly autoIdempotency;
516
+ private readonly tokenCompanyApiKey?;
517
+ private readonly tokenCompanyEndpoint?;
440
518
  constructor(options: UsageTapClientOptions);
441
519
  beginCall(request: BeginCallRequest, options?: BeginCallOptions): Promise<UsageTapSuccessResponse<BeginCallResponseBody>>;
520
+ promptCompress(request: PromptCompressionRequest, options?: PromptCompressionOptions): Promise<PromptCompressionResult & {
521
+ callId: string;
522
+ }>;
442
523
  endCall(request: EndCallRequest, options?: EndCallOptions): Promise<UsageTapSuccessResponse<EndCallResponseBody>>;
443
524
  checkUsage(request: CheckUsageRequest, options?: CheckUsageOptions): Promise<UsageTapSuccessResponse<CheckUsageResponseBody>>;
444
525
  createCustomer(request: CreateCustomerRequest, options?: CreateCustomerOptions): Promise<UsageTapSuccessResponse<CreateCustomerResponseBody>>;
445
526
  changePlan(request: ChangePlanRequest, options?: ChangePlanOptions): Promise<UsageTapSuccessResponse<ChangePlanResponseBody>>;
446
527
  incrementCustomMeter(request: IncrementCustomMeterRequest, options?: IncrementCustomMeterOptions): Promise<UsageTapSuccessResponse<IncrementCustomMeterResponseBody>>;
447
528
  withUsage<T>(beginRequest: BeginCallRequest, handler: (context: WithUsageContext) => Promise<T>, options?: WithUsageOptions): Promise<T>;
529
+ private toPromptCompressionTelemetry;
448
530
  private request;
449
531
  private requestGet;
450
532
  private performFetch;
@@ -457,4 +539,4 @@ declare class UsageTapClient {
457
539
  private toApiError;
458
540
  }
459
541
 
460
- export { type AllowedEntitlements as A, type BeginCallRequest as B, type CreateCustomerOptions as C, type UsageTapErrorResponse as D, type EndCallRequest as E, type UsageTapResultEnvelope as F, type UsageTapResultStatus as G, type UsageTapLogEntry as H, type IncrementCustomMeterOptions as I, type WithUsageContext as J, type SubscriptionSnapshot as K, type LimitType as L, type MeterSummary as M, type ModelHints as N, type IdempotencyMetadata as O, type PlanSummary as P, type UsageMetricEvent as Q, type RemainingRatios as R, type SpendVelocitySnapshot as S, UsageTapClient as U, type VendorHints as V, type WithUsageOptions as W, type UsageTapSuccessResponse as a, type BeginCallResponseBody as b, type BeginCallOptions as c, type CreateCustomerRequest as d, type CreateCustomerResponseBody as e, type CheckUsageOptions as f, type CheckUsageRequest as g, type CheckUsageResponseBody as h, type ChangePlanOptions as i, type ChangePlanRequest as j, type ChangePlanResponseBody as k, type ChangePlanStrategy as l, type IncrementCustomMeterRequest as m, type IncrementCustomMeterResponseBody as n, type CustomMeterSlot as o, type EndCallOptions as p, type EndCallResponseBody as q, type BalanceSummary as r, type SpendVelocityWindow as s, type SpendVelocityWindowKey as t, type EntitlementHints as u, type MeterSnapshot as v, type MeteredUsage as w, type RequestedEntitlements as x, type RetryOptions as y, type UsageTapClientOptions as z };
542
+ export { type UsageTapResultStatus as $, type EndCallResponseBody as A, type BeginCallRequest as B, type CreateCustomerOptions as C, type BalanceSummary as D, type EndCallRequest as E, type SpendVelocityWindow as F, type SpendVelocityWindowKey as G, type EntitlementHints as H, type IncrementCustomMeterOptions as I, type PlanSummary as J, type MeterSnapshot as K, type MeteredUsage as L, type MeterSummary as M, type RemainingRatios as N, type RollingCallsRateLimitState as O, type PromptCompressionInput as P, type RequestedEntitlements as Q, type RateLimitsSnapshot as R, type SpendVelocitySnapshot as S, type AllowedEntitlements as T, UsageTapClient as U, type VendorHints as V, type WithUsageOptions as W, type RetryOptions as X, type UsageTapClientOptions as Y, type UsageTapErrorResponse as Z, type UsageTapResultEnvelope as _, type UsageTapSuccessResponse as a, type UsageTapLogEntry as a0, type WithUsageContext as a1, type LimitType as a2, type SubscriptionSnapshot as a3, type ModelHints as a4, type IdempotencyMetadata as a5, type UsageMetricEvent as a6, type BeginCallResponseBody as b, compressPrompt as c, compressPromptHeuristic as d, compressPromptToon as e, estimatePromptTokens as f, type PromptCompressionProvider as g, type PromptCompressionResult as h, type BeginCallOptions as i, type PromptCompressionRequest as j, type PromptCompressionOptions as k, type PromptCompressionResponseBody as l, type PromptCompressionTelemetry as m, type CreateCustomerRequest as n, type CreateCustomerResponseBody as o, type CheckUsageOptions as p, type CheckUsageRequest as q, type CheckUsageResponseBody as r, type ChangePlanOptions as s, type ChangePlanRequest as t, type ChangePlanResponseBody as u, type ChangePlanStrategy as v, type IncrementCustomMeterRequest as w, type IncrementCustomMeterResponseBody as x, type CustomMeterSlot as y, type EndCallOptions as z };
@@ -1,6 +1,6 @@
1
1
  import OpenAI from 'openai';
2
2
  import { Request, Response, NextFunction } from 'express';
3
- import { U as UsageTapClient } from '../client-CuzjFxMn.cjs';
3
+ import { U as UsageTapClient } from '../client-BHNMYvlO.cjs';
4
4
  import { WrapOpenAIContext, WrapOpenAIOptions, wrapOpenAI, pipeToResponse } from '../adapters/openai.cjs';
5
5
 
6
6
  interface ExpressUsageTapContext {
@@ -1,6 +1,6 @@
1
1
  import OpenAI from 'openai';
2
2
  import { Request, Response, NextFunction } from 'express';
3
- import { U as UsageTapClient } from '../client-CuzjFxMn.js';
3
+ import { U as UsageTapClient } from '../client-BHNMYvlO.js';
4
4
  import { WrapOpenAIContext, WrapOpenAIOptions, wrapOpenAI, pipeToResponse } from '../adapters/openai.js';
5
5
 
6
6
  interface ExpressUsageTapContext {