@usagetap/sdk 0.2.0 → 0.2.1
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/README.md +23 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -532,6 +532,29 @@ UsageTap responds exclusively with the canonical `{ result, data, correlationId
|
|
|
532
532
|
|
|
533
533
|
`metered` is derived from the raw Dynamo deltas. Additional meters (audio seconds, reasoning tokens, balances) will populate in later phases without breaking the contract.
|
|
534
534
|
|
|
535
|
+
### Premium detection and override
|
|
536
|
+
|
|
537
|
+
UsageTap automatically determines whether a call is premium based on the model's output token pricing:
|
|
538
|
+
- If the output token price exceeds **$4.00 per million tokens**, the call is classified as premium
|
|
539
|
+
- Otherwise, it's classified as standard
|
|
540
|
+
|
|
541
|
+
You can explicitly override this detection by passing `isPremium` in your `call_end` request:
|
|
542
|
+
|
|
543
|
+
```ts
|
|
544
|
+
await usageTap.endCall({
|
|
545
|
+
callId: begin.data.callId,
|
|
546
|
+
modelUsed: "custom-model-v2",
|
|
547
|
+
inputTokens: 100,
|
|
548
|
+
responseTokens: 200,
|
|
549
|
+
isPremium: true, // Explicitly mark this as a premium call
|
|
550
|
+
});
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
This is useful when:
|
|
554
|
+
- You're using custom models that aren't in UsageTap's pricing database
|
|
555
|
+
- You want to enforce specific billing tiers regardless of pricing
|
|
556
|
+
- You're implementing your own tier classification logic
|
|
557
|
+
|
|
535
558
|
### Raw fetch integrations
|
|
536
559
|
|
|
537
560
|
Prefer `UsageTapClient` whenever possible—it handles retries, headers, and idempotency for you. If you still need to work with `fetch` directly, remember to request the canonical media type and consume the envelope shape directly:
|
package/dist/index.cjs
CHANGED
|
@@ -126,7 +126,7 @@ var IDEMPOTENCY_HEADER = "idempotency-key";
|
|
|
126
126
|
var SDK_HEADER = "x-usage-sdk";
|
|
127
127
|
var USER_AGENT = "UsageTapClient";
|
|
128
128
|
var CANONICAL_MEDIA_TYPE = "application/vnd.usagetap.v1+json";
|
|
129
|
-
var SDK_VERSION = "0.2.
|
|
129
|
+
var SDK_VERSION = "0.2.1" ;
|
|
130
130
|
var HAS_WINDOW = typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined";
|
|
131
131
|
var UsageTapClient = class {
|
|
132
132
|
apiKey;
|
package/dist/index.js
CHANGED
|
@@ -124,7 +124,7 @@ var IDEMPOTENCY_HEADER = "idempotency-key";
|
|
|
124
124
|
var SDK_HEADER = "x-usage-sdk";
|
|
125
125
|
var USER_AGENT = "UsageTapClient";
|
|
126
126
|
var CANONICAL_MEDIA_TYPE = "application/vnd.usagetap.v1+json";
|
|
127
|
-
var SDK_VERSION = "0.2.
|
|
127
|
+
var SDK_VERSION = "0.2.1" ;
|
|
128
128
|
var HAS_WINDOW = typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined";
|
|
129
129
|
var UsageTapClient = class {
|
|
130
130
|
apiKey;
|