@oxyhq/contracts 0.26.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/accountGraph.js +4 -3
- package/dist/cjs/index.js +186 -1
- package/dist/cjs/inference/accountBilling.js +334 -0
- package/dist/cjs/inference/attribution.js +106 -0
- package/dist/cjs/inference/catalogue.js +482 -0
- package/dist/cjs/inference/entitlement.js +217 -0
- package/dist/cjs/inference/errors.js +210 -0
- package/dist/cjs/inference/identifiers.js +197 -0
- package/dist/cjs/inference/money.js +188 -0
- package/dist/cjs/inference/priceVersion.js +110 -0
- package/dist/cjs/inference/providerConnection.js +142 -0
- package/dist/cjs/inference/request.js +288 -0
- package/dist/cjs/inference/routingPolicy.js +213 -0
- package/dist/cjs/inference/streamEvents.js +219 -0
- package/dist/cjs/inference/usage.js +297 -0
- package/dist/cjs/inference/version.js +85 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/accountGraph.js +4 -3
- package/dist/esm/index.js +54 -0
- package/dist/esm/inference/accountBilling.js +331 -0
- package/dist/esm/inference/attribution.js +103 -0
- package/dist/esm/inference/catalogue.js +479 -0
- package/dist/esm/inference/entitlement.js +214 -0
- package/dist/esm/inference/errors.js +207 -0
- package/dist/esm/inference/identifiers.js +194 -0
- package/dist/esm/inference/money.js +185 -0
- package/dist/esm/inference/priceVersion.js +107 -0
- package/dist/esm/inference/providerConnection.js +139 -0
- package/dist/esm/inference/request.js +285 -0
- package/dist/esm/inference/routingPolicy.js +210 -0
- package/dist/esm/inference/streamEvents.js +216 -0
- package/dist/esm/inference/usage.js +294 -0
- package/dist/esm/inference/version.js +82 -0
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/accountGraph.d.ts +6 -5
- package/dist/types/index.d.ts +27 -0
- package/dist/types/inference/accountBilling.d.ts +738 -0
- package/dist/types/inference/attribution.d.ts +176 -0
- package/dist/types/inference/catalogue.d.ts +1612 -0
- package/dist/types/inference/entitlement.d.ts +519 -0
- package/dist/types/inference/errors.d.ts +206 -0
- package/dist/types/inference/identifiers.d.ts +157 -0
- package/dist/types/inference/money.d.ts +185 -0
- package/dist/types/inference/priceVersion.d.ts +182 -0
- package/dist/types/inference/providerConnection.d.ts +297 -0
- package/dist/types/inference/request.d.ts +2364 -0
- package/dist/types/inference/routingPolicy.d.ts +426 -0
- package/dist/types/inference/streamEvents.d.ts +906 -0
- package/dist/types/inference/usage.d.ts +1139 -0
- package/dist/types/inference/version.d.ts +82 -0
- package/package.json +1 -1
|
@@ -0,0 +1,906 @@
|
|
|
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
|
+
requestId: string;
|
|
46
|
+
schemaVersion: 1;
|
|
47
|
+
sequence: number;
|
|
48
|
+
resolvedModelReference: string;
|
|
49
|
+
servingProvider: string;
|
|
50
|
+
startedAt: string;
|
|
51
|
+
generationId?: string | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
type: "start";
|
|
54
|
+
requestId: string;
|
|
55
|
+
schemaVersion: 1;
|
|
56
|
+
sequence: number;
|
|
57
|
+
resolvedModelReference: string;
|
|
58
|
+
servingProvider: string;
|
|
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" | "output_text" | "refusal";
|
|
81
|
+
type: "delta";
|
|
82
|
+
requestId: string;
|
|
83
|
+
schemaVersion: 1;
|
|
84
|
+
text: string;
|
|
85
|
+
sequence: number;
|
|
86
|
+
outputIndex: number;
|
|
87
|
+
}, {
|
|
88
|
+
channel: "reasoning" | "output_text" | "refusal";
|
|
89
|
+
type: "delta";
|
|
90
|
+
requestId: string;
|
|
91
|
+
schemaVersion: 1;
|
|
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
|
+
requestId: string;
|
|
116
|
+
schemaVersion: 1;
|
|
117
|
+
toolCallId: string;
|
|
118
|
+
sequence: number;
|
|
119
|
+
complete: boolean;
|
|
120
|
+
name?: string | undefined;
|
|
121
|
+
argumentsDelta?: string | undefined;
|
|
122
|
+
}, {
|
|
123
|
+
type: "tool_call";
|
|
124
|
+
requestId: string;
|
|
125
|
+
schemaVersion: 1;
|
|
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
|
+
export declare const inferenceStreamUsageEventSchema: z.ZodObject<{
|
|
141
|
+
/** See `version.ts`: each stream event is a whole message on the wire. */
|
|
142
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
143
|
+
type: z.ZodLiteral<"usage">;
|
|
144
|
+
requestId: z.ZodString;
|
|
145
|
+
sequence: z.ZodNumber;
|
|
146
|
+
units: z.ZodArray<z.ZodObject<{
|
|
147
|
+
unit: z.ZodEnum<["input_tokens", "cached_input_tokens", "output_tokens", "reasoning_tokens", "requests", "images", "audio_input_milliseconds", "audio_output_milliseconds", "video_milliseconds", "characters", "embeddings"]>;
|
|
148
|
+
quantity: z.ZodNumber;
|
|
149
|
+
}, "strict", z.ZodTypeAny, {
|
|
150
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
151
|
+
quantity: number;
|
|
152
|
+
}, {
|
|
153
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
154
|
+
quantity: number;
|
|
155
|
+
}>, "many">;
|
|
156
|
+
usageSource: z.ZodEnum<["provider_reported", "oxy_measured", "estimated"]>;
|
|
157
|
+
}, "strip", z.ZodTypeAny, {
|
|
158
|
+
type: "usage";
|
|
159
|
+
requestId: string;
|
|
160
|
+
schemaVersion: 1;
|
|
161
|
+
sequence: number;
|
|
162
|
+
units: {
|
|
163
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
164
|
+
quantity: number;
|
|
165
|
+
}[];
|
|
166
|
+
usageSource: "provider_reported" | "oxy_measured" | "estimated";
|
|
167
|
+
}, {
|
|
168
|
+
type: "usage";
|
|
169
|
+
requestId: string;
|
|
170
|
+
schemaVersion: 1;
|
|
171
|
+
sequence: number;
|
|
172
|
+
units: {
|
|
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
|
+
}[];
|
|
176
|
+
usageSource: "provider_reported" | "oxy_measured" | "estimated";
|
|
177
|
+
}>;
|
|
178
|
+
/**
|
|
179
|
+
* What kind of re-route happened.
|
|
180
|
+
*
|
|
181
|
+
* `deployment` is same-model failover: the same revision, served somewhere else.
|
|
182
|
+
* `model` is a substitution, and is expressible ONLY with
|
|
183
|
+
* `authorizedByPolicy: true` — the routing policy's `authorizedCrossModel` list
|
|
184
|
+
* is the only thing that can produce one, so "a concrete model was silently
|
|
185
|
+
* replaced" has no representation in this contract.
|
|
186
|
+
*/
|
|
187
|
+
export declare const inferenceRouteSwitchDetailSchema: z.ZodDiscriminatedUnion<"scope", [z.ZodObject<{
|
|
188
|
+
scope: z.ZodLiteral<"deployment">;
|
|
189
|
+
modelReference: z.ZodString;
|
|
190
|
+
toProvider: z.ZodString;
|
|
191
|
+
toDeploymentId: z.ZodOptional<z.ZodString>;
|
|
192
|
+
}, "strict", z.ZodTypeAny, {
|
|
193
|
+
scope: "deployment";
|
|
194
|
+
modelReference: string;
|
|
195
|
+
toProvider: string;
|
|
196
|
+
toDeploymentId?: string | undefined;
|
|
197
|
+
}, {
|
|
198
|
+
scope: "deployment";
|
|
199
|
+
modelReference: string;
|
|
200
|
+
toProvider: string;
|
|
201
|
+
toDeploymentId?: string | undefined;
|
|
202
|
+
}>, z.ZodObject<{
|
|
203
|
+
scope: z.ZodLiteral<"model">;
|
|
204
|
+
/**
|
|
205
|
+
* The UNPINNED model line the customer asked for (`<publisher>/<model>`,
|
|
206
|
+
* never `@revision`). A request that pinned a revision asked for exactly
|
|
207
|
+
* those weights and is served or refused, never substituted — so for such
|
|
208
|
+
* a request there is no value that satisfies this field, and the event
|
|
209
|
+
* cannot be constructed at all.
|
|
210
|
+
*/
|
|
211
|
+
requestedModelId: z.ZodString;
|
|
212
|
+
fromModelReference: z.ZodString;
|
|
213
|
+
toModelReference: z.ZodString;
|
|
214
|
+
toProvider: z.ZodString;
|
|
215
|
+
/** Literal `true`: an unauthorized cross-model switch cannot be reported. */
|
|
216
|
+
authorizedByPolicy: z.ZodLiteral<true>;
|
|
217
|
+
}, "strict", z.ZodTypeAny, {
|
|
218
|
+
scope: "model";
|
|
219
|
+
toProvider: string;
|
|
220
|
+
requestedModelId: string;
|
|
221
|
+
fromModelReference: string;
|
|
222
|
+
toModelReference: string;
|
|
223
|
+
authorizedByPolicy: true;
|
|
224
|
+
}, {
|
|
225
|
+
scope: "model";
|
|
226
|
+
toProvider: string;
|
|
227
|
+
requestedModelId: string;
|
|
228
|
+
fromModelReference: string;
|
|
229
|
+
toModelReference: string;
|
|
230
|
+
authorizedByPolicy: true;
|
|
231
|
+
}>]>;
|
|
232
|
+
/** Why a route changed mid-request. */
|
|
233
|
+
export declare const inferenceRouteSwitchReasonSchema: z.ZodEnum<["deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "rate_limited", "capacity", "policy_preference"]>;
|
|
234
|
+
/**
|
|
235
|
+
* The customer-visible notice that an allowed route switch occurred.
|
|
236
|
+
*
|
|
237
|
+
* Emitted in-stream rather than only recorded on the receipt, because a
|
|
238
|
+
* customer comparing two answers needs to know that the second one came from
|
|
239
|
+
* somewhere else while they are reading it.
|
|
240
|
+
*/
|
|
241
|
+
export declare const inferenceStreamRouteSwitchEventSchema: z.ZodObject<{
|
|
242
|
+
/** See `version.ts`: each stream event is a whole message on the wire. */
|
|
243
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
244
|
+
type: z.ZodLiteral<"route_switch">;
|
|
245
|
+
requestId: z.ZodString;
|
|
246
|
+
sequence: z.ZodNumber;
|
|
247
|
+
reason: z.ZodEnum<["deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "rate_limited", "capacity", "policy_preference"]>;
|
|
248
|
+
detail: z.ZodDiscriminatedUnion<"scope", [z.ZodObject<{
|
|
249
|
+
scope: z.ZodLiteral<"deployment">;
|
|
250
|
+
modelReference: z.ZodString;
|
|
251
|
+
toProvider: z.ZodString;
|
|
252
|
+
toDeploymentId: z.ZodOptional<z.ZodString>;
|
|
253
|
+
}, "strict", z.ZodTypeAny, {
|
|
254
|
+
scope: "deployment";
|
|
255
|
+
modelReference: string;
|
|
256
|
+
toProvider: string;
|
|
257
|
+
toDeploymentId?: string | undefined;
|
|
258
|
+
}, {
|
|
259
|
+
scope: "deployment";
|
|
260
|
+
modelReference: string;
|
|
261
|
+
toProvider: string;
|
|
262
|
+
toDeploymentId?: string | undefined;
|
|
263
|
+
}>, z.ZodObject<{
|
|
264
|
+
scope: z.ZodLiteral<"model">;
|
|
265
|
+
/**
|
|
266
|
+
* The UNPINNED model line the customer asked for (`<publisher>/<model>`,
|
|
267
|
+
* never `@revision`). A request that pinned a revision asked for exactly
|
|
268
|
+
* those weights and is served or refused, never substituted — so for such
|
|
269
|
+
* a request there is no value that satisfies this field, and the event
|
|
270
|
+
* cannot be constructed at all.
|
|
271
|
+
*/
|
|
272
|
+
requestedModelId: z.ZodString;
|
|
273
|
+
fromModelReference: z.ZodString;
|
|
274
|
+
toModelReference: z.ZodString;
|
|
275
|
+
toProvider: z.ZodString;
|
|
276
|
+
/** Literal `true`: an unauthorized cross-model switch cannot be reported. */
|
|
277
|
+
authorizedByPolicy: z.ZodLiteral<true>;
|
|
278
|
+
}, "strict", z.ZodTypeAny, {
|
|
279
|
+
scope: "model";
|
|
280
|
+
toProvider: string;
|
|
281
|
+
requestedModelId: string;
|
|
282
|
+
fromModelReference: string;
|
|
283
|
+
toModelReference: string;
|
|
284
|
+
authorizedByPolicy: true;
|
|
285
|
+
}, {
|
|
286
|
+
scope: "model";
|
|
287
|
+
toProvider: string;
|
|
288
|
+
requestedModelId: string;
|
|
289
|
+
fromModelReference: string;
|
|
290
|
+
toModelReference: string;
|
|
291
|
+
authorizedByPolicy: true;
|
|
292
|
+
}>]>;
|
|
293
|
+
occurredAt: z.ZodString;
|
|
294
|
+
}, "strip", z.ZodTypeAny, {
|
|
295
|
+
type: "route_switch";
|
|
296
|
+
reason: "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "capacity" | "policy_preference";
|
|
297
|
+
requestId: string;
|
|
298
|
+
occurredAt: string;
|
|
299
|
+
schemaVersion: 1;
|
|
300
|
+
detail: {
|
|
301
|
+
scope: "deployment";
|
|
302
|
+
modelReference: string;
|
|
303
|
+
toProvider: string;
|
|
304
|
+
toDeploymentId?: string | undefined;
|
|
305
|
+
} | {
|
|
306
|
+
scope: "model";
|
|
307
|
+
toProvider: string;
|
|
308
|
+
requestedModelId: string;
|
|
309
|
+
fromModelReference: string;
|
|
310
|
+
toModelReference: string;
|
|
311
|
+
authorizedByPolicy: true;
|
|
312
|
+
};
|
|
313
|
+
sequence: number;
|
|
314
|
+
}, {
|
|
315
|
+
type: "route_switch";
|
|
316
|
+
reason: "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "capacity" | "policy_preference";
|
|
317
|
+
requestId: string;
|
|
318
|
+
occurredAt: string;
|
|
319
|
+
schemaVersion: 1;
|
|
320
|
+
detail: {
|
|
321
|
+
scope: "deployment";
|
|
322
|
+
modelReference: string;
|
|
323
|
+
toProvider: string;
|
|
324
|
+
toDeploymentId?: string | undefined;
|
|
325
|
+
} | {
|
|
326
|
+
scope: "model";
|
|
327
|
+
toProvider: string;
|
|
328
|
+
requestedModelId: string;
|
|
329
|
+
fromModelReference: string;
|
|
330
|
+
toModelReference: string;
|
|
331
|
+
authorizedByPolicy: true;
|
|
332
|
+
};
|
|
333
|
+
sequence: number;
|
|
334
|
+
}>;
|
|
335
|
+
/**
|
|
336
|
+
* A terminal error. The stream ends here; no `done` follows, so a client that
|
|
337
|
+
* saw an error never also has to reconcile a success.
|
|
338
|
+
*/
|
|
339
|
+
export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
|
|
340
|
+
/** See `version.ts`: each stream event is a whole message on the wire. */
|
|
341
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
342
|
+
type: z.ZodLiteral<"error">;
|
|
343
|
+
requestId: z.ZodString;
|
|
344
|
+
sequence: z.ZodNumber;
|
|
345
|
+
/** Carries its own `schemaVersion`: the same body is returned non-streaming. */
|
|
346
|
+
error: z.ZodEffects<z.ZodObject<{
|
|
347
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
348
|
+
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", "service_unavailable", "internal_error"]>;
|
|
349
|
+
message: z.ZodEffects<z.ZodString, string, string>;
|
|
350
|
+
retryable: z.ZodBoolean;
|
|
351
|
+
requestId: z.ZodString;
|
|
352
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
353
|
+
param: z.ZodOptional<z.ZodString>;
|
|
354
|
+
upstreamCategory: z.ZodOptional<z.ZodEnum<["rate_limit", "quota", "timeout", "overloaded", "server_error", "content_filter", "invalid_request", "authentication", "unknown"]>>;
|
|
355
|
+
providerError: z.ZodOptional<z.ZodObject<{
|
|
356
|
+
provider: z.ZodString;
|
|
357
|
+
status: z.ZodOptional<z.ZodNumber>;
|
|
358
|
+
code: z.ZodOptional<z.ZodString>;
|
|
359
|
+
message: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
360
|
+
}, "strict", z.ZodTypeAny, {
|
|
361
|
+
provider: string;
|
|
362
|
+
code?: string | undefined;
|
|
363
|
+
message?: string | undefined;
|
|
364
|
+
status?: number | undefined;
|
|
365
|
+
}, {
|
|
366
|
+
provider: string;
|
|
367
|
+
code?: string | undefined;
|
|
368
|
+
message?: string | undefined;
|
|
369
|
+
status?: number | undefined;
|
|
370
|
+
}>>;
|
|
371
|
+
}, "strip", z.ZodTypeAny, {
|
|
372
|
+
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" | "service_unavailable" | "internal_error";
|
|
373
|
+
message: string;
|
|
374
|
+
requestId: string;
|
|
375
|
+
schemaVersion: 1;
|
|
376
|
+
retryable: boolean;
|
|
377
|
+
retryAfterMs?: number | undefined;
|
|
378
|
+
param?: string | undefined;
|
|
379
|
+
upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
|
|
380
|
+
providerError?: {
|
|
381
|
+
provider: string;
|
|
382
|
+
code?: string | undefined;
|
|
383
|
+
message?: string | undefined;
|
|
384
|
+
status?: number | undefined;
|
|
385
|
+
} | undefined;
|
|
386
|
+
}, {
|
|
387
|
+
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" | "service_unavailable" | "internal_error";
|
|
388
|
+
message: string;
|
|
389
|
+
requestId: string;
|
|
390
|
+
schemaVersion: 1;
|
|
391
|
+
retryable: boolean;
|
|
392
|
+
retryAfterMs?: number | undefined;
|
|
393
|
+
param?: string | undefined;
|
|
394
|
+
upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
|
|
395
|
+
providerError?: {
|
|
396
|
+
provider: string;
|
|
397
|
+
code?: string | undefined;
|
|
398
|
+
message?: string | undefined;
|
|
399
|
+
status?: number | undefined;
|
|
400
|
+
} | undefined;
|
|
401
|
+
}>, {
|
|
402
|
+
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" | "service_unavailable" | "internal_error";
|
|
403
|
+
message: string;
|
|
404
|
+
requestId: string;
|
|
405
|
+
schemaVersion: 1;
|
|
406
|
+
retryable: boolean;
|
|
407
|
+
retryAfterMs?: number | undefined;
|
|
408
|
+
param?: string | undefined;
|
|
409
|
+
upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
|
|
410
|
+
providerError?: {
|
|
411
|
+
provider: string;
|
|
412
|
+
code?: string | undefined;
|
|
413
|
+
message?: string | undefined;
|
|
414
|
+
status?: number | undefined;
|
|
415
|
+
} | undefined;
|
|
416
|
+
}, {
|
|
417
|
+
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" | "service_unavailable" | "internal_error";
|
|
418
|
+
message: string;
|
|
419
|
+
requestId: string;
|
|
420
|
+
schemaVersion: 1;
|
|
421
|
+
retryable: boolean;
|
|
422
|
+
retryAfterMs?: number | undefined;
|
|
423
|
+
param?: string | undefined;
|
|
424
|
+
upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
|
|
425
|
+
providerError?: {
|
|
426
|
+
provider: string;
|
|
427
|
+
code?: string | undefined;
|
|
428
|
+
message?: string | undefined;
|
|
429
|
+
status?: number | undefined;
|
|
430
|
+
} | undefined;
|
|
431
|
+
}>;
|
|
432
|
+
}, "strip", z.ZodTypeAny, {
|
|
433
|
+
type: "error";
|
|
434
|
+
requestId: string;
|
|
435
|
+
schemaVersion: 1;
|
|
436
|
+
sequence: number;
|
|
437
|
+
error: {
|
|
438
|
+
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" | "service_unavailable" | "internal_error";
|
|
439
|
+
message: string;
|
|
440
|
+
requestId: string;
|
|
441
|
+
schemaVersion: 1;
|
|
442
|
+
retryable: boolean;
|
|
443
|
+
retryAfterMs?: number | undefined;
|
|
444
|
+
param?: string | undefined;
|
|
445
|
+
upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
|
|
446
|
+
providerError?: {
|
|
447
|
+
provider: string;
|
|
448
|
+
code?: string | undefined;
|
|
449
|
+
message?: string | undefined;
|
|
450
|
+
status?: number | undefined;
|
|
451
|
+
} | undefined;
|
|
452
|
+
};
|
|
453
|
+
}, {
|
|
454
|
+
type: "error";
|
|
455
|
+
requestId: string;
|
|
456
|
+
schemaVersion: 1;
|
|
457
|
+
sequence: number;
|
|
458
|
+
error: {
|
|
459
|
+
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" | "service_unavailable" | "internal_error";
|
|
460
|
+
message: string;
|
|
461
|
+
requestId: string;
|
|
462
|
+
schemaVersion: 1;
|
|
463
|
+
retryable: boolean;
|
|
464
|
+
retryAfterMs?: number | undefined;
|
|
465
|
+
param?: string | undefined;
|
|
466
|
+
upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
|
|
467
|
+
providerError?: {
|
|
468
|
+
provider: string;
|
|
469
|
+
code?: string | undefined;
|
|
470
|
+
message?: string | undefined;
|
|
471
|
+
status?: number | undefined;
|
|
472
|
+
} | undefined;
|
|
473
|
+
};
|
|
474
|
+
}>;
|
|
475
|
+
/** Why generation stopped. */
|
|
476
|
+
export declare const inferenceFinishReasonSchema: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "cancelled"]>;
|
|
477
|
+
/**
|
|
478
|
+
* The successful terminal event.
|
|
479
|
+
*
|
|
480
|
+
* `receiptId` is present once settlement has produced one, giving a customer a
|
|
481
|
+
* direct handle on the exact amount charged rather than a telemetry estimate.
|
|
482
|
+
*/
|
|
483
|
+
export declare const inferenceStreamDoneEventSchema: z.ZodObject<{
|
|
484
|
+
/** See `version.ts`: each stream event is a whole message on the wire. */
|
|
485
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
486
|
+
type: z.ZodLiteral<"done">;
|
|
487
|
+
requestId: z.ZodString;
|
|
488
|
+
sequence: z.ZodNumber;
|
|
489
|
+
generationId: z.ZodOptional<z.ZodString>;
|
|
490
|
+
finishReason: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "cancelled"]>;
|
|
491
|
+
receiptId: z.ZodOptional<z.ZodString>;
|
|
492
|
+
completedAt: z.ZodString;
|
|
493
|
+
}, "strip", z.ZodTypeAny, {
|
|
494
|
+
type: "done";
|
|
495
|
+
requestId: string;
|
|
496
|
+
schemaVersion: 1;
|
|
497
|
+
sequence: number;
|
|
498
|
+
finishReason: "length" | "cancelled" | "content_filter" | "stop" | "tool_calls";
|
|
499
|
+
completedAt: string;
|
|
500
|
+
generationId?: string | undefined;
|
|
501
|
+
receiptId?: string | undefined;
|
|
502
|
+
}, {
|
|
503
|
+
type: "done";
|
|
504
|
+
requestId: string;
|
|
505
|
+
schemaVersion: 1;
|
|
506
|
+
sequence: number;
|
|
507
|
+
finishReason: "length" | "cancelled" | "content_filter" | "stop" | "tool_calls";
|
|
508
|
+
completedAt: string;
|
|
509
|
+
generationId?: string | undefined;
|
|
510
|
+
receiptId?: string | undefined;
|
|
511
|
+
}>;
|
|
512
|
+
/**
|
|
513
|
+
* Every event a normalized stream can carry.
|
|
514
|
+
*
|
|
515
|
+
* Discriminated on `type`, so a consumer that meets an unknown event fails at
|
|
516
|
+
* the parse instead of falling into a default branch that treats it as output.
|
|
517
|
+
*/
|
|
518
|
+
export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
519
|
+
/** See `version.ts`: each stream event is a whole message on the wire. */
|
|
520
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
521
|
+
type: z.ZodLiteral<"start">;
|
|
522
|
+
requestId: z.ZodString;
|
|
523
|
+
sequence: z.ZodNumber;
|
|
524
|
+
generationId: z.ZodOptional<z.ZodString>;
|
|
525
|
+
/** Always revision-pinned, even when the request named only the model. */
|
|
526
|
+
resolvedModelReference: z.ZodString;
|
|
527
|
+
servingProvider: z.ZodString;
|
|
528
|
+
startedAt: z.ZodString;
|
|
529
|
+
}, "strip", z.ZodTypeAny, {
|
|
530
|
+
type: "start";
|
|
531
|
+
requestId: string;
|
|
532
|
+
schemaVersion: 1;
|
|
533
|
+
sequence: number;
|
|
534
|
+
resolvedModelReference: string;
|
|
535
|
+
servingProvider: string;
|
|
536
|
+
startedAt: string;
|
|
537
|
+
generationId?: string | undefined;
|
|
538
|
+
}, {
|
|
539
|
+
type: "start";
|
|
540
|
+
requestId: string;
|
|
541
|
+
schemaVersion: 1;
|
|
542
|
+
sequence: number;
|
|
543
|
+
resolvedModelReference: string;
|
|
544
|
+
servingProvider: string;
|
|
545
|
+
startedAt: string;
|
|
546
|
+
generationId?: string | undefined;
|
|
547
|
+
}>, z.ZodObject<{
|
|
548
|
+
/** See `version.ts`: each stream event is a whole message on the wire. */
|
|
549
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
550
|
+
type: z.ZodLiteral<"delta">;
|
|
551
|
+
requestId: z.ZodString;
|
|
552
|
+
sequence: z.ZodNumber;
|
|
553
|
+
/** Which output of a multi-output response this chunk belongs to. */
|
|
554
|
+
outputIndex: z.ZodNumber;
|
|
555
|
+
channel: z.ZodEnum<["output_text", "reasoning", "refusal"]>;
|
|
556
|
+
text: z.ZodString;
|
|
557
|
+
}, "strip", z.ZodTypeAny, {
|
|
558
|
+
channel: "reasoning" | "output_text" | "refusal";
|
|
559
|
+
type: "delta";
|
|
560
|
+
requestId: string;
|
|
561
|
+
schemaVersion: 1;
|
|
562
|
+
text: string;
|
|
563
|
+
sequence: number;
|
|
564
|
+
outputIndex: number;
|
|
565
|
+
}, {
|
|
566
|
+
channel: "reasoning" | "output_text" | "refusal";
|
|
567
|
+
type: "delta";
|
|
568
|
+
requestId: string;
|
|
569
|
+
schemaVersion: 1;
|
|
570
|
+
text: string;
|
|
571
|
+
sequence: number;
|
|
572
|
+
outputIndex: number;
|
|
573
|
+
}>, z.ZodObject<{
|
|
574
|
+
/** See `version.ts`: each stream event is a whole message on the wire. */
|
|
575
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
576
|
+
type: z.ZodLiteral<"tool_call">;
|
|
577
|
+
requestId: z.ZodString;
|
|
578
|
+
sequence: z.ZodNumber;
|
|
579
|
+
toolCallId: z.ZodString;
|
|
580
|
+
/** Present on the first event of a call. */
|
|
581
|
+
name: z.ZodOptional<z.ZodString>;
|
|
582
|
+
argumentsDelta: z.ZodOptional<z.ZodString>;
|
|
583
|
+
complete: z.ZodBoolean;
|
|
584
|
+
}, "strip", z.ZodTypeAny, {
|
|
585
|
+
type: "tool_call";
|
|
586
|
+
requestId: string;
|
|
587
|
+
schemaVersion: 1;
|
|
588
|
+
toolCallId: string;
|
|
589
|
+
sequence: number;
|
|
590
|
+
complete: boolean;
|
|
591
|
+
name?: string | undefined;
|
|
592
|
+
argumentsDelta?: string | undefined;
|
|
593
|
+
}, {
|
|
594
|
+
type: "tool_call";
|
|
595
|
+
requestId: string;
|
|
596
|
+
schemaVersion: 1;
|
|
597
|
+
toolCallId: string;
|
|
598
|
+
sequence: number;
|
|
599
|
+
complete: boolean;
|
|
600
|
+
name?: string | undefined;
|
|
601
|
+
argumentsDelta?: string | undefined;
|
|
602
|
+
}>, z.ZodObject<{
|
|
603
|
+
/** See `version.ts`: each stream event is a whole message on the wire. */
|
|
604
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
605
|
+
type: z.ZodLiteral<"usage">;
|
|
606
|
+
requestId: z.ZodString;
|
|
607
|
+
sequence: z.ZodNumber;
|
|
608
|
+
units: z.ZodArray<z.ZodObject<{
|
|
609
|
+
unit: z.ZodEnum<["input_tokens", "cached_input_tokens", "output_tokens", "reasoning_tokens", "requests", "images", "audio_input_milliseconds", "audio_output_milliseconds", "video_milliseconds", "characters", "embeddings"]>;
|
|
610
|
+
quantity: z.ZodNumber;
|
|
611
|
+
}, "strict", z.ZodTypeAny, {
|
|
612
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
613
|
+
quantity: number;
|
|
614
|
+
}, {
|
|
615
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
616
|
+
quantity: number;
|
|
617
|
+
}>, "many">;
|
|
618
|
+
usageSource: z.ZodEnum<["provider_reported", "oxy_measured", "estimated"]>;
|
|
619
|
+
}, "strip", z.ZodTypeAny, {
|
|
620
|
+
type: "usage";
|
|
621
|
+
requestId: string;
|
|
622
|
+
schemaVersion: 1;
|
|
623
|
+
sequence: number;
|
|
624
|
+
units: {
|
|
625
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
626
|
+
quantity: number;
|
|
627
|
+
}[];
|
|
628
|
+
usageSource: "provider_reported" | "oxy_measured" | "estimated";
|
|
629
|
+
}, {
|
|
630
|
+
type: "usage";
|
|
631
|
+
requestId: string;
|
|
632
|
+
schemaVersion: 1;
|
|
633
|
+
sequence: number;
|
|
634
|
+
units: {
|
|
635
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
636
|
+
quantity: number;
|
|
637
|
+
}[];
|
|
638
|
+
usageSource: "provider_reported" | "oxy_measured" | "estimated";
|
|
639
|
+
}>, z.ZodObject<{
|
|
640
|
+
/** See `version.ts`: each stream event is a whole message on the wire. */
|
|
641
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
642
|
+
type: z.ZodLiteral<"route_switch">;
|
|
643
|
+
requestId: z.ZodString;
|
|
644
|
+
sequence: z.ZodNumber;
|
|
645
|
+
reason: z.ZodEnum<["deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "rate_limited", "capacity", "policy_preference"]>;
|
|
646
|
+
detail: z.ZodDiscriminatedUnion<"scope", [z.ZodObject<{
|
|
647
|
+
scope: z.ZodLiteral<"deployment">;
|
|
648
|
+
modelReference: z.ZodString;
|
|
649
|
+
toProvider: z.ZodString;
|
|
650
|
+
toDeploymentId: z.ZodOptional<z.ZodString>;
|
|
651
|
+
}, "strict", z.ZodTypeAny, {
|
|
652
|
+
scope: "deployment";
|
|
653
|
+
modelReference: string;
|
|
654
|
+
toProvider: string;
|
|
655
|
+
toDeploymentId?: string | undefined;
|
|
656
|
+
}, {
|
|
657
|
+
scope: "deployment";
|
|
658
|
+
modelReference: string;
|
|
659
|
+
toProvider: string;
|
|
660
|
+
toDeploymentId?: string | undefined;
|
|
661
|
+
}>, z.ZodObject<{
|
|
662
|
+
scope: z.ZodLiteral<"model">;
|
|
663
|
+
/**
|
|
664
|
+
* The UNPINNED model line the customer asked for (`<publisher>/<model>`,
|
|
665
|
+
* never `@revision`). A request that pinned a revision asked for exactly
|
|
666
|
+
* those weights and is served or refused, never substituted — so for such
|
|
667
|
+
* a request there is no value that satisfies this field, and the event
|
|
668
|
+
* cannot be constructed at all.
|
|
669
|
+
*/
|
|
670
|
+
requestedModelId: z.ZodString;
|
|
671
|
+
fromModelReference: z.ZodString;
|
|
672
|
+
toModelReference: z.ZodString;
|
|
673
|
+
toProvider: z.ZodString;
|
|
674
|
+
/** Literal `true`: an unauthorized cross-model switch cannot be reported. */
|
|
675
|
+
authorizedByPolicy: z.ZodLiteral<true>;
|
|
676
|
+
}, "strict", z.ZodTypeAny, {
|
|
677
|
+
scope: "model";
|
|
678
|
+
toProvider: string;
|
|
679
|
+
requestedModelId: string;
|
|
680
|
+
fromModelReference: string;
|
|
681
|
+
toModelReference: string;
|
|
682
|
+
authorizedByPolicy: true;
|
|
683
|
+
}, {
|
|
684
|
+
scope: "model";
|
|
685
|
+
toProvider: string;
|
|
686
|
+
requestedModelId: string;
|
|
687
|
+
fromModelReference: string;
|
|
688
|
+
toModelReference: string;
|
|
689
|
+
authorizedByPolicy: true;
|
|
690
|
+
}>]>;
|
|
691
|
+
occurredAt: z.ZodString;
|
|
692
|
+
}, "strip", z.ZodTypeAny, {
|
|
693
|
+
type: "route_switch";
|
|
694
|
+
reason: "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "capacity" | "policy_preference";
|
|
695
|
+
requestId: string;
|
|
696
|
+
occurredAt: string;
|
|
697
|
+
schemaVersion: 1;
|
|
698
|
+
detail: {
|
|
699
|
+
scope: "deployment";
|
|
700
|
+
modelReference: string;
|
|
701
|
+
toProvider: string;
|
|
702
|
+
toDeploymentId?: string | undefined;
|
|
703
|
+
} | {
|
|
704
|
+
scope: "model";
|
|
705
|
+
toProvider: string;
|
|
706
|
+
requestedModelId: string;
|
|
707
|
+
fromModelReference: string;
|
|
708
|
+
toModelReference: string;
|
|
709
|
+
authorizedByPolicy: true;
|
|
710
|
+
};
|
|
711
|
+
sequence: number;
|
|
712
|
+
}, {
|
|
713
|
+
type: "route_switch";
|
|
714
|
+
reason: "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "capacity" | "policy_preference";
|
|
715
|
+
requestId: string;
|
|
716
|
+
occurredAt: string;
|
|
717
|
+
schemaVersion: 1;
|
|
718
|
+
detail: {
|
|
719
|
+
scope: "deployment";
|
|
720
|
+
modelReference: string;
|
|
721
|
+
toProvider: string;
|
|
722
|
+
toDeploymentId?: string | undefined;
|
|
723
|
+
} | {
|
|
724
|
+
scope: "model";
|
|
725
|
+
toProvider: string;
|
|
726
|
+
requestedModelId: string;
|
|
727
|
+
fromModelReference: string;
|
|
728
|
+
toModelReference: string;
|
|
729
|
+
authorizedByPolicy: true;
|
|
730
|
+
};
|
|
731
|
+
sequence: number;
|
|
732
|
+
}>, z.ZodObject<{
|
|
733
|
+
/** See `version.ts`: each stream event is a whole message on the wire. */
|
|
734
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
735
|
+
type: z.ZodLiteral<"error">;
|
|
736
|
+
requestId: z.ZodString;
|
|
737
|
+
sequence: z.ZodNumber;
|
|
738
|
+
/** Carries its own `schemaVersion`: the same body is returned non-streaming. */
|
|
739
|
+
error: z.ZodEffects<z.ZodObject<{
|
|
740
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
741
|
+
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", "service_unavailable", "internal_error"]>;
|
|
742
|
+
message: z.ZodEffects<z.ZodString, string, string>;
|
|
743
|
+
retryable: z.ZodBoolean;
|
|
744
|
+
requestId: z.ZodString;
|
|
745
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
746
|
+
param: z.ZodOptional<z.ZodString>;
|
|
747
|
+
upstreamCategory: z.ZodOptional<z.ZodEnum<["rate_limit", "quota", "timeout", "overloaded", "server_error", "content_filter", "invalid_request", "authentication", "unknown"]>>;
|
|
748
|
+
providerError: z.ZodOptional<z.ZodObject<{
|
|
749
|
+
provider: z.ZodString;
|
|
750
|
+
status: z.ZodOptional<z.ZodNumber>;
|
|
751
|
+
code: z.ZodOptional<z.ZodString>;
|
|
752
|
+
message: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
753
|
+
}, "strict", z.ZodTypeAny, {
|
|
754
|
+
provider: string;
|
|
755
|
+
code?: string | undefined;
|
|
756
|
+
message?: string | undefined;
|
|
757
|
+
status?: number | undefined;
|
|
758
|
+
}, {
|
|
759
|
+
provider: string;
|
|
760
|
+
code?: string | undefined;
|
|
761
|
+
message?: string | undefined;
|
|
762
|
+
status?: number | undefined;
|
|
763
|
+
}>>;
|
|
764
|
+
}, "strip", z.ZodTypeAny, {
|
|
765
|
+
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" | "service_unavailable" | "internal_error";
|
|
766
|
+
message: string;
|
|
767
|
+
requestId: string;
|
|
768
|
+
schemaVersion: 1;
|
|
769
|
+
retryable: boolean;
|
|
770
|
+
retryAfterMs?: number | undefined;
|
|
771
|
+
param?: string | undefined;
|
|
772
|
+
upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
|
|
773
|
+
providerError?: {
|
|
774
|
+
provider: string;
|
|
775
|
+
code?: string | undefined;
|
|
776
|
+
message?: string | undefined;
|
|
777
|
+
status?: number | undefined;
|
|
778
|
+
} | undefined;
|
|
779
|
+
}, {
|
|
780
|
+
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" | "service_unavailable" | "internal_error";
|
|
781
|
+
message: string;
|
|
782
|
+
requestId: string;
|
|
783
|
+
schemaVersion: 1;
|
|
784
|
+
retryable: boolean;
|
|
785
|
+
retryAfterMs?: number | undefined;
|
|
786
|
+
param?: string | undefined;
|
|
787
|
+
upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
|
|
788
|
+
providerError?: {
|
|
789
|
+
provider: string;
|
|
790
|
+
code?: string | undefined;
|
|
791
|
+
message?: string | undefined;
|
|
792
|
+
status?: number | undefined;
|
|
793
|
+
} | undefined;
|
|
794
|
+
}>, {
|
|
795
|
+
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" | "service_unavailable" | "internal_error";
|
|
796
|
+
message: string;
|
|
797
|
+
requestId: string;
|
|
798
|
+
schemaVersion: 1;
|
|
799
|
+
retryable: boolean;
|
|
800
|
+
retryAfterMs?: number | undefined;
|
|
801
|
+
param?: string | undefined;
|
|
802
|
+
upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
|
|
803
|
+
providerError?: {
|
|
804
|
+
provider: string;
|
|
805
|
+
code?: string | undefined;
|
|
806
|
+
message?: string | undefined;
|
|
807
|
+
status?: number | undefined;
|
|
808
|
+
} | undefined;
|
|
809
|
+
}, {
|
|
810
|
+
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" | "service_unavailable" | "internal_error";
|
|
811
|
+
message: string;
|
|
812
|
+
requestId: string;
|
|
813
|
+
schemaVersion: 1;
|
|
814
|
+
retryable: boolean;
|
|
815
|
+
retryAfterMs?: number | undefined;
|
|
816
|
+
param?: string | undefined;
|
|
817
|
+
upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
|
|
818
|
+
providerError?: {
|
|
819
|
+
provider: string;
|
|
820
|
+
code?: string | undefined;
|
|
821
|
+
message?: string | undefined;
|
|
822
|
+
status?: number | undefined;
|
|
823
|
+
} | undefined;
|
|
824
|
+
}>;
|
|
825
|
+
}, "strip", z.ZodTypeAny, {
|
|
826
|
+
type: "error";
|
|
827
|
+
requestId: string;
|
|
828
|
+
schemaVersion: 1;
|
|
829
|
+
sequence: number;
|
|
830
|
+
error: {
|
|
831
|
+
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" | "service_unavailable" | "internal_error";
|
|
832
|
+
message: string;
|
|
833
|
+
requestId: string;
|
|
834
|
+
schemaVersion: 1;
|
|
835
|
+
retryable: boolean;
|
|
836
|
+
retryAfterMs?: number | undefined;
|
|
837
|
+
param?: string | undefined;
|
|
838
|
+
upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
|
|
839
|
+
providerError?: {
|
|
840
|
+
provider: string;
|
|
841
|
+
code?: string | undefined;
|
|
842
|
+
message?: string | undefined;
|
|
843
|
+
status?: number | undefined;
|
|
844
|
+
} | undefined;
|
|
845
|
+
};
|
|
846
|
+
}, {
|
|
847
|
+
type: "error";
|
|
848
|
+
requestId: string;
|
|
849
|
+
schemaVersion: 1;
|
|
850
|
+
sequence: number;
|
|
851
|
+
error: {
|
|
852
|
+
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" | "service_unavailable" | "internal_error";
|
|
853
|
+
message: string;
|
|
854
|
+
requestId: string;
|
|
855
|
+
schemaVersion: 1;
|
|
856
|
+
retryable: boolean;
|
|
857
|
+
retryAfterMs?: number | undefined;
|
|
858
|
+
param?: string | undefined;
|
|
859
|
+
upstreamCategory?: "unknown" | "authentication" | "invalid_request" | "rate_limit" | "quota" | "timeout" | "overloaded" | "server_error" | "content_filter" | undefined;
|
|
860
|
+
providerError?: {
|
|
861
|
+
provider: string;
|
|
862
|
+
code?: string | undefined;
|
|
863
|
+
message?: string | undefined;
|
|
864
|
+
status?: number | undefined;
|
|
865
|
+
} | undefined;
|
|
866
|
+
};
|
|
867
|
+
}>, z.ZodObject<{
|
|
868
|
+
/** See `version.ts`: each stream event is a whole message on the wire. */
|
|
869
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
870
|
+
type: z.ZodLiteral<"done">;
|
|
871
|
+
requestId: z.ZodString;
|
|
872
|
+
sequence: z.ZodNumber;
|
|
873
|
+
generationId: z.ZodOptional<z.ZodString>;
|
|
874
|
+
finishReason: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "cancelled"]>;
|
|
875
|
+
receiptId: z.ZodOptional<z.ZodString>;
|
|
876
|
+
completedAt: z.ZodString;
|
|
877
|
+
}, "strip", z.ZodTypeAny, {
|
|
878
|
+
type: "done";
|
|
879
|
+
requestId: string;
|
|
880
|
+
schemaVersion: 1;
|
|
881
|
+
sequence: number;
|
|
882
|
+
finishReason: "length" | "cancelled" | "content_filter" | "stop" | "tool_calls";
|
|
883
|
+
completedAt: string;
|
|
884
|
+
generationId?: string | undefined;
|
|
885
|
+
receiptId?: string | undefined;
|
|
886
|
+
}, {
|
|
887
|
+
type: "done";
|
|
888
|
+
requestId: string;
|
|
889
|
+
schemaVersion: 1;
|
|
890
|
+
sequence: number;
|
|
891
|
+
finishReason: "length" | "cancelled" | "content_filter" | "stop" | "tool_calls";
|
|
892
|
+
completedAt: string;
|
|
893
|
+
generationId?: string | undefined;
|
|
894
|
+
receiptId?: string | undefined;
|
|
895
|
+
}>]>;
|
|
896
|
+
export type InferenceStreamStartEvent = z.infer<typeof inferenceStreamStartEventSchema>;
|
|
897
|
+
export type InferenceStreamDeltaEvent = z.infer<typeof inferenceStreamDeltaEventSchema>;
|
|
898
|
+
export type InferenceStreamToolCallEvent = z.infer<typeof inferenceStreamToolCallEventSchema>;
|
|
899
|
+
export type InferenceStreamUsageEvent = z.infer<typeof inferenceStreamUsageEventSchema>;
|
|
900
|
+
export type InferenceRouteSwitchDetail = z.infer<typeof inferenceRouteSwitchDetailSchema>;
|
|
901
|
+
export type InferenceRouteSwitchReason = z.infer<typeof inferenceRouteSwitchReasonSchema>;
|
|
902
|
+
export type InferenceStreamRouteSwitchEvent = z.infer<typeof inferenceStreamRouteSwitchEventSchema>;
|
|
903
|
+
export type InferenceStreamErrorEvent = z.infer<typeof inferenceStreamErrorEventSchema>;
|
|
904
|
+
export type InferenceFinishReason = z.infer<typeof inferenceFinishReasonSchema>;
|
|
905
|
+
export type InferenceStreamDoneEvent = z.infer<typeof inferenceStreamDoneEventSchema>;
|
|
906
|
+
export type InferenceStreamEvent = z.infer<typeof inferenceStreamEventSchema>;
|