@oxy.so/contracts 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 +202 -0
- package/NOTICE +16 -0
- package/dist/cjs/.tsbuildinfo +1 -0
- package/dist/cjs/accountGraph.js +489 -0
- package/dist/cjs/agency.js +439 -0
- package/dist/cjs/browserHub.js +215 -0
- package/dist/cjs/civic.js +163 -0
- package/dist/cjs/commonsSignIn.js +59 -0
- package/dist/cjs/deviceBoot.js +50 -0
- package/dist/cjs/deviceDirectory.js +189 -0
- package/dist/cjs/devicePairing.js +138 -0
- package/dist/cjs/deviceSession.js +164 -0
- package/dist/cjs/emailAgentContext.js +32 -0
- package/dist/cjs/followGraph.js +28 -0
- package/dist/cjs/identity.js +258 -0
- package/dist/cjs/inboxPush.js +24 -0
- package/dist/cjs/index.js +618 -0
- package/dist/cjs/inference/accountBilling.js +334 -0
- package/dist/cjs/inference/aliaModelRelease.js +262 -0
- package/dist/cjs/inference/attribution.js +106 -0
- package/dist/cjs/inference/catalogue.js +487 -0
- package/dist/cjs/inference/entitlement.js +217 -0
- package/dist/cjs/inference/errors.js +309 -0
- package/dist/cjs/inference/identifiers.js +224 -0
- package/dist/cjs/inference/inbox.js +105 -0
- package/dist/cjs/inference/modelDocumentation.js +433 -0
- package/dist/cjs/inference/money.js +188 -0
- package/dist/cjs/inference/priceVersion.js +110 -0
- package/dist/cjs/inference/providerConnection.js +455 -0
- package/dist/cjs/inference/request.js +477 -0
- package/dist/cjs/inference/routingPolicy.js +318 -0
- package/dist/cjs/inference/streamEvents.js +258 -0
- package/dist/cjs/inference/usage.js +329 -0
- package/dist/cjs/inference/version.js +105 -0
- package/dist/cjs/keyRecovery.js +91 -0
- package/dist/cjs/keyRotation.js +75 -0
- package/dist/cjs/links.js +68 -0
- package/dist/cjs/moderationReputation.js +298 -0
- package/dist/cjs/oauth.js +66 -0
- package/dist/cjs/oxyRecordTypes.js +71 -0
- package/dist/cjs/protocol.js +53 -0
- package/dist/cjs/recommendations.js +168 -0
- package/dist/cjs/reputation.js +297 -0
- package/dist/cjs/sessionStatus.js +121 -0
- package/dist/cjs/transparency.js +89 -0
- package/dist/cjs/updates.js +252 -0
- package/dist/cjs/userInvalidation.js +89 -0
- package/dist/cjs/userResponse.js +245 -0
- package/dist/cjs/username.js +290 -0
- package/dist/cjs/webauthn.js +71 -0
- package/dist/esm/.tsbuildinfo +1 -0
- package/dist/esm/accountGraph.js +480 -0
- package/dist/esm/agency.js +436 -0
- package/dist/esm/browserHub.js +212 -0
- package/dist/esm/civic.js +160 -0
- package/dist/esm/commonsSignIn.js +56 -0
- package/dist/esm/deviceBoot.js +47 -0
- package/dist/esm/deviceDirectory.js +186 -0
- package/dist/esm/devicePairing.js +135 -0
- package/dist/esm/deviceSession.js +161 -0
- package/dist/esm/emailAgentContext.js +29 -0
- package/dist/esm/followGraph.js +27 -0
- package/dist/esm/identity.js +255 -0
- package/dist/esm/inboxPush.js +21 -0
- package/dist/esm/index.js +172 -0
- package/dist/esm/inference/accountBilling.js +331 -0
- package/dist/esm/inference/aliaModelRelease.js +259 -0
- package/dist/esm/inference/attribution.js +103 -0
- package/dist/esm/inference/catalogue.js +484 -0
- package/dist/esm/inference/entitlement.js +214 -0
- package/dist/esm/inference/errors.js +306 -0
- package/dist/esm/inference/identifiers.js +221 -0
- package/dist/esm/inference/inbox.js +102 -0
- package/dist/esm/inference/modelDocumentation.js +430 -0
- package/dist/esm/inference/money.js +185 -0
- package/dist/esm/inference/priceVersion.js +107 -0
- package/dist/esm/inference/providerConnection.js +452 -0
- package/dist/esm/inference/request.js +474 -0
- package/dist/esm/inference/routingPolicy.js +315 -0
- package/dist/esm/inference/streamEvents.js +255 -0
- package/dist/esm/inference/usage.js +326 -0
- package/dist/esm/inference/version.js +102 -0
- package/dist/esm/keyRecovery.js +88 -0
- package/dist/esm/keyRotation.js +72 -0
- package/dist/esm/links.js +65 -0
- package/dist/esm/moderationReputation.js +295 -0
- package/dist/esm/oauth.js +63 -0
- package/dist/esm/oxyRecordTypes.js +68 -0
- package/dist/esm/protocol.js +50 -0
- package/dist/esm/recommendations.js +165 -0
- package/dist/esm/reputation.js +293 -0
- package/dist/esm/sessionStatus.js +118 -0
- package/dist/esm/transparency.js +86 -0
- package/dist/esm/updates.js +249 -0
- package/dist/esm/userInvalidation.js +85 -0
- package/dist/esm/userResponse.js +240 -0
- package/dist/esm/username.js +283 -0
- package/dist/esm/webauthn.js +68 -0
- package/dist/types/.tsbuildinfo +1 -0
- package/dist/types/accountGraph.d.ts +378 -0
- package/dist/types/agency.d.ts +2162 -0
- package/dist/types/browserHub.d.ts +856 -0
- package/dist/types/civic.d.ts +338 -0
- package/dist/types/commonsSignIn.d.ts +58 -0
- package/dist/types/deviceBoot.d.ts +74 -0
- package/dist/types/deviceDirectory.d.ts +1317 -0
- package/dist/types/devicePairing.d.ts +130 -0
- package/dist/types/deviceSession.d.ts +411 -0
- package/dist/types/emailAgentContext.d.ts +248 -0
- package/dist/types/followGraph.d.ts +150 -0
- package/dist/types/identity.d.ts +402 -0
- package/dist/types/inboxPush.d.ts +30 -0
- package/dist/types/index.d.ts +100 -0
- package/dist/types/inference/accountBilling.d.ts +738 -0
- package/dist/types/inference/aliaModelRelease.d.ts +609 -0
- package/dist/types/inference/attribution.d.ts +176 -0
- package/dist/types/inference/catalogue.d.ts +1618 -0
- package/dist/types/inference/entitlement.d.ts +519 -0
- package/dist/types/inference/errors.d.ts +242 -0
- package/dist/types/inference/identifiers.d.ts +182 -0
- package/dist/types/inference/inbox.d.ts +374 -0
- package/dist/types/inference/modelDocumentation.d.ts +1603 -0
- package/dist/types/inference/money.d.ts +185 -0
- package/dist/types/inference/priceVersion.d.ts +182 -0
- package/dist/types/inference/providerConnection.d.ts +968 -0
- package/dist/types/inference/request.d.ts +2800 -0
- package/dist/types/inference/routingPolicy.d.ts +616 -0
- package/dist/types/inference/streamEvents.d.ts +950 -0
- package/dist/types/inference/usage.d.ts +1164 -0
- package/dist/types/inference/version.d.ts +102 -0
- package/dist/types/keyRecovery.d.ts +138 -0
- package/dist/types/keyRotation.d.ts +103 -0
- package/dist/types/links.d.ts +96 -0
- package/dist/types/moderationReputation.d.ts +487 -0
- package/dist/types/oauth.d.ts +86 -0
- package/dist/types/oxyRecordTypes.d.ts +62 -0
- package/dist/types/protocol.d.ts +86 -0
- package/dist/types/recommendations.d.ts +542 -0
- package/dist/types/reputation.d.ts +457 -0
- package/dist/types/sessionStatus.d.ts +231 -0
- package/dist/types/transparency.d.ts +392 -0
- package/dist/types/updates.d.ts +545 -0
- package/dist/types/userInvalidation.d.ts +94 -0
- package/dist/types/userResponse.d.ts +1706 -0
- package/dist/types/username.d.ts +265 -0
- package/dist/types/webauthn.d.ts +77 -0
- package/package.json +87 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Money and usage units for the inference contracts.
|
|
3
|
+
*
|
|
4
|
+
* The non-negotiable invariant this file exists to make structural: **customer
|
|
5
|
+
* charges never use floating-point values as the financial source of truth.**
|
|
6
|
+
* A JS `number` cannot represent `0.1 + 0.2` exactly, and an inference ledger
|
|
7
|
+
* adds millions of small amounts, so a float total is wrong by construction
|
|
8
|
+
* rather than by accident.
|
|
9
|
+
*
|
|
10
|
+
* Every amount and every price is one representation: {@link exactDecimalSchema},
|
|
11
|
+
* an exact decimal STRING at the scale ADR 0009 declares. Amounts are not
|
|
12
|
+
* integer minor units, and that is the ADR's decision rather than an oversight:
|
|
13
|
+
* one token costs several orders of magnitude less than one cent, so rounding
|
|
14
|
+
* per request would make a customer's bill depend on how their client chunked
|
|
15
|
+
* its work. Rounding happens ONCE, at the invoice boundary, and is itself a
|
|
16
|
+
* ledger entry.
|
|
17
|
+
*
|
|
18
|
+
* A string is also what the driver hands back — `postgres.js` decodes `NUMERIC`
|
|
19
|
+
* as a string — so keeping it a string on the wire means accidental JS
|
|
20
|
+
* arithmetic fails loudly instead of silently losing precision. Money
|
|
21
|
+
* arithmetic happens in SQL or in a decimal type, never in a JS `number`.
|
|
22
|
+
*
|
|
23
|
+
* Units are carried separately from money in every shape: a receipt says both
|
|
24
|
+
* "204 output tokens" and "0.003060000000 USD", and neither is derived from the
|
|
25
|
+
* other at read time. That separation is what lets a price version change
|
|
26
|
+
* without rewriting settled history.
|
|
27
|
+
*
|
|
28
|
+
* Decided in: docs/adr/0009-usage-reservation-and-settlement.md.
|
|
29
|
+
*/
|
|
30
|
+
import { z } from 'zod';
|
|
31
|
+
/** ISO 4217 alpha-3 currency code, e.g. `USD`. */
|
|
32
|
+
export declare const currencyCodeSchema: z.ZodString;
|
|
33
|
+
/**
|
|
34
|
+
* The declared fractional scale of every amount and price in this contract, and
|
|
35
|
+
* of the `NUMERIC` columns the ledger stores them in.
|
|
36
|
+
*
|
|
37
|
+
* Twelve digits is sub-minor-unit precision by a wide margin: at $3 per million
|
|
38
|
+
* input tokens, one token costs `0.000003000000`, which this scale represents
|
|
39
|
+
* exactly. Amounts are compared and summed NUMERICALLY, never as text — `3.0`
|
|
40
|
+
* and `3.000000000000` are one amount written two ways.
|
|
41
|
+
*/
|
|
42
|
+
export declare const INFERENCE_MONEY_SCALE = 12;
|
|
43
|
+
/**
|
|
44
|
+
* An exact non-negative decimal, carried as a STRING so no parse step can turn
|
|
45
|
+
* it into a float on the way past. Up to 18 integer digits and
|
|
46
|
+
* {@link INFERENCE_MONEY_SCALE} fractional digits.
|
|
47
|
+
*
|
|
48
|
+
* Non-negative: direction is carried by the SHAPE — a receipt debits, a refund
|
|
49
|
+
* credits — so a stray sign can never silently invert an entry.
|
|
50
|
+
*
|
|
51
|
+
* No exponent form: `1e-6` and `0.000001` are the same number, but only one of
|
|
52
|
+
* them survives a naive string comparison, a cache key or a log grep intact.
|
|
53
|
+
*
|
|
54
|
+
* Branded, so a bare `string` is not assignable and an amount cannot arrive
|
|
55
|
+
* from string concatenation that was never checked. Producers construct one
|
|
56
|
+
* with `exactDecimalSchema.parse(value)`.
|
|
57
|
+
*/
|
|
58
|
+
export declare const exactDecimalSchema: z.ZodBranded<z.ZodString, "ExactDecimal">;
|
|
59
|
+
/**
|
|
60
|
+
* An amount of money: the exact decimal plus the currency it is in.
|
|
61
|
+
*
|
|
62
|
+
* `.strict()` so a payload carrying a convenience float beside the exact value
|
|
63
|
+
* (`{ amount: '18.06', amountFloat: 18.06 }`) is REJECTED rather than stripped.
|
|
64
|
+
* A stripped float is the more dangerous outcome: it disappears silently here
|
|
65
|
+
* and survives in the producer, where it is the value somebody eventually
|
|
66
|
+
* displays.
|
|
67
|
+
*/
|
|
68
|
+
export declare const moneySchema: z.ZodObject<{
|
|
69
|
+
amount: z.ZodBranded<z.ZodString, "ExactDecimal">;
|
|
70
|
+
currency: z.ZodString;
|
|
71
|
+
}, "strict", z.ZodTypeAny, {
|
|
72
|
+
currency: string;
|
|
73
|
+
amount: string & z.BRAND<"ExactDecimal">;
|
|
74
|
+
}, {
|
|
75
|
+
currency: string;
|
|
76
|
+
amount: string;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* The closed set of units inference is metered in.
|
|
80
|
+
*
|
|
81
|
+
* **The units PARTITION a request: every unit counts material no other unit
|
|
82
|
+
* counts.** `cached_input_tokens` is not part of `input_tokens`, and
|
|
83
|
+
* `reasoning_tokens` is not part of `output_tokens` — they are siblings, not
|
|
84
|
+
* subsets. A request whose 10 000-token prompt was served 9 000 tokens from
|
|
85
|
+
* cache is reported as `input_tokens: 1000` beside `cached_input_tokens: 9000`,
|
|
86
|
+
* never as `input_tokens: 10000` beside it.
|
|
87
|
+
*
|
|
88
|
+
* That belongs to the definition rather than to a convention somewhere else,
|
|
89
|
+
* because settlement applies a price to EVERY reported unit and sums them
|
|
90
|
+
* (`inferenceLedger.service.ts`'s `computeCharge`). Under the partition rule
|
|
91
|
+
* that sum IS the request's cost, and a cached token can carry its own — lower
|
|
92
|
+
* — price. Under the nested reading the same sum charges the cached and
|
|
93
|
+
* reasoning tokens twice: once inside their parent and once on their own line.
|
|
94
|
+
* It fails silently, because every total still looks plausible and the receipt
|
|
95
|
+
* is still internally consistent, and on a reasoning model the reasoning tokens
|
|
96
|
+
* can dominate the completion, so the error is not marginal.
|
|
97
|
+
*
|
|
98
|
+
* **Every OpenAI-compatible provider reports the other way round**:
|
|
99
|
+
* `prompt_tokens` INCLUDES `prompt_tokens_details.cached_tokens`, and
|
|
100
|
+
* `completion_tokens` INCLUDES `completion_tokens_details.reasoning_tokens`.
|
|
101
|
+
* Normalising is the data plane's job and it is subtraction:
|
|
102
|
+
*
|
|
103
|
+
* ```text
|
|
104
|
+
* input_tokens = prompt_tokens - prompt_tokens_details.cached_tokens
|
|
105
|
+
* output_tokens = completion_tokens - completion_tokens_details.reasoning_tokens
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* No refinement in this package can enforce it, and saying so is part of the
|
|
109
|
+
* rule: a nested report and a disjoint one are the same four non-negative
|
|
110
|
+
* integers, so no predicate over a single report can tell them apart. The two
|
|
111
|
+
* structural guards that DO exist — refining `cached <= input` and
|
|
112
|
+
* `reasoning <= output`, or deriving the parents instead of reporting them —
|
|
113
|
+
* both encode the nested reading, which is the one this rule rejects. What IS
|
|
114
|
+
* enforceable is the arithmetic that depends on the rule, and that is where the
|
|
115
|
+
* enforcement lives — `inferenceLedger.service.test.ts` prices a report in
|
|
116
|
+
* which cached and reasoning tokens are both non-zero and asserts the exact
|
|
117
|
+
* total, which the nested reading cannot produce.
|
|
118
|
+
*
|
|
119
|
+
* Where the public surface has to speak a nested dialect, the sum is put back
|
|
120
|
+
* at the boundary rather than the internal reading being bent to it
|
|
121
|
+
* (`routes/inferenceEdge.ts` renders `prompt_tokens` as
|
|
122
|
+
* `input_tokens + cached_input_tokens`).
|
|
123
|
+
*
|
|
124
|
+
* Time is carried in integer MILLISECONDS rather than seconds so that no unit
|
|
125
|
+
* quantity is ever fractional: a 12.5-second transcription is `12500`, exactly,
|
|
126
|
+
* and the "units are integers" rule holds for every modality instead of holding
|
|
127
|
+
* for tokens and being quietly broken by audio.
|
|
128
|
+
*/
|
|
129
|
+
export declare const USAGE_UNITS: readonly ["input_tokens", "cached_input_tokens", "output_tokens", "reasoning_tokens", "requests", "images", "audio_input_milliseconds", "audio_output_milliseconds", "video_milliseconds", "characters", "embeddings"];
|
|
130
|
+
export declare const usageUnitSchema: z.ZodEnum<["input_tokens", "cached_input_tokens", "output_tokens", "reasoning_tokens", "requests", "images", "audio_input_milliseconds", "audio_output_milliseconds", "video_milliseconds", "characters", "embeddings"]>;
|
|
131
|
+
/**
|
|
132
|
+
* A metered quantity of ONE unit. Never money — a quantity carries no price and
|
|
133
|
+
* no currency, so a consumer cannot mistake a token count for an amount owed.
|
|
134
|
+
*/
|
|
135
|
+
export declare const usageQuantitySchema: z.ZodObject<{
|
|
136
|
+
unit: z.ZodEnum<["input_tokens", "cached_input_tokens", "output_tokens", "reasoning_tokens", "requests", "images", "audio_input_milliseconds", "audio_output_milliseconds", "video_milliseconds", "characters", "embeddings"]>;
|
|
137
|
+
quantity: z.ZodNumber;
|
|
138
|
+
}, "strict", z.ZodTypeAny, {
|
|
139
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
140
|
+
quantity: number;
|
|
141
|
+
}, {
|
|
142
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
143
|
+
quantity: number;
|
|
144
|
+
}>;
|
|
145
|
+
/**
|
|
146
|
+
* Where a metered quantity came from.
|
|
147
|
+
*
|
|
148
|
+
* Kept explicit because the three are not interchangeable when a charge is
|
|
149
|
+
* disputed: `provider_reported` is the upstream's own count, `oxy_measured` is
|
|
150
|
+
* counted by the platform (streamed bytes, wall-clock milliseconds), and
|
|
151
|
+
* `estimated` is a reconstruction used when a provider returned no usage at
|
|
152
|
+
* all. An estimate that is indistinguishable from a reported number is an
|
|
153
|
+
* estimate nobody can later reconcile or refund against.
|
|
154
|
+
*/
|
|
155
|
+
export declare const USAGE_SOURCES: readonly ["provider_reported", "oxy_measured", "estimated"];
|
|
156
|
+
export declare const usageSourceSchema: z.ZodEnum<["provider_reported", "oxy_measured", "estimated"]>;
|
|
157
|
+
/**
|
|
158
|
+
* A price for one unit, as `amount` per `per` units — `per` because a price
|
|
159
|
+
* quoted per single token would need more fractional digits than it is worth
|
|
160
|
+
* ("$3.00 per 1000000 input_tokens" is how every provider quotes it, and how
|
|
161
|
+
* every customer reads it).
|
|
162
|
+
*/
|
|
163
|
+
export declare const unitPriceSchema: z.ZodObject<{
|
|
164
|
+
unit: z.ZodEnum<["input_tokens", "cached_input_tokens", "output_tokens", "reasoning_tokens", "requests", "images", "audio_input_milliseconds", "audio_output_milliseconds", "video_milliseconds", "characters", "embeddings"]>;
|
|
165
|
+
amount: z.ZodBranded<z.ZodString, "ExactDecimal">;
|
|
166
|
+
per: z.ZodNumber;
|
|
167
|
+
currency: z.ZodString;
|
|
168
|
+
}, "strict", z.ZodTypeAny, {
|
|
169
|
+
currency: string;
|
|
170
|
+
amount: string & z.BRAND<"ExactDecimal">;
|
|
171
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
172
|
+
per: number;
|
|
173
|
+
}, {
|
|
174
|
+
currency: string;
|
|
175
|
+
amount: string;
|
|
176
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
177
|
+
per: number;
|
|
178
|
+
}>;
|
|
179
|
+
export type CurrencyCode = z.infer<typeof currencyCodeSchema>;
|
|
180
|
+
export type ExactDecimal = z.infer<typeof exactDecimalSchema>;
|
|
181
|
+
export type Money = z.infer<typeof moneySchema>;
|
|
182
|
+
export type UsageUnit = z.infer<typeof usageUnitSchema>;
|
|
183
|
+
export type UsageSource = z.infer<typeof usageSourceSchema>;
|
|
184
|
+
export type UsageQuantity = z.infer<typeof usageQuantitySchema>;
|
|
185
|
+
export type UnitPrice = z.infer<typeof unitPriceSchema>;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Price versions — the immutable snapshots customer pricing is quoted and
|
|
3
|
+
* settled against.
|
|
4
|
+
*
|
|
5
|
+
* A price is never edited in place. A change publishes a NEW version that
|
|
6
|
+
* supersedes the old one, and every settled receipt keeps the id of the version
|
|
7
|
+
* it was priced with. That is what makes an invoice reproducible a year later:
|
|
8
|
+
* the receipt does not say "3.00 per million tokens", it says "priced under
|
|
9
|
+
* `pv_2026_08`", and that version still exists, unchanged, with its own
|
|
10
|
+
* effective window.
|
|
11
|
+
*
|
|
12
|
+
* Prices are exact decimal strings (see `money.ts`), never floats, and they are
|
|
13
|
+
* quoted per unit. The amount a customer owes is computed from them and is
|
|
14
|
+
* carried in the same exact form, so no step of the calculation passes through
|
|
15
|
+
* a representation that cannot hold the value.
|
|
16
|
+
*
|
|
17
|
+
* Decided in: docs/adr/0009-usage-reservation-and-settlement.md.
|
|
18
|
+
*/
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
/**
|
|
21
|
+
* Lifecycle of a price version.
|
|
22
|
+
*
|
|
23
|
+
* `draft` is quotable in Console previews but may never price a receipt;
|
|
24
|
+
* `active` is what live requests are priced with; `superseded` priced receipts
|
|
25
|
+
* in the past and still resolves for them forever.
|
|
26
|
+
*/
|
|
27
|
+
export declare const priceVersionStatusSchema: z.ZodEnum<["draft", "active", "superseded"]>;
|
|
28
|
+
/**
|
|
29
|
+
* A published set of customer prices for one model reference on one provider.
|
|
30
|
+
*
|
|
31
|
+
* Scoped to a `(modelReference, provider)` pair rather than to a model alone
|
|
32
|
+
* because the same model costs different amounts on different providers, and a
|
|
33
|
+
* receipt has to be reproducible against the route that actually served it.
|
|
34
|
+
*/
|
|
35
|
+
export declare const priceVersionSchema: z.ZodEffects<z.ZodObject<{
|
|
36
|
+
/** See `version.ts`: served on its own by the catalogue, so it is versioned. */
|
|
37
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
38
|
+
priceVersionId: z.ZodString;
|
|
39
|
+
status: z.ZodEnum<["draft", "active", "superseded"]>;
|
|
40
|
+
modelReference: z.ZodString;
|
|
41
|
+
provider: z.ZodString;
|
|
42
|
+
currency: z.ZodString;
|
|
43
|
+
unitPrices: z.ZodArray<z.ZodObject<{
|
|
44
|
+
unit: z.ZodEnum<["input_tokens", "cached_input_tokens", "output_tokens", "reasoning_tokens", "requests", "images", "audio_input_milliseconds", "audio_output_milliseconds", "video_milliseconds", "characters", "embeddings"]>;
|
|
45
|
+
amount: z.ZodBranded<z.ZodString, "ExactDecimal">;
|
|
46
|
+
per: z.ZodNumber;
|
|
47
|
+
currency: z.ZodString;
|
|
48
|
+
}, "strict", z.ZodTypeAny, {
|
|
49
|
+
currency: string;
|
|
50
|
+
amount: string & z.BRAND<"ExactDecimal">;
|
|
51
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
52
|
+
per: number;
|
|
53
|
+
}, {
|
|
54
|
+
currency: string;
|
|
55
|
+
amount: string;
|
|
56
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
57
|
+
per: number;
|
|
58
|
+
}>, "many">;
|
|
59
|
+
effectiveFrom: z.ZodString;
|
|
60
|
+
/** Absent while this version is the current one. */
|
|
61
|
+
effectiveUntil: z.ZodOptional<z.ZodString>;
|
|
62
|
+
/** The version this one replaced, absent for the first version of a route. */
|
|
63
|
+
supersedesPriceVersionId: z.ZodOptional<z.ZodString>;
|
|
64
|
+
createdAt: z.ZodString;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
status: "draft" | "active" | "superseded";
|
|
67
|
+
createdAt: string;
|
|
68
|
+
schemaVersion: 1;
|
|
69
|
+
currency: string;
|
|
70
|
+
provider: string;
|
|
71
|
+
priceVersionId: string;
|
|
72
|
+
modelReference: string;
|
|
73
|
+
unitPrices: {
|
|
74
|
+
currency: string;
|
|
75
|
+
amount: string & z.BRAND<"ExactDecimal">;
|
|
76
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
77
|
+
per: number;
|
|
78
|
+
}[];
|
|
79
|
+
effectiveFrom: string;
|
|
80
|
+
effectiveUntil?: string | undefined;
|
|
81
|
+
supersedesPriceVersionId?: string | undefined;
|
|
82
|
+
}, {
|
|
83
|
+
status: "draft" | "active" | "superseded";
|
|
84
|
+
createdAt: string;
|
|
85
|
+
schemaVersion: 1;
|
|
86
|
+
currency: string;
|
|
87
|
+
provider: string;
|
|
88
|
+
priceVersionId: string;
|
|
89
|
+
modelReference: string;
|
|
90
|
+
unitPrices: {
|
|
91
|
+
currency: string;
|
|
92
|
+
amount: string;
|
|
93
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
94
|
+
per: number;
|
|
95
|
+
}[];
|
|
96
|
+
effectiveFrom: string;
|
|
97
|
+
effectiveUntil?: string | undefined;
|
|
98
|
+
supersedesPriceVersionId?: string | undefined;
|
|
99
|
+
}>, {
|
|
100
|
+
status: "draft" | "active" | "superseded";
|
|
101
|
+
createdAt: string;
|
|
102
|
+
schemaVersion: 1;
|
|
103
|
+
currency: string;
|
|
104
|
+
provider: string;
|
|
105
|
+
priceVersionId: string;
|
|
106
|
+
modelReference: string;
|
|
107
|
+
unitPrices: {
|
|
108
|
+
currency: string;
|
|
109
|
+
amount: string & z.BRAND<"ExactDecimal">;
|
|
110
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
111
|
+
per: number;
|
|
112
|
+
}[];
|
|
113
|
+
effectiveFrom: string;
|
|
114
|
+
effectiveUntil?: string | undefined;
|
|
115
|
+
supersedesPriceVersionId?: string | undefined;
|
|
116
|
+
}, {
|
|
117
|
+
status: "draft" | "active" | "superseded";
|
|
118
|
+
createdAt: string;
|
|
119
|
+
schemaVersion: 1;
|
|
120
|
+
currency: string;
|
|
121
|
+
provider: string;
|
|
122
|
+
priceVersionId: string;
|
|
123
|
+
modelReference: string;
|
|
124
|
+
unitPrices: {
|
|
125
|
+
currency: string;
|
|
126
|
+
amount: string;
|
|
127
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
128
|
+
per: number;
|
|
129
|
+
}[];
|
|
130
|
+
effectiveFrom: string;
|
|
131
|
+
effectiveUntil?: string | undefined;
|
|
132
|
+
supersedesPriceVersionId?: string | undefined;
|
|
133
|
+
}>;
|
|
134
|
+
/**
|
|
135
|
+
* The price snapshot a settled receipt keeps.
|
|
136
|
+
*
|
|
137
|
+
* The unit prices are COPIED onto the receipt, not just referenced, so a receipt
|
|
138
|
+
* remains readable even if the price version record is later archived, and so
|
|
139
|
+
* that a mistake in the copy is visible as a disagreement with the version it
|
|
140
|
+
* names rather than silently invisible.
|
|
141
|
+
*/
|
|
142
|
+
export declare const priceSnapshotSchema: z.ZodObject<{
|
|
143
|
+
priceVersionId: z.ZodString;
|
|
144
|
+
currency: z.ZodString;
|
|
145
|
+
unitPrices: z.ZodArray<z.ZodObject<{
|
|
146
|
+
unit: z.ZodEnum<["input_tokens", "cached_input_tokens", "output_tokens", "reasoning_tokens", "requests", "images", "audio_input_milliseconds", "audio_output_milliseconds", "video_milliseconds", "characters", "embeddings"]>;
|
|
147
|
+
amount: z.ZodBranded<z.ZodString, "ExactDecimal">;
|
|
148
|
+
per: z.ZodNumber;
|
|
149
|
+
currency: z.ZodString;
|
|
150
|
+
}, "strict", z.ZodTypeAny, {
|
|
151
|
+
currency: string;
|
|
152
|
+
amount: string & z.BRAND<"ExactDecimal">;
|
|
153
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
154
|
+
per: number;
|
|
155
|
+
}, {
|
|
156
|
+
currency: string;
|
|
157
|
+
amount: string;
|
|
158
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
159
|
+
per: number;
|
|
160
|
+
}>, "many">;
|
|
161
|
+
}, "strict", z.ZodTypeAny, {
|
|
162
|
+
currency: string;
|
|
163
|
+
priceVersionId: string;
|
|
164
|
+
unitPrices: {
|
|
165
|
+
currency: string;
|
|
166
|
+
amount: string & z.BRAND<"ExactDecimal">;
|
|
167
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
168
|
+
per: number;
|
|
169
|
+
}[];
|
|
170
|
+
}, {
|
|
171
|
+
currency: string;
|
|
172
|
+
priceVersionId: string;
|
|
173
|
+
unitPrices: {
|
|
174
|
+
currency: string;
|
|
175
|
+
amount: string;
|
|
176
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
177
|
+
per: number;
|
|
178
|
+
}[];
|
|
179
|
+
}>;
|
|
180
|
+
export type PriceVersionStatus = z.infer<typeof priceVersionStatusSchema>;
|
|
181
|
+
export type PriceVersion = z.infer<typeof priceVersionSchema>;
|
|
182
|
+
export type PriceSnapshot = z.infer<typeof priceSnapshotSchema>;
|