@oxyhq/contracts 0.26.0 → 0.27.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.
Files changed (46) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/accountGraph.js +4 -3
  3. package/dist/cjs/index.js +143 -1
  4. package/dist/cjs/inference/attribution.js +101 -0
  5. package/dist/cjs/inference/catalogue.js +482 -0
  6. package/dist/cjs/inference/errors.js +195 -0
  7. package/dist/cjs/inference/identifiers.js +189 -0
  8. package/dist/cjs/inference/money.js +145 -0
  9. package/dist/cjs/inference/priceVersion.js +110 -0
  10. package/dist/cjs/inference/providerConnection.js +142 -0
  11. package/dist/cjs/inference/request.js +288 -0
  12. package/dist/cjs/inference/routingPolicy.js +213 -0
  13. package/dist/cjs/inference/streamEvents.js +219 -0
  14. package/dist/cjs/inference/usage.js +291 -0
  15. package/dist/cjs/inference/version.js +57 -0
  16. package/dist/esm/.tsbuildinfo +1 -1
  17. package/dist/esm/accountGraph.js +4 -3
  18. package/dist/esm/index.js +45 -0
  19. package/dist/esm/inference/attribution.js +98 -0
  20. package/dist/esm/inference/catalogue.js +479 -0
  21. package/dist/esm/inference/errors.js +192 -0
  22. package/dist/esm/inference/identifiers.js +186 -0
  23. package/dist/esm/inference/money.js +142 -0
  24. package/dist/esm/inference/priceVersion.js +107 -0
  25. package/dist/esm/inference/providerConnection.js +139 -0
  26. package/dist/esm/inference/request.js +285 -0
  27. package/dist/esm/inference/routingPolicy.js +210 -0
  28. package/dist/esm/inference/streamEvents.js +216 -0
  29. package/dist/esm/inference/usage.js +288 -0
  30. package/dist/esm/inference/version.js +54 -0
  31. package/dist/types/.tsbuildinfo +1 -1
  32. package/dist/types/accountGraph.d.ts +6 -5
  33. package/dist/types/index.d.ts +23 -0
  34. package/dist/types/inference/attribution.d.ts +171 -0
  35. package/dist/types/inference/catalogue.d.ts +1612 -0
  36. package/dist/types/inference/errors.d.ts +193 -0
  37. package/dist/types/inference/identifiers.d.ts +149 -0
  38. package/dist/types/inference/money.d.ts +142 -0
  39. package/dist/types/inference/priceVersion.d.ts +182 -0
  40. package/dist/types/inference/providerConnection.d.ts +297 -0
  41. package/dist/types/inference/request.d.ts +2364 -0
  42. package/dist/types/inference/routingPolicy.d.ts +426 -0
  43. package/dist/types/inference/streamEvents.d.ts +906 -0
  44. package/dist/types/inference/usage.d.ts +1133 -0
  45. package/dist/types/inference/version.d.ts +54 -0
  46. package/package.json +1 -1
@@ -0,0 +1,1133 @@
1
+ /**
2
+ * The reserve → settle → refund protocol.
3
+ *
4
+ * Four records, in the order they happen:
5
+ *
6
+ * 1. **Reservation** — before a request enters the data plane, Oxy holds the
7
+ * MAXIMUM the request could cost (input units + maximum output + the
8
+ * allowed route's price ceiling). A request whose account cannot cover that
9
+ * hold is rejected before anything is spent upstream.
10
+ * 2. **Usage report** — the data plane's technical account of what was
11
+ * consumed. Units and route, never money: the data plane measures, the
12
+ * control plane prices.
13
+ * 3. **Receipt** — the immutable settlement. Carries the exact units, a COPY
14
+ * of the prices they were charged at, and the amount booked. It is never
15
+ * edited afterwards.
16
+ * 4. **Refund/reversal** — an equally immutable entry that releases an unused
17
+ * hold or reverses a settled charge. Settled history is compensated, never
18
+ * rewritten, because an invoice a customer already received must remain
19
+ * reconstructible.
20
+ *
21
+ * Every one of them is keyed by an idempotency key, so a retried call, a
22
+ * redelivered event or a duplicated webhook produces the same record rather than
23
+ * a second charge.
24
+ *
25
+ * Money is an exact decimal string throughout (ADR 0009 — never integer minor
26
+ * units, never a float), and unit counts are carried separately from it (see
27
+ * `money.ts`).
28
+ *
29
+ * Decided in: docs/adr/0009-usage-reservation-and-settlement.md.
30
+ */
31
+ import { z } from 'zod';
32
+ /**
33
+ * Ask the ledger to hold the maximum a request could cost.
34
+ *
35
+ * `maxAmount` is the number the balance check is made against, and it is
36
+ * computed from the three inputs beside it rather than guessed: the units
37
+ * already known (the prompt), the ceiling on units still to come
38
+ * (`maxOutputTokens`), and the most expensive route the policy allows. Sizing a
39
+ * hold from a typical response rather than the worst allowed one is how a
40
+ * balance goes negative on a long generation.
41
+ */
42
+ export declare const usageReservationRequestSchema: z.ZodObject<{
43
+ /** See `version.ts`: exchanged between the edge and the ledger on its own. */
44
+ schemaVersion: z.ZodLiteral<1>;
45
+ idempotencyKey: z.ZodString;
46
+ attribution: z.ZodObject<{
47
+ principal: z.ZodObject<{
48
+ billing: z.ZodObject<{
49
+ accountId: z.ZodBranded<z.ZodString, "OxyAccountId">;
50
+ }, "strict", z.ZodTypeAny, {
51
+ accountId: string & z.BRAND<"OxyAccountId">;
52
+ }, {
53
+ accountId: string;
54
+ }>;
55
+ applicationId: z.ZodString;
56
+ credentialId: z.ZodString;
57
+ environment: z.ZodEnum<["development", "staging", "production"]>;
58
+ inferenceScopes: z.ZodArray<z.ZodEnum<["inference:invoke", "inference:models:read", "inference:usage:read", "inference:routing:read", "inference:routing:write", "inference:providers:read", "inference:providers:write"]>, "many">;
59
+ }, "strip", z.ZodTypeAny, {
60
+ environment: "development" | "staging" | "production";
61
+ credentialId: string;
62
+ applicationId: string;
63
+ billing: {
64
+ accountId: string & z.BRAND<"OxyAccountId">;
65
+ };
66
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
67
+ }, {
68
+ environment: "development" | "staging" | "production";
69
+ credentialId: string;
70
+ applicationId: string;
71
+ billing: {
72
+ accountId: string;
73
+ };
74
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
75
+ }>;
76
+ userId: z.ZodOptional<z.ZodBranded<z.ZodString, "DelegatedUserId">>;
77
+ requestId: z.ZodString;
78
+ generationId: z.ZodOptional<z.ZodString>;
79
+ }, "strip", z.ZodTypeAny, {
80
+ requestId: string;
81
+ principal: {
82
+ environment: "development" | "staging" | "production";
83
+ credentialId: string;
84
+ applicationId: string;
85
+ billing: {
86
+ accountId: string & z.BRAND<"OxyAccountId">;
87
+ };
88
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
89
+ };
90
+ userId?: (string & z.BRAND<"DelegatedUserId">) | undefined;
91
+ generationId?: string | undefined;
92
+ }, {
93
+ requestId: string;
94
+ principal: {
95
+ environment: "development" | "staging" | "production";
96
+ credentialId: string;
97
+ applicationId: string;
98
+ billing: {
99
+ accountId: string;
100
+ };
101
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
102
+ };
103
+ userId?: string | undefined;
104
+ generationId?: string | undefined;
105
+ }>;
106
+ /** Units already determined by the request itself, e.g. input tokens. */
107
+ knownUnits: z.ZodDefault<z.ZodArray<z.ZodObject<{
108
+ unit: z.ZodEnum<["input_tokens", "cached_input_tokens", "output_tokens", "reasoning_tokens", "requests", "images", "audio_input_milliseconds", "audio_output_milliseconds", "video_milliseconds", "characters", "embeddings"]>;
109
+ quantity: z.ZodNumber;
110
+ }, "strict", z.ZodTypeAny, {
111
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
112
+ quantity: number;
113
+ }, {
114
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
115
+ quantity: number;
116
+ }>, "many">>;
117
+ /** The ceiling on generated output, when the request set one. */
118
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
119
+ /** The price version of the most expensive route the policy permits. */
120
+ ceilingPriceVersionId: z.ZodString;
121
+ maxAmount: z.ZodBranded<z.ZodString, "ExactDecimal">;
122
+ currency: z.ZodString;
123
+ expiresInSeconds: z.ZodNumber;
124
+ }, "strip", z.ZodTypeAny, {
125
+ attribution: {
126
+ requestId: string;
127
+ principal: {
128
+ environment: "development" | "staging" | "production";
129
+ credentialId: string;
130
+ applicationId: string;
131
+ billing: {
132
+ accountId: string & z.BRAND<"OxyAccountId">;
133
+ };
134
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
135
+ };
136
+ userId?: (string & z.BRAND<"DelegatedUserId">) | undefined;
137
+ generationId?: string | undefined;
138
+ };
139
+ idempotencyKey: string;
140
+ currency: string;
141
+ schemaVersion: 1;
142
+ knownUnits: {
143
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
144
+ quantity: number;
145
+ }[];
146
+ ceilingPriceVersionId: string;
147
+ maxAmount: string & z.BRAND<"ExactDecimal">;
148
+ expiresInSeconds: number;
149
+ maxOutputTokens?: number | undefined;
150
+ }, {
151
+ attribution: {
152
+ requestId: string;
153
+ principal: {
154
+ environment: "development" | "staging" | "production";
155
+ credentialId: string;
156
+ applicationId: string;
157
+ billing: {
158
+ accountId: string;
159
+ };
160
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
161
+ };
162
+ userId?: string | undefined;
163
+ generationId?: string | undefined;
164
+ };
165
+ idempotencyKey: string;
166
+ currency: string;
167
+ schemaVersion: 1;
168
+ ceilingPriceVersionId: string;
169
+ maxAmount: string;
170
+ expiresInSeconds: number;
171
+ maxOutputTokens?: number | undefined;
172
+ knownUnits?: {
173
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
174
+ quantity: number;
175
+ }[] | undefined;
176
+ }>;
177
+ /** Lifecycle of a hold. Terminal states are `settled`, `released`, `expired`. */
178
+ export declare const usageReservationStatusSchema: z.ZodEnum<["held", "settled", "released", "expired"]>;
179
+ /**
180
+ * A hold placed against an account's balance.
181
+ *
182
+ * Reserved amounts are shown to customers distinctly from settled charges: a
183
+ * reservation is not money spent, and presenting the two as one number makes a
184
+ * balance appear to drop and then recover for every request.
185
+ */
186
+ export declare const usageReservationSchema: z.ZodEffects<z.ZodObject<{
187
+ /** See `version.ts`: read back by the edge and the Console on its own. */
188
+ schemaVersion: z.ZodLiteral<1>;
189
+ reservationId: z.ZodString;
190
+ idempotencyKey: z.ZodString;
191
+ attribution: z.ZodObject<{
192
+ principal: z.ZodObject<{
193
+ billing: z.ZodObject<{
194
+ accountId: z.ZodBranded<z.ZodString, "OxyAccountId">;
195
+ }, "strict", z.ZodTypeAny, {
196
+ accountId: string & z.BRAND<"OxyAccountId">;
197
+ }, {
198
+ accountId: string;
199
+ }>;
200
+ applicationId: z.ZodString;
201
+ credentialId: z.ZodString;
202
+ environment: z.ZodEnum<["development", "staging", "production"]>;
203
+ inferenceScopes: z.ZodArray<z.ZodEnum<["inference:invoke", "inference:models:read", "inference:usage:read", "inference:routing:read", "inference:routing:write", "inference:providers:read", "inference:providers:write"]>, "many">;
204
+ }, "strip", z.ZodTypeAny, {
205
+ environment: "development" | "staging" | "production";
206
+ credentialId: string;
207
+ applicationId: string;
208
+ billing: {
209
+ accountId: string & z.BRAND<"OxyAccountId">;
210
+ };
211
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
212
+ }, {
213
+ environment: "development" | "staging" | "production";
214
+ credentialId: string;
215
+ applicationId: string;
216
+ billing: {
217
+ accountId: string;
218
+ };
219
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
220
+ }>;
221
+ userId: z.ZodOptional<z.ZodBranded<z.ZodString, "DelegatedUserId">>;
222
+ requestId: z.ZodString;
223
+ generationId: z.ZodOptional<z.ZodString>;
224
+ }, "strip", z.ZodTypeAny, {
225
+ requestId: string;
226
+ principal: {
227
+ environment: "development" | "staging" | "production";
228
+ credentialId: string;
229
+ applicationId: string;
230
+ billing: {
231
+ accountId: string & z.BRAND<"OxyAccountId">;
232
+ };
233
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
234
+ };
235
+ userId?: (string & z.BRAND<"DelegatedUserId">) | undefined;
236
+ generationId?: string | undefined;
237
+ }, {
238
+ requestId: string;
239
+ principal: {
240
+ environment: "development" | "staging" | "production";
241
+ credentialId: string;
242
+ applicationId: string;
243
+ billing: {
244
+ accountId: string;
245
+ };
246
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
247
+ };
248
+ userId?: string | undefined;
249
+ generationId?: string | undefined;
250
+ }>;
251
+ status: z.ZodEnum<["held", "settled", "released", "expired"]>;
252
+ reservedAmount: z.ZodBranded<z.ZodString, "ExactDecimal">;
253
+ currency: z.ZodString;
254
+ ceilingPriceVersionId: z.ZodString;
255
+ createdAt: z.ZodString;
256
+ expiresAt: z.ZodString;
257
+ /** The receipt that consumed this hold. Present exactly when `settled`. */
258
+ settledReceiptId: z.ZodOptional<z.ZodString>;
259
+ }, "strip", z.ZodTypeAny, {
260
+ status: "expired" | "held" | "settled" | "released";
261
+ expiresAt: string;
262
+ attribution: {
263
+ requestId: string;
264
+ principal: {
265
+ environment: "development" | "staging" | "production";
266
+ credentialId: string;
267
+ applicationId: string;
268
+ billing: {
269
+ accountId: string & z.BRAND<"OxyAccountId">;
270
+ };
271
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
272
+ };
273
+ userId?: (string & z.BRAND<"DelegatedUserId">) | undefined;
274
+ generationId?: string | undefined;
275
+ };
276
+ idempotencyKey: string;
277
+ createdAt: string;
278
+ currency: string;
279
+ schemaVersion: 1;
280
+ ceilingPriceVersionId: string;
281
+ reservationId: string;
282
+ reservedAmount: string & z.BRAND<"ExactDecimal">;
283
+ settledReceiptId?: string | undefined;
284
+ }, {
285
+ status: "expired" | "held" | "settled" | "released";
286
+ expiresAt: string;
287
+ attribution: {
288
+ requestId: string;
289
+ principal: {
290
+ environment: "development" | "staging" | "production";
291
+ credentialId: string;
292
+ applicationId: string;
293
+ billing: {
294
+ accountId: string;
295
+ };
296
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
297
+ };
298
+ userId?: string | undefined;
299
+ generationId?: string | undefined;
300
+ };
301
+ idempotencyKey: string;
302
+ createdAt: string;
303
+ currency: string;
304
+ schemaVersion: 1;
305
+ ceilingPriceVersionId: string;
306
+ reservationId: string;
307
+ reservedAmount: string;
308
+ settledReceiptId?: string | undefined;
309
+ }>, {
310
+ status: "expired" | "held" | "settled" | "released";
311
+ expiresAt: string;
312
+ attribution: {
313
+ requestId: string;
314
+ principal: {
315
+ environment: "development" | "staging" | "production";
316
+ credentialId: string;
317
+ applicationId: string;
318
+ billing: {
319
+ accountId: string & z.BRAND<"OxyAccountId">;
320
+ };
321
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
322
+ };
323
+ userId?: (string & z.BRAND<"DelegatedUserId">) | undefined;
324
+ generationId?: string | undefined;
325
+ };
326
+ idempotencyKey: string;
327
+ createdAt: string;
328
+ currency: string;
329
+ schemaVersion: 1;
330
+ ceilingPriceVersionId: string;
331
+ reservationId: string;
332
+ reservedAmount: string & z.BRAND<"ExactDecimal">;
333
+ settledReceiptId?: string | undefined;
334
+ }, {
335
+ status: "expired" | "held" | "settled" | "released";
336
+ expiresAt: string;
337
+ attribution: {
338
+ requestId: string;
339
+ principal: {
340
+ environment: "development" | "staging" | "production";
341
+ credentialId: string;
342
+ applicationId: string;
343
+ billing: {
344
+ accountId: string;
345
+ };
346
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
347
+ };
348
+ userId?: string | undefined;
349
+ generationId?: string | undefined;
350
+ };
351
+ idempotencyKey: string;
352
+ createdAt: string;
353
+ currency: string;
354
+ schemaVersion: 1;
355
+ ceilingPriceVersionId: string;
356
+ reservationId: string;
357
+ reservedAmount: string;
358
+ settledReceiptId?: string | undefined;
359
+ }>;
360
+ /** How a request ended, from the data plane's point of view. */
361
+ export declare const inferenceRequestOutcomeSchema: z.ZodEnum<["completed", "partial", "cancelled", "failed"]>;
362
+ /**
363
+ * The data plane's technical account of one request.
364
+ *
365
+ * No money and no price: the data plane measures units and names the route it
366
+ * used, and the control plane decides what that costs. Keeping the two apart is
367
+ * what allows a price to be corrected after the fact without re-running or
368
+ * re-measuring anything.
369
+ *
370
+ * `usageSource` is load-bearing when a provider returns no usage at all: the
371
+ * report still arrives, marked `estimated`, so settlement can apply the
372
+ * estimation policy knowingly instead of treating a reconstruction as fact.
373
+ */
374
+ export declare const normalizedUsageReportSchema: z.ZodEffects<z.ZodObject<{
375
+ /** See `version.ts`: emitted by the data plane as a whole message. */
376
+ schemaVersion: z.ZodLiteral<1>;
377
+ requestId: z.ZodString;
378
+ generationId: z.ZodOptional<z.ZodString>;
379
+ attribution: z.ZodObject<{
380
+ principal: z.ZodObject<{
381
+ billing: z.ZodObject<{
382
+ accountId: z.ZodBranded<z.ZodString, "OxyAccountId">;
383
+ }, "strict", z.ZodTypeAny, {
384
+ accountId: string & z.BRAND<"OxyAccountId">;
385
+ }, {
386
+ accountId: string;
387
+ }>;
388
+ applicationId: z.ZodString;
389
+ credentialId: z.ZodString;
390
+ environment: z.ZodEnum<["development", "staging", "production"]>;
391
+ inferenceScopes: z.ZodArray<z.ZodEnum<["inference:invoke", "inference:models:read", "inference:usage:read", "inference:routing:read", "inference:routing:write", "inference:providers:read", "inference:providers:write"]>, "many">;
392
+ }, "strip", z.ZodTypeAny, {
393
+ environment: "development" | "staging" | "production";
394
+ credentialId: string;
395
+ applicationId: string;
396
+ billing: {
397
+ accountId: string & z.BRAND<"OxyAccountId">;
398
+ };
399
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
400
+ }, {
401
+ environment: "development" | "staging" | "production";
402
+ credentialId: string;
403
+ applicationId: string;
404
+ billing: {
405
+ accountId: string;
406
+ };
407
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
408
+ }>;
409
+ userId: z.ZodOptional<z.ZodBranded<z.ZodString, "DelegatedUserId">>;
410
+ requestId: z.ZodString;
411
+ generationId: z.ZodOptional<z.ZodString>;
412
+ }, "strip", z.ZodTypeAny, {
413
+ requestId: string;
414
+ principal: {
415
+ environment: "development" | "staging" | "production";
416
+ credentialId: string;
417
+ applicationId: string;
418
+ billing: {
419
+ accountId: string & z.BRAND<"OxyAccountId">;
420
+ };
421
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
422
+ };
423
+ userId?: (string & z.BRAND<"DelegatedUserId">) | undefined;
424
+ generationId?: string | undefined;
425
+ }, {
426
+ requestId: string;
427
+ principal: {
428
+ environment: "development" | "staging" | "production";
429
+ credentialId: string;
430
+ applicationId: string;
431
+ billing: {
432
+ accountId: string;
433
+ };
434
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
435
+ };
436
+ userId?: string | undefined;
437
+ generationId?: string | undefined;
438
+ }>;
439
+ outcome: z.ZodEnum<["completed", "partial", "cancelled", "failed"]>;
440
+ units: z.ZodArray<z.ZodObject<{
441
+ unit: z.ZodEnum<["input_tokens", "cached_input_tokens", "output_tokens", "reasoning_tokens", "requests", "images", "audio_input_milliseconds", "audio_output_milliseconds", "video_milliseconds", "characters", "embeddings"]>;
442
+ quantity: z.ZodNumber;
443
+ }, "strict", z.ZodTypeAny, {
444
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
445
+ quantity: number;
446
+ }, {
447
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
448
+ quantity: number;
449
+ }>, "many">;
450
+ usageSource: z.ZodEnum<["provider_reported", "oxy_measured", "estimated"]>;
451
+ resolvedModelReference: z.ZodString;
452
+ servingProvider: z.ZodString;
453
+ deploymentId: z.ZodOptional<z.ZodString>;
454
+ /** How many allowed route switches occurred while serving this request. */
455
+ routeSwitches: z.ZodNumber;
456
+ startedAt: z.ZodString;
457
+ completedAt: z.ZodString;
458
+ timeToFirstTokenMs: z.ZodOptional<z.ZodNumber>;
459
+ }, "strip", z.ZodTypeAny, {
460
+ requestId: string;
461
+ attribution: {
462
+ requestId: string;
463
+ principal: {
464
+ environment: "development" | "staging" | "production";
465
+ credentialId: string;
466
+ applicationId: string;
467
+ billing: {
468
+ accountId: string & z.BRAND<"OxyAccountId">;
469
+ };
470
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
471
+ };
472
+ userId?: (string & z.BRAND<"DelegatedUserId">) | undefined;
473
+ generationId?: string | undefined;
474
+ };
475
+ schemaVersion: 1;
476
+ resolvedModelReference: string;
477
+ servingProvider: string;
478
+ startedAt: string;
479
+ units: {
480
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
481
+ quantity: number;
482
+ }[];
483
+ usageSource: "provider_reported" | "oxy_measured" | "estimated";
484
+ completedAt: string;
485
+ outcome: "cancelled" | "completed" | "partial" | "failed";
486
+ routeSwitches: number;
487
+ generationId?: string | undefined;
488
+ deploymentId?: string | undefined;
489
+ timeToFirstTokenMs?: number | undefined;
490
+ }, {
491
+ requestId: string;
492
+ attribution: {
493
+ requestId: string;
494
+ principal: {
495
+ environment: "development" | "staging" | "production";
496
+ credentialId: string;
497
+ applicationId: string;
498
+ billing: {
499
+ accountId: string;
500
+ };
501
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
502
+ };
503
+ userId?: string | undefined;
504
+ generationId?: string | undefined;
505
+ };
506
+ schemaVersion: 1;
507
+ resolvedModelReference: string;
508
+ servingProvider: string;
509
+ startedAt: string;
510
+ units: {
511
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
512
+ quantity: number;
513
+ }[];
514
+ usageSource: "provider_reported" | "oxy_measured" | "estimated";
515
+ completedAt: string;
516
+ outcome: "cancelled" | "completed" | "partial" | "failed";
517
+ routeSwitches: number;
518
+ generationId?: string | undefined;
519
+ deploymentId?: string | undefined;
520
+ timeToFirstTokenMs?: number | undefined;
521
+ }>, {
522
+ requestId: string;
523
+ attribution: {
524
+ requestId: string;
525
+ principal: {
526
+ environment: "development" | "staging" | "production";
527
+ credentialId: string;
528
+ applicationId: string;
529
+ billing: {
530
+ accountId: string & z.BRAND<"OxyAccountId">;
531
+ };
532
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
533
+ };
534
+ userId?: (string & z.BRAND<"DelegatedUserId">) | undefined;
535
+ generationId?: string | undefined;
536
+ };
537
+ schemaVersion: 1;
538
+ resolvedModelReference: string;
539
+ servingProvider: string;
540
+ startedAt: string;
541
+ units: {
542
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
543
+ quantity: number;
544
+ }[];
545
+ usageSource: "provider_reported" | "oxy_measured" | "estimated";
546
+ completedAt: string;
547
+ outcome: "cancelled" | "completed" | "partial" | "failed";
548
+ routeSwitches: number;
549
+ generationId?: string | undefined;
550
+ deploymentId?: string | undefined;
551
+ timeToFirstTokenMs?: number | undefined;
552
+ }, {
553
+ requestId: string;
554
+ attribution: {
555
+ requestId: string;
556
+ principal: {
557
+ environment: "development" | "staging" | "production";
558
+ credentialId: string;
559
+ applicationId: string;
560
+ billing: {
561
+ accountId: string;
562
+ };
563
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
564
+ };
565
+ userId?: string | undefined;
566
+ generationId?: string | undefined;
567
+ };
568
+ schemaVersion: 1;
569
+ resolvedModelReference: string;
570
+ servingProvider: string;
571
+ startedAt: string;
572
+ units: {
573
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
574
+ quantity: number;
575
+ }[];
576
+ usageSource: "provider_reported" | "oxy_measured" | "estimated";
577
+ completedAt: string;
578
+ outcome: "cancelled" | "completed" | "partial" | "failed";
579
+ routeSwitches: number;
580
+ generationId?: string | undefined;
581
+ deploymentId?: string | undefined;
582
+ timeToFirstTokenMs?: number | undefined;
583
+ }>;
584
+ /**
585
+ * The immutable record of what a request was actually charged.
586
+ *
587
+ * `priceSnapshot` is a COPY of the unit prices applied, not just the id of the
588
+ * price version they came from, so the arithmetic on this receipt can be
589
+ * checked years later without depending on any other record still existing.
590
+ *
591
+ * `platformFeeOnly` marks a BYOK request: the upstream provider billed the
592
+ * customer's own account directly, and `billedAmount` is Oxy's service fee
593
+ * rather than the cost of the tokens. Without the flag, the two look identical
594
+ * and a BYOK customer appears to have been charged twice for one request.
595
+ */
596
+ export declare const usageReceiptSchema: z.ZodEffects<z.ZodObject<{
597
+ /** See `version.ts`: returned to customers by `GET /v1/generations/:id`. */
598
+ schemaVersion: z.ZodLiteral<1>;
599
+ receiptId: z.ZodString;
600
+ /** The hold this settled against. Absent for a charge with no reservation. */
601
+ reservationId: z.ZodOptional<z.ZodString>;
602
+ idempotencyKey: z.ZodString;
603
+ attribution: z.ZodObject<{
604
+ principal: z.ZodObject<{
605
+ billing: z.ZodObject<{
606
+ accountId: z.ZodBranded<z.ZodString, "OxyAccountId">;
607
+ }, "strict", z.ZodTypeAny, {
608
+ accountId: string & z.BRAND<"OxyAccountId">;
609
+ }, {
610
+ accountId: string;
611
+ }>;
612
+ applicationId: z.ZodString;
613
+ credentialId: z.ZodString;
614
+ environment: z.ZodEnum<["development", "staging", "production"]>;
615
+ inferenceScopes: z.ZodArray<z.ZodEnum<["inference:invoke", "inference:models:read", "inference:usage:read", "inference:routing:read", "inference:routing:write", "inference:providers:read", "inference:providers:write"]>, "many">;
616
+ }, "strip", z.ZodTypeAny, {
617
+ environment: "development" | "staging" | "production";
618
+ credentialId: string;
619
+ applicationId: string;
620
+ billing: {
621
+ accountId: string & z.BRAND<"OxyAccountId">;
622
+ };
623
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
624
+ }, {
625
+ environment: "development" | "staging" | "production";
626
+ credentialId: string;
627
+ applicationId: string;
628
+ billing: {
629
+ accountId: string;
630
+ };
631
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
632
+ }>;
633
+ userId: z.ZodOptional<z.ZodBranded<z.ZodString, "DelegatedUserId">>;
634
+ requestId: z.ZodString;
635
+ generationId: z.ZodOptional<z.ZodString>;
636
+ }, "strip", z.ZodTypeAny, {
637
+ requestId: string;
638
+ principal: {
639
+ environment: "development" | "staging" | "production";
640
+ credentialId: string;
641
+ applicationId: string;
642
+ billing: {
643
+ accountId: string & z.BRAND<"OxyAccountId">;
644
+ };
645
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
646
+ };
647
+ userId?: (string & z.BRAND<"DelegatedUserId">) | undefined;
648
+ generationId?: string | undefined;
649
+ }, {
650
+ requestId: string;
651
+ principal: {
652
+ environment: "development" | "staging" | "production";
653
+ credentialId: string;
654
+ applicationId: string;
655
+ billing: {
656
+ accountId: string;
657
+ };
658
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
659
+ };
660
+ userId?: string | undefined;
661
+ generationId?: string | undefined;
662
+ }>;
663
+ outcome: z.ZodEnum<["completed", "partial", "cancelled", "failed"]>;
664
+ units: z.ZodArray<z.ZodObject<{
665
+ unit: z.ZodEnum<["input_tokens", "cached_input_tokens", "output_tokens", "reasoning_tokens", "requests", "images", "audio_input_milliseconds", "audio_output_milliseconds", "video_milliseconds", "characters", "embeddings"]>;
666
+ quantity: z.ZodNumber;
667
+ }, "strict", z.ZodTypeAny, {
668
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
669
+ quantity: number;
670
+ }, {
671
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
672
+ quantity: number;
673
+ }>, "many">;
674
+ usageSource: z.ZodEnum<["provider_reported", "oxy_measured", "estimated"]>;
675
+ priceSnapshot: z.ZodObject<{
676
+ priceVersionId: z.ZodString;
677
+ currency: z.ZodString;
678
+ unitPrices: z.ZodArray<z.ZodObject<{
679
+ unit: z.ZodEnum<["input_tokens", "cached_input_tokens", "output_tokens", "reasoning_tokens", "requests", "images", "audio_input_milliseconds", "audio_output_milliseconds", "video_milliseconds", "characters", "embeddings"]>;
680
+ amount: z.ZodBranded<z.ZodString, "ExactDecimal">;
681
+ per: z.ZodNumber;
682
+ currency: z.ZodString;
683
+ }, "strict", z.ZodTypeAny, {
684
+ amount: string & z.BRAND<"ExactDecimal">;
685
+ currency: string;
686
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
687
+ per: number;
688
+ }, {
689
+ amount: string;
690
+ currency: string;
691
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
692
+ per: number;
693
+ }>, "many">;
694
+ }, "strict", z.ZodTypeAny, {
695
+ currency: string;
696
+ priceVersionId: string;
697
+ unitPrices: {
698
+ amount: string & z.BRAND<"ExactDecimal">;
699
+ currency: string;
700
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
701
+ per: number;
702
+ }[];
703
+ }, {
704
+ currency: string;
705
+ priceVersionId: string;
706
+ unitPrices: {
707
+ amount: string;
708
+ currency: string;
709
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
710
+ per: number;
711
+ }[];
712
+ }>;
713
+ billedAmount: z.ZodBranded<z.ZodString, "ExactDecimal">;
714
+ currency: z.ZodString;
715
+ platformFeeOnly: z.ZodBoolean;
716
+ resolvedModelReference: z.ZodString;
717
+ servingProvider: z.ZodString;
718
+ settledAt: z.ZodString;
719
+ }, "strip", z.ZodTypeAny, {
720
+ attribution: {
721
+ requestId: string;
722
+ principal: {
723
+ environment: "development" | "staging" | "production";
724
+ credentialId: string;
725
+ applicationId: string;
726
+ billing: {
727
+ accountId: string & z.BRAND<"OxyAccountId">;
728
+ };
729
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
730
+ };
731
+ userId?: (string & z.BRAND<"DelegatedUserId">) | undefined;
732
+ generationId?: string | undefined;
733
+ };
734
+ idempotencyKey: string;
735
+ currency: string;
736
+ schemaVersion: 1;
737
+ resolvedModelReference: string;
738
+ servingProvider: string;
739
+ units: {
740
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
741
+ quantity: number;
742
+ }[];
743
+ usageSource: "provider_reported" | "oxy_measured" | "estimated";
744
+ receiptId: string;
745
+ outcome: "cancelled" | "completed" | "partial" | "failed";
746
+ priceSnapshot: {
747
+ currency: string;
748
+ priceVersionId: string;
749
+ unitPrices: {
750
+ amount: string & z.BRAND<"ExactDecimal">;
751
+ currency: string;
752
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
753
+ per: number;
754
+ }[];
755
+ };
756
+ billedAmount: string & z.BRAND<"ExactDecimal">;
757
+ platformFeeOnly: boolean;
758
+ settledAt: string;
759
+ reservationId?: string | undefined;
760
+ }, {
761
+ attribution: {
762
+ requestId: string;
763
+ principal: {
764
+ environment: "development" | "staging" | "production";
765
+ credentialId: string;
766
+ applicationId: string;
767
+ billing: {
768
+ accountId: string;
769
+ };
770
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
771
+ };
772
+ userId?: string | undefined;
773
+ generationId?: string | undefined;
774
+ };
775
+ idempotencyKey: string;
776
+ currency: string;
777
+ schemaVersion: 1;
778
+ resolvedModelReference: string;
779
+ servingProvider: string;
780
+ units: {
781
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
782
+ quantity: number;
783
+ }[];
784
+ usageSource: "provider_reported" | "oxy_measured" | "estimated";
785
+ receiptId: string;
786
+ outcome: "cancelled" | "completed" | "partial" | "failed";
787
+ priceSnapshot: {
788
+ currency: string;
789
+ priceVersionId: string;
790
+ unitPrices: {
791
+ amount: string;
792
+ currency: string;
793
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
794
+ per: number;
795
+ }[];
796
+ };
797
+ billedAmount: string;
798
+ platformFeeOnly: boolean;
799
+ settledAt: string;
800
+ reservationId?: string | undefined;
801
+ }>, {
802
+ attribution: {
803
+ requestId: string;
804
+ principal: {
805
+ environment: "development" | "staging" | "production";
806
+ credentialId: string;
807
+ applicationId: string;
808
+ billing: {
809
+ accountId: string & z.BRAND<"OxyAccountId">;
810
+ };
811
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
812
+ };
813
+ userId?: (string & z.BRAND<"DelegatedUserId">) | undefined;
814
+ generationId?: string | undefined;
815
+ };
816
+ idempotencyKey: string;
817
+ currency: string;
818
+ schemaVersion: 1;
819
+ resolvedModelReference: string;
820
+ servingProvider: string;
821
+ units: {
822
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
823
+ quantity: number;
824
+ }[];
825
+ usageSource: "provider_reported" | "oxy_measured" | "estimated";
826
+ receiptId: string;
827
+ outcome: "cancelled" | "completed" | "partial" | "failed";
828
+ priceSnapshot: {
829
+ currency: string;
830
+ priceVersionId: string;
831
+ unitPrices: {
832
+ amount: string & z.BRAND<"ExactDecimal">;
833
+ currency: string;
834
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
835
+ per: number;
836
+ }[];
837
+ };
838
+ billedAmount: string & z.BRAND<"ExactDecimal">;
839
+ platformFeeOnly: boolean;
840
+ settledAt: string;
841
+ reservationId?: string | undefined;
842
+ }, {
843
+ attribution: {
844
+ requestId: string;
845
+ principal: {
846
+ environment: "development" | "staging" | "production";
847
+ credentialId: string;
848
+ applicationId: string;
849
+ billing: {
850
+ accountId: string;
851
+ };
852
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
853
+ };
854
+ userId?: string | undefined;
855
+ generationId?: string | undefined;
856
+ };
857
+ idempotencyKey: string;
858
+ currency: string;
859
+ schemaVersion: 1;
860
+ resolvedModelReference: string;
861
+ servingProvider: string;
862
+ units: {
863
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
864
+ quantity: number;
865
+ }[];
866
+ usageSource: "provider_reported" | "oxy_measured" | "estimated";
867
+ receiptId: string;
868
+ outcome: "cancelled" | "completed" | "partial" | "failed";
869
+ priceSnapshot: {
870
+ currency: string;
871
+ priceVersionId: string;
872
+ unitPrices: {
873
+ amount: string;
874
+ currency: string;
875
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
876
+ per: number;
877
+ }[];
878
+ };
879
+ billedAmount: string;
880
+ platformFeeOnly: boolean;
881
+ settledAt: string;
882
+ reservationId?: string | undefined;
883
+ }>;
884
+ /**
885
+ * What a reversal acts on: an unused hold, or a settled charge.
886
+ *
887
+ * A discriminated union, so "release the rest of the hold" and "give back money
888
+ * already booked" can never be confused for one another — they hit different
889
+ * ledger accounts and only the second one is visible on an invoice.
890
+ */
891
+ export declare const usageRefundSubjectSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
892
+ kind: z.ZodLiteral<"reservation">;
893
+ reservationId: z.ZodString;
894
+ }, "strict", z.ZodTypeAny, {
895
+ kind: "reservation";
896
+ reservationId: string;
897
+ }, {
898
+ kind: "reservation";
899
+ reservationId: string;
900
+ }>, z.ZodObject<{
901
+ kind: z.ZodLiteral<"receipt">;
902
+ receiptId: z.ZodString;
903
+ }, "strict", z.ZodTypeAny, {
904
+ kind: "receipt";
905
+ receiptId: string;
906
+ }, {
907
+ kind: "receipt";
908
+ receiptId: string;
909
+ }>]>;
910
+ /** Why money was given back or a hold was released. */
911
+ export declare const usageRefundReasonSchema: z.ZodEnum<["unused_reservation", "client_cancelled", "upstream_failure", "partial_stream", "usage_unavailable", "billing_correction", "duplicate_charge"]>;
912
+ /**
913
+ * An immutable reversal entry.
914
+ *
915
+ * `amount` is non-negative like every other amount in this contract: the
916
+ * direction is carried by the record being a refund, not by a sign that a
917
+ * consumer could read the wrong way round. Idempotent by key, so a retried
918
+ * refund releases the same money once.
919
+ */
920
+ export declare const usageRefundSchema: z.ZodEffects<z.ZodObject<{
921
+ /** See `version.ts`: a ledger record read back on its own. */
922
+ schemaVersion: z.ZodLiteral<1>;
923
+ refundId: z.ZodString;
924
+ idempotencyKey: z.ZodString;
925
+ attribution: z.ZodObject<{
926
+ principal: z.ZodObject<{
927
+ billing: z.ZodObject<{
928
+ accountId: z.ZodBranded<z.ZodString, "OxyAccountId">;
929
+ }, "strict", z.ZodTypeAny, {
930
+ accountId: string & z.BRAND<"OxyAccountId">;
931
+ }, {
932
+ accountId: string;
933
+ }>;
934
+ applicationId: z.ZodString;
935
+ credentialId: z.ZodString;
936
+ environment: z.ZodEnum<["development", "staging", "production"]>;
937
+ inferenceScopes: z.ZodArray<z.ZodEnum<["inference:invoke", "inference:models:read", "inference:usage:read", "inference:routing:read", "inference:routing:write", "inference:providers:read", "inference:providers:write"]>, "many">;
938
+ }, "strip", z.ZodTypeAny, {
939
+ environment: "development" | "staging" | "production";
940
+ credentialId: string;
941
+ applicationId: string;
942
+ billing: {
943
+ accountId: string & z.BRAND<"OxyAccountId">;
944
+ };
945
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
946
+ }, {
947
+ environment: "development" | "staging" | "production";
948
+ credentialId: string;
949
+ applicationId: string;
950
+ billing: {
951
+ accountId: string;
952
+ };
953
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
954
+ }>;
955
+ userId: z.ZodOptional<z.ZodBranded<z.ZodString, "DelegatedUserId">>;
956
+ requestId: z.ZodString;
957
+ generationId: z.ZodOptional<z.ZodString>;
958
+ }, "strip", z.ZodTypeAny, {
959
+ requestId: string;
960
+ principal: {
961
+ environment: "development" | "staging" | "production";
962
+ credentialId: string;
963
+ applicationId: string;
964
+ billing: {
965
+ accountId: string & z.BRAND<"OxyAccountId">;
966
+ };
967
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
968
+ };
969
+ userId?: (string & z.BRAND<"DelegatedUserId">) | undefined;
970
+ generationId?: string | undefined;
971
+ }, {
972
+ requestId: string;
973
+ principal: {
974
+ environment: "development" | "staging" | "production";
975
+ credentialId: string;
976
+ applicationId: string;
977
+ billing: {
978
+ accountId: string;
979
+ };
980
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
981
+ };
982
+ userId?: string | undefined;
983
+ generationId?: string | undefined;
984
+ }>;
985
+ subject: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
986
+ kind: z.ZodLiteral<"reservation">;
987
+ reservationId: z.ZodString;
988
+ }, "strict", z.ZodTypeAny, {
989
+ kind: "reservation";
990
+ reservationId: string;
991
+ }, {
992
+ kind: "reservation";
993
+ reservationId: string;
994
+ }>, z.ZodObject<{
995
+ kind: z.ZodLiteral<"receipt">;
996
+ receiptId: z.ZodString;
997
+ }, "strict", z.ZodTypeAny, {
998
+ kind: "receipt";
999
+ receiptId: string;
1000
+ }, {
1001
+ kind: "receipt";
1002
+ receiptId: string;
1003
+ }>]>;
1004
+ reason: z.ZodEnum<["unused_reservation", "client_cancelled", "upstream_failure", "partial_stream", "usage_unavailable", "billing_correction", "duplicate_charge"]>;
1005
+ amount: z.ZodBranded<z.ZodString, "ExactDecimal">;
1006
+ currency: z.ZodString;
1007
+ createdAt: z.ZodString;
1008
+ }, "strip", z.ZodTypeAny, {
1009
+ reason: "unused_reservation" | "client_cancelled" | "upstream_failure" | "partial_stream" | "usage_unavailable" | "billing_correction" | "duplicate_charge";
1010
+ subject: {
1011
+ kind: "reservation";
1012
+ reservationId: string;
1013
+ } | {
1014
+ kind: "receipt";
1015
+ receiptId: string;
1016
+ };
1017
+ attribution: {
1018
+ requestId: string;
1019
+ principal: {
1020
+ environment: "development" | "staging" | "production";
1021
+ credentialId: string;
1022
+ applicationId: string;
1023
+ billing: {
1024
+ accountId: string & z.BRAND<"OxyAccountId">;
1025
+ };
1026
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
1027
+ };
1028
+ userId?: (string & z.BRAND<"DelegatedUserId">) | undefined;
1029
+ generationId?: string | undefined;
1030
+ };
1031
+ idempotencyKey: string;
1032
+ createdAt: string;
1033
+ amount: string & z.BRAND<"ExactDecimal">;
1034
+ currency: string;
1035
+ schemaVersion: 1;
1036
+ refundId: string;
1037
+ }, {
1038
+ reason: "unused_reservation" | "client_cancelled" | "upstream_failure" | "partial_stream" | "usage_unavailable" | "billing_correction" | "duplicate_charge";
1039
+ subject: {
1040
+ kind: "reservation";
1041
+ reservationId: string;
1042
+ } | {
1043
+ kind: "receipt";
1044
+ receiptId: string;
1045
+ };
1046
+ attribution: {
1047
+ requestId: string;
1048
+ principal: {
1049
+ environment: "development" | "staging" | "production";
1050
+ credentialId: string;
1051
+ applicationId: string;
1052
+ billing: {
1053
+ accountId: string;
1054
+ };
1055
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
1056
+ };
1057
+ userId?: string | undefined;
1058
+ generationId?: string | undefined;
1059
+ };
1060
+ idempotencyKey: string;
1061
+ createdAt: string;
1062
+ amount: string;
1063
+ currency: string;
1064
+ schemaVersion: 1;
1065
+ refundId: string;
1066
+ }>, {
1067
+ reason: "unused_reservation" | "client_cancelled" | "upstream_failure" | "partial_stream" | "usage_unavailable" | "billing_correction" | "duplicate_charge";
1068
+ subject: {
1069
+ kind: "reservation";
1070
+ reservationId: string;
1071
+ } | {
1072
+ kind: "receipt";
1073
+ receiptId: string;
1074
+ };
1075
+ attribution: {
1076
+ requestId: string;
1077
+ principal: {
1078
+ environment: "development" | "staging" | "production";
1079
+ credentialId: string;
1080
+ applicationId: string;
1081
+ billing: {
1082
+ accountId: string & z.BRAND<"OxyAccountId">;
1083
+ };
1084
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
1085
+ };
1086
+ userId?: (string & z.BRAND<"DelegatedUserId">) | undefined;
1087
+ generationId?: string | undefined;
1088
+ };
1089
+ idempotencyKey: string;
1090
+ createdAt: string;
1091
+ amount: string & z.BRAND<"ExactDecimal">;
1092
+ currency: string;
1093
+ schemaVersion: 1;
1094
+ refundId: string;
1095
+ }, {
1096
+ reason: "unused_reservation" | "client_cancelled" | "upstream_failure" | "partial_stream" | "usage_unavailable" | "billing_correction" | "duplicate_charge";
1097
+ subject: {
1098
+ kind: "reservation";
1099
+ reservationId: string;
1100
+ } | {
1101
+ kind: "receipt";
1102
+ receiptId: string;
1103
+ };
1104
+ attribution: {
1105
+ requestId: string;
1106
+ principal: {
1107
+ environment: "development" | "staging" | "production";
1108
+ credentialId: string;
1109
+ applicationId: string;
1110
+ billing: {
1111
+ accountId: string;
1112
+ };
1113
+ inferenceScopes: ("inference:invoke" | "inference:models:read" | "inference:usage:read" | "inference:routing:read" | "inference:routing:write" | "inference:providers:read" | "inference:providers:write")[];
1114
+ };
1115
+ userId?: string | undefined;
1116
+ generationId?: string | undefined;
1117
+ };
1118
+ idempotencyKey: string;
1119
+ createdAt: string;
1120
+ amount: string;
1121
+ currency: string;
1122
+ schemaVersion: 1;
1123
+ refundId: string;
1124
+ }>;
1125
+ export type UsageReservationRequest = z.infer<typeof usageReservationRequestSchema>;
1126
+ export type UsageReservationStatus = z.infer<typeof usageReservationStatusSchema>;
1127
+ export type UsageReservation = z.infer<typeof usageReservationSchema>;
1128
+ export type InferenceRequestOutcome = z.infer<typeof inferenceRequestOutcomeSchema>;
1129
+ export type NormalizedUsageReport = z.infer<typeof normalizedUsageReportSchema>;
1130
+ export type UsageReceipt = z.infer<typeof usageReceiptSchema>;
1131
+ export type UsageRefundSubject = z.infer<typeof usageRefundSubjectSchema>;
1132
+ export type UsageRefundReason = z.infer<typeof usageRefundReasonSchema>;
1133
+ export type UsageRefund = z.infer<typeof usageRefundSchema>;