@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.
Files changed (147) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +16 -0
  3. package/dist/cjs/.tsbuildinfo +1 -0
  4. package/dist/cjs/accountGraph.js +489 -0
  5. package/dist/cjs/agency.js +439 -0
  6. package/dist/cjs/browserHub.js +215 -0
  7. package/dist/cjs/civic.js +163 -0
  8. package/dist/cjs/commonsSignIn.js +59 -0
  9. package/dist/cjs/deviceBoot.js +50 -0
  10. package/dist/cjs/deviceDirectory.js +189 -0
  11. package/dist/cjs/devicePairing.js +138 -0
  12. package/dist/cjs/deviceSession.js +164 -0
  13. package/dist/cjs/emailAgentContext.js +32 -0
  14. package/dist/cjs/followGraph.js +28 -0
  15. package/dist/cjs/identity.js +258 -0
  16. package/dist/cjs/inboxPush.js +24 -0
  17. package/dist/cjs/index.js +618 -0
  18. package/dist/cjs/inference/accountBilling.js +334 -0
  19. package/dist/cjs/inference/aliaModelRelease.js +262 -0
  20. package/dist/cjs/inference/attribution.js +106 -0
  21. package/dist/cjs/inference/catalogue.js +487 -0
  22. package/dist/cjs/inference/entitlement.js +217 -0
  23. package/dist/cjs/inference/errors.js +309 -0
  24. package/dist/cjs/inference/identifiers.js +224 -0
  25. package/dist/cjs/inference/inbox.js +105 -0
  26. package/dist/cjs/inference/modelDocumentation.js +433 -0
  27. package/dist/cjs/inference/money.js +188 -0
  28. package/dist/cjs/inference/priceVersion.js +110 -0
  29. package/dist/cjs/inference/providerConnection.js +455 -0
  30. package/dist/cjs/inference/request.js +477 -0
  31. package/dist/cjs/inference/routingPolicy.js +318 -0
  32. package/dist/cjs/inference/streamEvents.js +258 -0
  33. package/dist/cjs/inference/usage.js +329 -0
  34. package/dist/cjs/inference/version.js +105 -0
  35. package/dist/cjs/keyRecovery.js +91 -0
  36. package/dist/cjs/keyRotation.js +75 -0
  37. package/dist/cjs/links.js +68 -0
  38. package/dist/cjs/moderationReputation.js +298 -0
  39. package/dist/cjs/oauth.js +66 -0
  40. package/dist/cjs/oxyRecordTypes.js +71 -0
  41. package/dist/cjs/protocol.js +53 -0
  42. package/dist/cjs/recommendations.js +168 -0
  43. package/dist/cjs/reputation.js +297 -0
  44. package/dist/cjs/sessionStatus.js +121 -0
  45. package/dist/cjs/transparency.js +89 -0
  46. package/dist/cjs/updates.js +252 -0
  47. package/dist/cjs/userInvalidation.js +89 -0
  48. package/dist/cjs/userResponse.js +245 -0
  49. package/dist/cjs/username.js +290 -0
  50. package/dist/cjs/webauthn.js +71 -0
  51. package/dist/esm/.tsbuildinfo +1 -0
  52. package/dist/esm/accountGraph.js +480 -0
  53. package/dist/esm/agency.js +436 -0
  54. package/dist/esm/browserHub.js +212 -0
  55. package/dist/esm/civic.js +160 -0
  56. package/dist/esm/commonsSignIn.js +56 -0
  57. package/dist/esm/deviceBoot.js +47 -0
  58. package/dist/esm/deviceDirectory.js +186 -0
  59. package/dist/esm/devicePairing.js +135 -0
  60. package/dist/esm/deviceSession.js +161 -0
  61. package/dist/esm/emailAgentContext.js +29 -0
  62. package/dist/esm/followGraph.js +27 -0
  63. package/dist/esm/identity.js +255 -0
  64. package/dist/esm/inboxPush.js +21 -0
  65. package/dist/esm/index.js +172 -0
  66. package/dist/esm/inference/accountBilling.js +331 -0
  67. package/dist/esm/inference/aliaModelRelease.js +259 -0
  68. package/dist/esm/inference/attribution.js +103 -0
  69. package/dist/esm/inference/catalogue.js +484 -0
  70. package/dist/esm/inference/entitlement.js +214 -0
  71. package/dist/esm/inference/errors.js +306 -0
  72. package/dist/esm/inference/identifiers.js +221 -0
  73. package/dist/esm/inference/inbox.js +102 -0
  74. package/dist/esm/inference/modelDocumentation.js +430 -0
  75. package/dist/esm/inference/money.js +185 -0
  76. package/dist/esm/inference/priceVersion.js +107 -0
  77. package/dist/esm/inference/providerConnection.js +452 -0
  78. package/dist/esm/inference/request.js +474 -0
  79. package/dist/esm/inference/routingPolicy.js +315 -0
  80. package/dist/esm/inference/streamEvents.js +255 -0
  81. package/dist/esm/inference/usage.js +326 -0
  82. package/dist/esm/inference/version.js +102 -0
  83. package/dist/esm/keyRecovery.js +88 -0
  84. package/dist/esm/keyRotation.js +72 -0
  85. package/dist/esm/links.js +65 -0
  86. package/dist/esm/moderationReputation.js +295 -0
  87. package/dist/esm/oauth.js +63 -0
  88. package/dist/esm/oxyRecordTypes.js +68 -0
  89. package/dist/esm/protocol.js +50 -0
  90. package/dist/esm/recommendations.js +165 -0
  91. package/dist/esm/reputation.js +293 -0
  92. package/dist/esm/sessionStatus.js +118 -0
  93. package/dist/esm/transparency.js +86 -0
  94. package/dist/esm/updates.js +249 -0
  95. package/dist/esm/userInvalidation.js +85 -0
  96. package/dist/esm/userResponse.js +240 -0
  97. package/dist/esm/username.js +283 -0
  98. package/dist/esm/webauthn.js +68 -0
  99. package/dist/types/.tsbuildinfo +1 -0
  100. package/dist/types/accountGraph.d.ts +378 -0
  101. package/dist/types/agency.d.ts +2162 -0
  102. package/dist/types/browserHub.d.ts +856 -0
  103. package/dist/types/civic.d.ts +338 -0
  104. package/dist/types/commonsSignIn.d.ts +58 -0
  105. package/dist/types/deviceBoot.d.ts +74 -0
  106. package/dist/types/deviceDirectory.d.ts +1317 -0
  107. package/dist/types/devicePairing.d.ts +130 -0
  108. package/dist/types/deviceSession.d.ts +411 -0
  109. package/dist/types/emailAgentContext.d.ts +248 -0
  110. package/dist/types/followGraph.d.ts +150 -0
  111. package/dist/types/identity.d.ts +402 -0
  112. package/dist/types/inboxPush.d.ts +30 -0
  113. package/dist/types/index.d.ts +100 -0
  114. package/dist/types/inference/accountBilling.d.ts +738 -0
  115. package/dist/types/inference/aliaModelRelease.d.ts +609 -0
  116. package/dist/types/inference/attribution.d.ts +176 -0
  117. package/dist/types/inference/catalogue.d.ts +1618 -0
  118. package/dist/types/inference/entitlement.d.ts +519 -0
  119. package/dist/types/inference/errors.d.ts +242 -0
  120. package/dist/types/inference/identifiers.d.ts +182 -0
  121. package/dist/types/inference/inbox.d.ts +374 -0
  122. package/dist/types/inference/modelDocumentation.d.ts +1603 -0
  123. package/dist/types/inference/money.d.ts +185 -0
  124. package/dist/types/inference/priceVersion.d.ts +182 -0
  125. package/dist/types/inference/providerConnection.d.ts +968 -0
  126. package/dist/types/inference/request.d.ts +2800 -0
  127. package/dist/types/inference/routingPolicy.d.ts +616 -0
  128. package/dist/types/inference/streamEvents.d.ts +950 -0
  129. package/dist/types/inference/usage.d.ts +1164 -0
  130. package/dist/types/inference/version.d.ts +102 -0
  131. package/dist/types/keyRecovery.d.ts +138 -0
  132. package/dist/types/keyRotation.d.ts +103 -0
  133. package/dist/types/links.d.ts +96 -0
  134. package/dist/types/moderationReputation.d.ts +487 -0
  135. package/dist/types/oauth.d.ts +86 -0
  136. package/dist/types/oxyRecordTypes.d.ts +62 -0
  137. package/dist/types/protocol.d.ts +86 -0
  138. package/dist/types/recommendations.d.ts +542 -0
  139. package/dist/types/reputation.d.ts +457 -0
  140. package/dist/types/sessionStatus.d.ts +231 -0
  141. package/dist/types/transparency.d.ts +392 -0
  142. package/dist/types/updates.d.ts +545 -0
  143. package/dist/types/userInvalidation.d.ts +94 -0
  144. package/dist/types/userResponse.d.ts +1706 -0
  145. package/dist/types/username.d.ts +265 -0
  146. package/dist/types/webauthn.d.ts +77 -0
  147. package/package.json +87 -0
@@ -0,0 +1,950 @@
1
+ /**
2
+ * Normalized stream events — what the data plane emits and the Oxy edge
3
+ * forwards as SSE.
4
+ *
5
+ * One discriminated union, seven shapes, all carrying `requestId` and a
6
+ * monotonic `sequence`. `requestId` is on EVERY event rather than only the
7
+ * first because a proxy that re-frames or a client that reconnects would
8
+ * otherwise be holding events it cannot attribute; `sequence` is what makes a
9
+ * redelivered event detectable as a duplicate rather than as new output.
10
+ *
11
+ * The events are versioned INDIVIDUALLY (see `version.ts`): a stream is a long
12
+ * sequence of small messages from a producer that may be redeployed mid-stream,
13
+ * so the alternative — one version for the whole union — would force every
14
+ * event to move whenever any one of them changed.
15
+ *
16
+ * `route_switch` is the customer-visible receipt for an allowed re-route, and
17
+ * its shape carries the invariant: a switch to a DIFFERENT model can only be
18
+ * expressed with `authorizedByPolicy: true`, so an unauthorized substitution is
19
+ * not a thing the contract can say.
20
+ *
21
+ * Decided in: docs/adr/0010-public-api-compatibility.md, docs/adr/0008-catalogue-concept-separation.md.
22
+ */
23
+ import { z } from 'zod';
24
+ /**
25
+ * The first event of every stream: what was actually resolved.
26
+ *
27
+ * Names the revision-pinned model and the serving provider, so a customer who
28
+ * asked for `<publisher>/<model>` learns which revision answered without having
29
+ * to wait for the receipt. Carries no deployment health, no route id and no
30
+ * upstream cost.
31
+ */
32
+ export declare const inferenceStreamStartEventSchema: z.ZodObject<{
33
+ /** See `version.ts`: each stream event is a whole message on the wire. */
34
+ schemaVersion: z.ZodLiteral<1>;
35
+ type: z.ZodLiteral<"start">;
36
+ requestId: z.ZodString;
37
+ sequence: z.ZodNumber;
38
+ generationId: z.ZodOptional<z.ZodString>;
39
+ /** Always revision-pinned, even when the request named only the model. */
40
+ resolvedModelReference: z.ZodString;
41
+ servingProvider: z.ZodString;
42
+ startedAt: z.ZodString;
43
+ }, "strip", z.ZodTypeAny, {
44
+ type: "start";
45
+ schemaVersion: 1;
46
+ requestId: string;
47
+ resolvedModelReference: string;
48
+ servingProvider: string;
49
+ sequence: number;
50
+ startedAt: string;
51
+ generationId?: string | undefined;
52
+ }, {
53
+ type: "start";
54
+ schemaVersion: 1;
55
+ requestId: string;
56
+ resolvedModelReference: string;
57
+ servingProvider: string;
58
+ sequence: number;
59
+ startedAt: string;
60
+ generationId?: string | undefined;
61
+ }>;
62
+ /**
63
+ * A chunk of output.
64
+ *
65
+ * `channel` separates visible output from reasoning and refusals, because a
66
+ * client that renders reasoning as answer text is a product bug, not a display
67
+ * preference.
68
+ */
69
+ export declare const inferenceStreamDeltaEventSchema: z.ZodObject<{
70
+ /** See `version.ts`: each stream event is a whole message on the wire. */
71
+ schemaVersion: z.ZodLiteral<1>;
72
+ type: z.ZodLiteral<"delta">;
73
+ requestId: z.ZodString;
74
+ sequence: z.ZodNumber;
75
+ /** Which output of a multi-output response this chunk belongs to. */
76
+ outputIndex: z.ZodNumber;
77
+ channel: z.ZodEnum<["output_text", "reasoning", "refusal"]>;
78
+ text: z.ZodString;
79
+ }, "strip", z.ZodTypeAny, {
80
+ channel: "reasoning" | "refusal" | "output_text";
81
+ type: "delta";
82
+ schemaVersion: 1;
83
+ requestId: string;
84
+ text: string;
85
+ sequence: number;
86
+ outputIndex: number;
87
+ }, {
88
+ channel: "reasoning" | "refusal" | "output_text";
89
+ type: "delta";
90
+ schemaVersion: 1;
91
+ requestId: string;
92
+ text: string;
93
+ sequence: number;
94
+ outputIndex: number;
95
+ }>;
96
+ /**
97
+ * A tool call being streamed.
98
+ *
99
+ * `argumentsDelta` accumulates; `complete` marks the call finished so a client
100
+ * knows when the accumulated JSON text is worth parsing.
101
+ */
102
+ export declare const inferenceStreamToolCallEventSchema: z.ZodObject<{
103
+ /** See `version.ts`: each stream event is a whole message on the wire. */
104
+ schemaVersion: z.ZodLiteral<1>;
105
+ type: z.ZodLiteral<"tool_call">;
106
+ requestId: z.ZodString;
107
+ sequence: z.ZodNumber;
108
+ toolCallId: z.ZodString;
109
+ /** Present on the first event of a call. */
110
+ name: z.ZodOptional<z.ZodString>;
111
+ argumentsDelta: z.ZodOptional<z.ZodString>;
112
+ complete: z.ZodBoolean;
113
+ }, "strip", z.ZodTypeAny, {
114
+ type: "tool_call";
115
+ schemaVersion: 1;
116
+ requestId: string;
117
+ toolCallId: string;
118
+ sequence: number;
119
+ complete: boolean;
120
+ name?: string | undefined;
121
+ argumentsDelta?: string | undefined;
122
+ }, {
123
+ type: "tool_call";
124
+ schemaVersion: 1;
125
+ requestId: string;
126
+ toolCallId: string;
127
+ sequence: number;
128
+ complete: boolean;
129
+ name?: string | undefined;
130
+ argumentsDelta?: string | undefined;
131
+ }>;
132
+ /**
133
+ * Metered units for the request so far.
134
+ *
135
+ * Units only — no money. What a customer is charged is the ledger's answer,
136
+ * derived from these units and a price version at settlement; a cost quoted by
137
+ * the data plane would be a second, unauthoritative answer to the same
138
+ * question.
139
+ *
140
+ * ## This event is MEASUREMENT EVIDENCE, never a settleable record
141
+ *
142
+ * `normalizedUsageReportSchema` is the only shape a settlement is written from,
143
+ * and this event is deliberately NOT a subset of it that could be widened into
144
+ * one. It carries units and a source; a report additionally carries the
145
+ * attribution block, the outcome, the resolved route, the route-switch count and
146
+ * the two timestamps. Every one of those is knowable only by one END of the
147
+ * request rather than by the frame: the outcome only by the edge, which is the
148
+ * only party that knows whether the CLIENT cancelled, and the route record only
149
+ * by the data plane.
150
+ *
151
+ * So the event is not widened, and that is a decision rather than an omission.
152
+ * Adding the route record and the attribution block here would repeat both on
153
+ * EVERY usage frame of every stream, and each repetition is one more place two
154
+ * frames of one stream could disagree about which route served it — a second
155
+ * source of truth per frame, for fields no consumer of a progress signal reads.
156
+ *
157
+ * **What the edge may do with it, and what it may not.** The units are exact and
158
+ * may be settled; the record around them may not be inferred. When no terminal
159
+ * report arrives — the ordinary case for a client disconnect, since the report
160
+ * frame can no longer be delivered to a connection that is gone — the edge
161
+ * settles the units from the last such event and takes the OUTCOME from itself,
162
+ * never from the event. Its outcome is then `cancelled`, `partial` or `failed`;
163
+ * it is never `completed`, because nothing here can witness that the customer
164
+ * received the whole answer. Zero units marked `estimated` is the arm for no
165
+ * evidence at ALL, not for a disconnect that reported some.
166
+ */
167
+ export declare const inferenceStreamUsageEventSchema: z.ZodObject<{
168
+ /** See `version.ts`: each stream event is a whole message on the wire. */
169
+ schemaVersion: z.ZodLiteral<2>;
170
+ type: z.ZodLiteral<"usage">;
171
+ requestId: z.ZodString;
172
+ sequence: z.ZodNumber;
173
+ /** Exact deployment whose metering produced these partial units. */
174
+ deploymentId: z.ZodString;
175
+ units: z.ZodArray<z.ZodObject<{
176
+ unit: z.ZodEnum<["input_tokens", "cached_input_tokens", "output_tokens", "reasoning_tokens", "requests", "images", "audio_input_milliseconds", "audio_output_milliseconds", "video_milliseconds", "characters", "embeddings"]>;
177
+ quantity: z.ZodNumber;
178
+ }, "strict", z.ZodTypeAny, {
179
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
180
+ quantity: number;
181
+ }, {
182
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
183
+ quantity: number;
184
+ }>, "many">;
185
+ usageSource: z.ZodEnum<["provider_reported", "oxy_measured", "estimated"]>;
186
+ }, "strip", z.ZodTypeAny, {
187
+ type: "usage";
188
+ schemaVersion: 2;
189
+ requestId: string;
190
+ deploymentId: string;
191
+ sequence: number;
192
+ units: {
193
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
194
+ quantity: number;
195
+ }[];
196
+ usageSource: "provider_reported" | "oxy_measured" | "estimated";
197
+ }, {
198
+ type: "usage";
199
+ schemaVersion: 2;
200
+ requestId: string;
201
+ deploymentId: string;
202
+ sequence: number;
203
+ units: {
204
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
205
+ quantity: number;
206
+ }[];
207
+ usageSource: "provider_reported" | "oxy_measured" | "estimated";
208
+ }>;
209
+ /**
210
+ * What kind of re-route happened.
211
+ *
212
+ * `deployment` is same-model failover: the same revision, served somewhere else.
213
+ * `model` is a substitution, and is expressible ONLY with
214
+ * `authorizedByPolicy: true` — the routing policy's `authorizedCrossModel` list
215
+ * is the only thing that can produce one, so "a concrete model was silently
216
+ * replaced" has no representation in this contract.
217
+ */
218
+ export declare const inferenceRouteSwitchDetailSchema: z.ZodDiscriminatedUnion<"scope", [z.ZodObject<{
219
+ scope: z.ZodLiteral<"deployment">;
220
+ modelReference: z.ZodString;
221
+ toProvider: z.ZodString;
222
+ toDeploymentId: z.ZodOptional<z.ZodString>;
223
+ }, "strict", z.ZodTypeAny, {
224
+ scope: "deployment";
225
+ modelReference: string;
226
+ toProvider: string;
227
+ toDeploymentId?: string | undefined;
228
+ }, {
229
+ scope: "deployment";
230
+ modelReference: string;
231
+ toProvider: string;
232
+ toDeploymentId?: string | undefined;
233
+ }>, z.ZodObject<{
234
+ scope: z.ZodLiteral<"model">;
235
+ /**
236
+ * The UNPINNED model line the customer asked for (`<publisher>/<model>`,
237
+ * never `@revision`). A request that pinned a revision asked for exactly
238
+ * those weights and is served or refused, never substituted — so for such
239
+ * a request there is no value that satisfies this field, and the event
240
+ * cannot be constructed at all.
241
+ */
242
+ requestedModelId: z.ZodString;
243
+ fromModelReference: z.ZodString;
244
+ toModelReference: z.ZodString;
245
+ toProvider: z.ZodString;
246
+ /** Literal `true`: an unauthorized cross-model switch cannot be reported. */
247
+ authorizedByPolicy: z.ZodLiteral<true>;
248
+ }, "strict", z.ZodTypeAny, {
249
+ scope: "model";
250
+ authorizedByPolicy: true;
251
+ toProvider: string;
252
+ requestedModelId: string;
253
+ fromModelReference: string;
254
+ toModelReference: string;
255
+ }, {
256
+ scope: "model";
257
+ authorizedByPolicy: true;
258
+ toProvider: string;
259
+ requestedModelId: string;
260
+ fromModelReference: string;
261
+ toModelReference: string;
262
+ }>]>;
263
+ /** Why a route changed mid-request. */
264
+ export declare const inferenceRouteSwitchReasonSchema: z.ZodEnum<["deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "rate_limited", "capacity", "policy_preference"]>;
265
+ /**
266
+ * The customer-visible notice that an allowed route switch occurred.
267
+ *
268
+ * Emitted in-stream rather than only recorded on the receipt, because a
269
+ * customer comparing two answers needs to know that the second one came from
270
+ * somewhere else while they are reading it.
271
+ */
272
+ export declare const inferenceStreamRouteSwitchEventSchema: z.ZodObject<{
273
+ /** See `version.ts`: each stream event is a whole message on the wire. */
274
+ schemaVersion: z.ZodLiteral<1>;
275
+ type: z.ZodLiteral<"route_switch">;
276
+ requestId: z.ZodString;
277
+ sequence: z.ZodNumber;
278
+ reason: z.ZodEnum<["deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "rate_limited", "capacity", "policy_preference"]>;
279
+ detail: z.ZodDiscriminatedUnion<"scope", [z.ZodObject<{
280
+ scope: z.ZodLiteral<"deployment">;
281
+ modelReference: z.ZodString;
282
+ toProvider: z.ZodString;
283
+ toDeploymentId: z.ZodOptional<z.ZodString>;
284
+ }, "strict", z.ZodTypeAny, {
285
+ scope: "deployment";
286
+ modelReference: string;
287
+ toProvider: string;
288
+ toDeploymentId?: string | undefined;
289
+ }, {
290
+ scope: "deployment";
291
+ modelReference: string;
292
+ toProvider: string;
293
+ toDeploymentId?: string | undefined;
294
+ }>, z.ZodObject<{
295
+ scope: z.ZodLiteral<"model">;
296
+ /**
297
+ * The UNPINNED model line the customer asked for (`<publisher>/<model>`,
298
+ * never `@revision`). A request that pinned a revision asked for exactly
299
+ * those weights and is served or refused, never substituted — so for such
300
+ * a request there is no value that satisfies this field, and the event
301
+ * cannot be constructed at all.
302
+ */
303
+ requestedModelId: z.ZodString;
304
+ fromModelReference: z.ZodString;
305
+ toModelReference: z.ZodString;
306
+ toProvider: z.ZodString;
307
+ /** Literal `true`: an unauthorized cross-model switch cannot be reported. */
308
+ authorizedByPolicy: z.ZodLiteral<true>;
309
+ }, "strict", z.ZodTypeAny, {
310
+ scope: "model";
311
+ authorizedByPolicy: true;
312
+ toProvider: string;
313
+ requestedModelId: string;
314
+ fromModelReference: string;
315
+ toModelReference: string;
316
+ }, {
317
+ scope: "model";
318
+ authorizedByPolicy: true;
319
+ toProvider: string;
320
+ requestedModelId: string;
321
+ fromModelReference: string;
322
+ toModelReference: string;
323
+ }>]>;
324
+ occurredAt: z.ZodString;
325
+ }, "strip", z.ZodTypeAny, {
326
+ type: "route_switch";
327
+ reason: "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "capacity" | "policy_preference";
328
+ occurredAt: string;
329
+ schemaVersion: 1;
330
+ requestId: string;
331
+ detail: {
332
+ scope: "deployment";
333
+ modelReference: string;
334
+ toProvider: string;
335
+ toDeploymentId?: string | undefined;
336
+ } | {
337
+ scope: "model";
338
+ authorizedByPolicy: true;
339
+ toProvider: string;
340
+ requestedModelId: string;
341
+ fromModelReference: string;
342
+ toModelReference: string;
343
+ };
344
+ sequence: number;
345
+ }, {
346
+ type: "route_switch";
347
+ reason: "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "capacity" | "policy_preference";
348
+ occurredAt: string;
349
+ schemaVersion: 1;
350
+ requestId: string;
351
+ detail: {
352
+ scope: "deployment";
353
+ modelReference: string;
354
+ toProvider: string;
355
+ toDeploymentId?: string | undefined;
356
+ } | {
357
+ scope: "model";
358
+ authorizedByPolicy: true;
359
+ toProvider: string;
360
+ requestedModelId: string;
361
+ fromModelReference: string;
362
+ toModelReference: string;
363
+ };
364
+ sequence: number;
365
+ }>;
366
+ /**
367
+ * A terminal error. The stream ends here; no `done` follows, so a client that
368
+ * saw an error never also has to reconcile a success.
369
+ */
370
+ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
371
+ /** See `version.ts`: each stream event is a whole message on the wire. */
372
+ schemaVersion: z.ZodLiteral<1>;
373
+ type: z.ZodLiteral<"error">;
374
+ requestId: z.ZodString;
375
+ sequence: z.ZodNumber;
376
+ /** Carries its own `schemaVersion`: the same body is returned non-streaming. */
377
+ error: z.ZodEffects<z.ZodObject<{
378
+ schemaVersion: z.ZodLiteral<1>;
379
+ code: z.ZodEnum<["invalid_request", "authentication_failed", "permission_denied", "insufficient_scope", "model_not_found", "unsupported_modality", "context_length_exceeded", "request_too_large", "output_limit_exceeded", "idempotency_conflict", "insufficient_balance", "spending_limit_exceeded", "quota_exceeded", "byok_credential_invalid", "policy_violation", "commercial_permission_denied", "no_route_available", "upstream_content_filtered", "cancelled", "rate_limited", "deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "provider_credential_invalid", "provider_billing_refused", "service_unavailable", "internal_error"]>;
380
+ message: z.ZodEffects<z.ZodString, string, string>;
381
+ retryable: z.ZodBoolean;
382
+ requestId: z.ZodString;
383
+ retryAfterMs: z.ZodOptional<z.ZodNumber>;
384
+ param: z.ZodOptional<z.ZodString>;
385
+ upstreamCategory: z.ZodOptional<z.ZodEnum<["rate_limit", "quota", "timeout", "overloaded", "server_error", "content_filter", "invalid_request", "authentication", "unknown"]>>;
386
+ providerError: z.ZodOptional<z.ZodObject<{
387
+ provider: z.ZodString;
388
+ status: z.ZodOptional<z.ZodNumber>;
389
+ code: z.ZodOptional<z.ZodString>;
390
+ message: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
391
+ }, "strict", z.ZodTypeAny, {
392
+ provider: string;
393
+ code?: string | undefined;
394
+ message?: string | undefined;
395
+ status?: number | undefined;
396
+ }, {
397
+ provider: string;
398
+ code?: string | undefined;
399
+ message?: string | undefined;
400
+ status?: number | undefined;
401
+ }>>;
402
+ }, "strip", z.ZodTypeAny, {
403
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
404
+ message: string;
405
+ schemaVersion: 1;
406
+ requestId: string;
407
+ retryable: boolean;
408
+ retryAfterMs?: number | undefined;
409
+ param?: string | undefined;
410
+ upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
411
+ providerError?: {
412
+ provider: string;
413
+ code?: string | undefined;
414
+ message?: string | undefined;
415
+ status?: number | undefined;
416
+ } | undefined;
417
+ }, {
418
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
419
+ message: string;
420
+ schemaVersion: 1;
421
+ requestId: string;
422
+ retryable: boolean;
423
+ retryAfterMs?: number | undefined;
424
+ param?: string | undefined;
425
+ upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
426
+ providerError?: {
427
+ provider: string;
428
+ code?: string | undefined;
429
+ message?: string | undefined;
430
+ status?: number | undefined;
431
+ } | undefined;
432
+ }>, {
433
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
434
+ message: string;
435
+ schemaVersion: 1;
436
+ requestId: string;
437
+ retryable: boolean;
438
+ retryAfterMs?: number | undefined;
439
+ param?: string | undefined;
440
+ upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
441
+ providerError?: {
442
+ provider: string;
443
+ code?: string | undefined;
444
+ message?: string | undefined;
445
+ status?: number | undefined;
446
+ } | undefined;
447
+ }, {
448
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
449
+ message: string;
450
+ schemaVersion: 1;
451
+ requestId: string;
452
+ retryable: boolean;
453
+ retryAfterMs?: number | undefined;
454
+ param?: string | undefined;
455
+ upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
456
+ providerError?: {
457
+ provider: string;
458
+ code?: string | undefined;
459
+ message?: string | undefined;
460
+ status?: number | undefined;
461
+ } | undefined;
462
+ }>;
463
+ }, "strip", z.ZodTypeAny, {
464
+ type: "error";
465
+ schemaVersion: 1;
466
+ requestId: string;
467
+ sequence: number;
468
+ error: {
469
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
470
+ message: string;
471
+ schemaVersion: 1;
472
+ requestId: string;
473
+ retryable: boolean;
474
+ retryAfterMs?: number | undefined;
475
+ param?: string | undefined;
476
+ upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
477
+ providerError?: {
478
+ provider: string;
479
+ code?: string | undefined;
480
+ message?: string | undefined;
481
+ status?: number | undefined;
482
+ } | undefined;
483
+ };
484
+ }, {
485
+ type: "error";
486
+ schemaVersion: 1;
487
+ requestId: string;
488
+ sequence: number;
489
+ error: {
490
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
491
+ message: string;
492
+ schemaVersion: 1;
493
+ requestId: string;
494
+ retryable: boolean;
495
+ retryAfterMs?: number | undefined;
496
+ param?: string | undefined;
497
+ upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
498
+ providerError?: {
499
+ provider: string;
500
+ code?: string | undefined;
501
+ message?: string | undefined;
502
+ status?: number | undefined;
503
+ } | undefined;
504
+ };
505
+ }>;
506
+ /**
507
+ * Why generation stopped.
508
+ *
509
+ * `refusal` and `content_filter` are separate members because they are separate
510
+ * events: the MODEL declining to answer is a property of the answer, while a
511
+ * filter is an upstream system removing one. The delta channels already carry
512
+ * that distinction (`channel: 'refusal'` beside the filter's own error code),
513
+ * so collapsing it here would have made the terminal event less specific than
514
+ * the stream that produced it.
515
+ */
516
+ export declare const inferenceFinishReasonSchema: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "refusal", "cancelled"]>;
517
+ /**
518
+ * The successful terminal event.
519
+ *
520
+ * `receiptId` is present once settlement has produced one, giving a customer a
521
+ * direct handle on the exact amount charged rather than a telemetry estimate.
522
+ */
523
+ export declare const inferenceStreamDoneEventSchema: z.ZodObject<{
524
+ /** See `version.ts`: each stream event is a whole message on the wire. */
525
+ schemaVersion: z.ZodLiteral<1>;
526
+ type: z.ZodLiteral<"done">;
527
+ requestId: z.ZodString;
528
+ sequence: z.ZodNumber;
529
+ generationId: z.ZodOptional<z.ZodString>;
530
+ finishReason: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "refusal", "cancelled"]>;
531
+ receiptId: z.ZodOptional<z.ZodString>;
532
+ completedAt: z.ZodString;
533
+ }, "strip", z.ZodTypeAny, {
534
+ type: "done";
535
+ schemaVersion: 1;
536
+ requestId: string;
537
+ completedAt: string;
538
+ sequence: number;
539
+ finishReason: "length" | "cancelled" | "content_filter" | "refusal" | "stop" | "tool_calls";
540
+ receiptId?: string | undefined;
541
+ generationId?: string | undefined;
542
+ }, {
543
+ type: "done";
544
+ schemaVersion: 1;
545
+ requestId: string;
546
+ completedAt: string;
547
+ sequence: number;
548
+ finishReason: "length" | "cancelled" | "content_filter" | "refusal" | "stop" | "tool_calls";
549
+ receiptId?: string | undefined;
550
+ generationId?: string | undefined;
551
+ }>;
552
+ /**
553
+ * Every event a normalized stream can carry.
554
+ *
555
+ * Discriminated on `type`, so a consumer that meets an unknown event fails at
556
+ * the parse instead of falling into a default branch that treats it as output.
557
+ */
558
+ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
559
+ /** See `version.ts`: each stream event is a whole message on the wire. */
560
+ schemaVersion: z.ZodLiteral<1>;
561
+ type: z.ZodLiteral<"start">;
562
+ requestId: z.ZodString;
563
+ sequence: z.ZodNumber;
564
+ generationId: z.ZodOptional<z.ZodString>;
565
+ /** Always revision-pinned, even when the request named only the model. */
566
+ resolvedModelReference: z.ZodString;
567
+ servingProvider: z.ZodString;
568
+ startedAt: z.ZodString;
569
+ }, "strip", z.ZodTypeAny, {
570
+ type: "start";
571
+ schemaVersion: 1;
572
+ requestId: string;
573
+ resolvedModelReference: string;
574
+ servingProvider: string;
575
+ sequence: number;
576
+ startedAt: string;
577
+ generationId?: string | undefined;
578
+ }, {
579
+ type: "start";
580
+ schemaVersion: 1;
581
+ requestId: string;
582
+ resolvedModelReference: string;
583
+ servingProvider: string;
584
+ sequence: number;
585
+ startedAt: string;
586
+ generationId?: string | undefined;
587
+ }>, z.ZodObject<{
588
+ /** See `version.ts`: each stream event is a whole message on the wire. */
589
+ schemaVersion: z.ZodLiteral<1>;
590
+ type: z.ZodLiteral<"delta">;
591
+ requestId: z.ZodString;
592
+ sequence: z.ZodNumber;
593
+ /** Which output of a multi-output response this chunk belongs to. */
594
+ outputIndex: z.ZodNumber;
595
+ channel: z.ZodEnum<["output_text", "reasoning", "refusal"]>;
596
+ text: z.ZodString;
597
+ }, "strip", z.ZodTypeAny, {
598
+ channel: "reasoning" | "refusal" | "output_text";
599
+ type: "delta";
600
+ schemaVersion: 1;
601
+ requestId: string;
602
+ text: string;
603
+ sequence: number;
604
+ outputIndex: number;
605
+ }, {
606
+ channel: "reasoning" | "refusal" | "output_text";
607
+ type: "delta";
608
+ schemaVersion: 1;
609
+ requestId: string;
610
+ text: string;
611
+ sequence: number;
612
+ outputIndex: number;
613
+ }>, z.ZodObject<{
614
+ /** See `version.ts`: each stream event is a whole message on the wire. */
615
+ schemaVersion: z.ZodLiteral<1>;
616
+ type: z.ZodLiteral<"tool_call">;
617
+ requestId: z.ZodString;
618
+ sequence: z.ZodNumber;
619
+ toolCallId: z.ZodString;
620
+ /** Present on the first event of a call. */
621
+ name: z.ZodOptional<z.ZodString>;
622
+ argumentsDelta: z.ZodOptional<z.ZodString>;
623
+ complete: z.ZodBoolean;
624
+ }, "strip", z.ZodTypeAny, {
625
+ type: "tool_call";
626
+ schemaVersion: 1;
627
+ requestId: string;
628
+ toolCallId: string;
629
+ sequence: number;
630
+ complete: boolean;
631
+ name?: string | undefined;
632
+ argumentsDelta?: string | undefined;
633
+ }, {
634
+ type: "tool_call";
635
+ schemaVersion: 1;
636
+ requestId: string;
637
+ toolCallId: string;
638
+ sequence: number;
639
+ complete: boolean;
640
+ name?: string | undefined;
641
+ argumentsDelta?: string | undefined;
642
+ }>, z.ZodObject<{
643
+ /** See `version.ts`: each stream event is a whole message on the wire. */
644
+ schemaVersion: z.ZodLiteral<2>;
645
+ type: z.ZodLiteral<"usage">;
646
+ requestId: z.ZodString;
647
+ sequence: z.ZodNumber;
648
+ /** Exact deployment whose metering produced these partial units. */
649
+ deploymentId: z.ZodString;
650
+ units: z.ZodArray<z.ZodObject<{
651
+ unit: z.ZodEnum<["input_tokens", "cached_input_tokens", "output_tokens", "reasoning_tokens", "requests", "images", "audio_input_milliseconds", "audio_output_milliseconds", "video_milliseconds", "characters", "embeddings"]>;
652
+ quantity: z.ZodNumber;
653
+ }, "strict", z.ZodTypeAny, {
654
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
655
+ quantity: number;
656
+ }, {
657
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
658
+ quantity: number;
659
+ }>, "many">;
660
+ usageSource: z.ZodEnum<["provider_reported", "oxy_measured", "estimated"]>;
661
+ }, "strip", z.ZodTypeAny, {
662
+ type: "usage";
663
+ schemaVersion: 2;
664
+ requestId: string;
665
+ deploymentId: string;
666
+ sequence: number;
667
+ units: {
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
+ usageSource: "provider_reported" | "oxy_measured" | "estimated";
672
+ }, {
673
+ type: "usage";
674
+ schemaVersion: 2;
675
+ requestId: string;
676
+ deploymentId: string;
677
+ sequence: number;
678
+ units: {
679
+ unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
680
+ quantity: number;
681
+ }[];
682
+ usageSource: "provider_reported" | "oxy_measured" | "estimated";
683
+ }>, z.ZodObject<{
684
+ /** See `version.ts`: each stream event is a whole message on the wire. */
685
+ schemaVersion: z.ZodLiteral<1>;
686
+ type: z.ZodLiteral<"route_switch">;
687
+ requestId: z.ZodString;
688
+ sequence: z.ZodNumber;
689
+ reason: z.ZodEnum<["deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "rate_limited", "capacity", "policy_preference"]>;
690
+ detail: z.ZodDiscriminatedUnion<"scope", [z.ZodObject<{
691
+ scope: z.ZodLiteral<"deployment">;
692
+ modelReference: z.ZodString;
693
+ toProvider: z.ZodString;
694
+ toDeploymentId: z.ZodOptional<z.ZodString>;
695
+ }, "strict", z.ZodTypeAny, {
696
+ scope: "deployment";
697
+ modelReference: string;
698
+ toProvider: string;
699
+ toDeploymentId?: string | undefined;
700
+ }, {
701
+ scope: "deployment";
702
+ modelReference: string;
703
+ toProvider: string;
704
+ toDeploymentId?: string | undefined;
705
+ }>, z.ZodObject<{
706
+ scope: z.ZodLiteral<"model">;
707
+ /**
708
+ * The UNPINNED model line the customer asked for (`<publisher>/<model>`,
709
+ * never `@revision`). A request that pinned a revision asked for exactly
710
+ * those weights and is served or refused, never substituted — so for such
711
+ * a request there is no value that satisfies this field, and the event
712
+ * cannot be constructed at all.
713
+ */
714
+ requestedModelId: z.ZodString;
715
+ fromModelReference: z.ZodString;
716
+ toModelReference: z.ZodString;
717
+ toProvider: z.ZodString;
718
+ /** Literal `true`: an unauthorized cross-model switch cannot be reported. */
719
+ authorizedByPolicy: z.ZodLiteral<true>;
720
+ }, "strict", z.ZodTypeAny, {
721
+ scope: "model";
722
+ authorizedByPolicy: true;
723
+ toProvider: string;
724
+ requestedModelId: string;
725
+ fromModelReference: string;
726
+ toModelReference: string;
727
+ }, {
728
+ scope: "model";
729
+ authorizedByPolicy: true;
730
+ toProvider: string;
731
+ requestedModelId: string;
732
+ fromModelReference: string;
733
+ toModelReference: string;
734
+ }>]>;
735
+ occurredAt: z.ZodString;
736
+ }, "strip", z.ZodTypeAny, {
737
+ type: "route_switch";
738
+ reason: "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "capacity" | "policy_preference";
739
+ occurredAt: string;
740
+ schemaVersion: 1;
741
+ requestId: string;
742
+ detail: {
743
+ scope: "deployment";
744
+ modelReference: string;
745
+ toProvider: string;
746
+ toDeploymentId?: string | undefined;
747
+ } | {
748
+ scope: "model";
749
+ authorizedByPolicy: true;
750
+ toProvider: string;
751
+ requestedModelId: string;
752
+ fromModelReference: string;
753
+ toModelReference: string;
754
+ };
755
+ sequence: number;
756
+ }, {
757
+ type: "route_switch";
758
+ reason: "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "capacity" | "policy_preference";
759
+ occurredAt: string;
760
+ schemaVersion: 1;
761
+ requestId: string;
762
+ detail: {
763
+ scope: "deployment";
764
+ modelReference: string;
765
+ toProvider: string;
766
+ toDeploymentId?: string | undefined;
767
+ } | {
768
+ scope: "model";
769
+ authorizedByPolicy: true;
770
+ toProvider: string;
771
+ requestedModelId: string;
772
+ fromModelReference: string;
773
+ toModelReference: string;
774
+ };
775
+ sequence: number;
776
+ }>, z.ZodObject<{
777
+ /** See `version.ts`: each stream event is a whole message on the wire. */
778
+ schemaVersion: z.ZodLiteral<1>;
779
+ type: z.ZodLiteral<"error">;
780
+ requestId: z.ZodString;
781
+ sequence: z.ZodNumber;
782
+ /** Carries its own `schemaVersion`: the same body is returned non-streaming. */
783
+ error: z.ZodEffects<z.ZodObject<{
784
+ schemaVersion: z.ZodLiteral<1>;
785
+ code: z.ZodEnum<["invalid_request", "authentication_failed", "permission_denied", "insufficient_scope", "model_not_found", "unsupported_modality", "context_length_exceeded", "request_too_large", "output_limit_exceeded", "idempotency_conflict", "insufficient_balance", "spending_limit_exceeded", "quota_exceeded", "byok_credential_invalid", "policy_violation", "commercial_permission_denied", "no_route_available", "upstream_content_filtered", "cancelled", "rate_limited", "deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "provider_credential_invalid", "provider_billing_refused", "service_unavailable", "internal_error"]>;
786
+ message: z.ZodEffects<z.ZodString, string, string>;
787
+ retryable: z.ZodBoolean;
788
+ requestId: z.ZodString;
789
+ retryAfterMs: z.ZodOptional<z.ZodNumber>;
790
+ param: z.ZodOptional<z.ZodString>;
791
+ upstreamCategory: z.ZodOptional<z.ZodEnum<["rate_limit", "quota", "timeout", "overloaded", "server_error", "content_filter", "invalid_request", "authentication", "unknown"]>>;
792
+ providerError: z.ZodOptional<z.ZodObject<{
793
+ provider: z.ZodString;
794
+ status: z.ZodOptional<z.ZodNumber>;
795
+ code: z.ZodOptional<z.ZodString>;
796
+ message: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
797
+ }, "strict", z.ZodTypeAny, {
798
+ provider: string;
799
+ code?: string | undefined;
800
+ message?: string | undefined;
801
+ status?: number | undefined;
802
+ }, {
803
+ provider: string;
804
+ code?: string | undefined;
805
+ message?: string | undefined;
806
+ status?: number | undefined;
807
+ }>>;
808
+ }, "strip", z.ZodTypeAny, {
809
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
810
+ message: string;
811
+ schemaVersion: 1;
812
+ requestId: string;
813
+ retryable: boolean;
814
+ retryAfterMs?: number | undefined;
815
+ param?: string | undefined;
816
+ upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
817
+ providerError?: {
818
+ provider: string;
819
+ code?: string | undefined;
820
+ message?: string | undefined;
821
+ status?: number | undefined;
822
+ } | undefined;
823
+ }, {
824
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
825
+ message: string;
826
+ schemaVersion: 1;
827
+ requestId: string;
828
+ retryable: boolean;
829
+ retryAfterMs?: number | undefined;
830
+ param?: string | undefined;
831
+ upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
832
+ providerError?: {
833
+ provider: string;
834
+ code?: string | undefined;
835
+ message?: string | undefined;
836
+ status?: number | undefined;
837
+ } | undefined;
838
+ }>, {
839
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
840
+ message: string;
841
+ schemaVersion: 1;
842
+ requestId: string;
843
+ retryable: boolean;
844
+ retryAfterMs?: number | undefined;
845
+ param?: string | undefined;
846
+ upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
847
+ providerError?: {
848
+ provider: string;
849
+ code?: string | undefined;
850
+ message?: string | undefined;
851
+ status?: number | undefined;
852
+ } | undefined;
853
+ }, {
854
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
855
+ message: string;
856
+ schemaVersion: 1;
857
+ requestId: string;
858
+ retryable: boolean;
859
+ retryAfterMs?: number | undefined;
860
+ param?: string | undefined;
861
+ upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
862
+ providerError?: {
863
+ provider: string;
864
+ code?: string | undefined;
865
+ message?: string | undefined;
866
+ status?: number | undefined;
867
+ } | undefined;
868
+ }>;
869
+ }, "strip", z.ZodTypeAny, {
870
+ type: "error";
871
+ schemaVersion: 1;
872
+ requestId: string;
873
+ sequence: number;
874
+ error: {
875
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
876
+ message: string;
877
+ schemaVersion: 1;
878
+ requestId: string;
879
+ retryable: boolean;
880
+ retryAfterMs?: number | undefined;
881
+ param?: string | undefined;
882
+ upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
883
+ providerError?: {
884
+ provider: string;
885
+ code?: string | undefined;
886
+ message?: string | undefined;
887
+ status?: number | undefined;
888
+ } | undefined;
889
+ };
890
+ }, {
891
+ type: "error";
892
+ schemaVersion: 1;
893
+ requestId: string;
894
+ sequence: number;
895
+ error: {
896
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
897
+ message: string;
898
+ schemaVersion: 1;
899
+ requestId: string;
900
+ retryable: boolean;
901
+ retryAfterMs?: number | undefined;
902
+ param?: string | undefined;
903
+ upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
904
+ providerError?: {
905
+ provider: string;
906
+ code?: string | undefined;
907
+ message?: string | undefined;
908
+ status?: number | undefined;
909
+ } | undefined;
910
+ };
911
+ }>, z.ZodObject<{
912
+ /** See `version.ts`: each stream event is a whole message on the wire. */
913
+ schemaVersion: z.ZodLiteral<1>;
914
+ type: z.ZodLiteral<"done">;
915
+ requestId: z.ZodString;
916
+ sequence: z.ZodNumber;
917
+ generationId: z.ZodOptional<z.ZodString>;
918
+ finishReason: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "refusal", "cancelled"]>;
919
+ receiptId: z.ZodOptional<z.ZodString>;
920
+ completedAt: z.ZodString;
921
+ }, "strip", z.ZodTypeAny, {
922
+ type: "done";
923
+ schemaVersion: 1;
924
+ requestId: string;
925
+ completedAt: string;
926
+ sequence: number;
927
+ finishReason: "length" | "cancelled" | "content_filter" | "refusal" | "stop" | "tool_calls";
928
+ receiptId?: string | undefined;
929
+ generationId?: string | undefined;
930
+ }, {
931
+ type: "done";
932
+ schemaVersion: 1;
933
+ requestId: string;
934
+ completedAt: string;
935
+ sequence: number;
936
+ finishReason: "length" | "cancelled" | "content_filter" | "refusal" | "stop" | "tool_calls";
937
+ receiptId?: string | undefined;
938
+ generationId?: string | undefined;
939
+ }>]>;
940
+ export type InferenceStreamStartEvent = z.infer<typeof inferenceStreamStartEventSchema>;
941
+ export type InferenceStreamDeltaEvent = z.infer<typeof inferenceStreamDeltaEventSchema>;
942
+ export type InferenceStreamToolCallEvent = z.infer<typeof inferenceStreamToolCallEventSchema>;
943
+ export type InferenceStreamUsageEvent = z.infer<typeof inferenceStreamUsageEventSchema>;
944
+ export type InferenceRouteSwitchDetail = z.infer<typeof inferenceRouteSwitchDetailSchema>;
945
+ export type InferenceRouteSwitchReason = z.infer<typeof inferenceRouteSwitchReasonSchema>;
946
+ export type InferenceStreamRouteSwitchEvent = z.infer<typeof inferenceStreamRouteSwitchEventSchema>;
947
+ export type InferenceStreamErrorEvent = z.infer<typeof inferenceStreamErrorEventSchema>;
948
+ export type InferenceFinishReason = z.infer<typeof inferenceFinishReasonSchema>;
949
+ export type InferenceStreamDoneEvent = z.infer<typeof inferenceStreamDoneEventSchema>;
950
+ export type InferenceStreamEvent = z.infer<typeof inferenceStreamEventSchema>;