@oxyhq/contracts 0.27.0 → 0.29.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/index.js +44 -1
- package/dist/cjs/inference/accountBilling.js +334 -0
- package/dist/cjs/inference/attribution.js +9 -4
- package/dist/cjs/inference/entitlement.js +217 -0
- package/dist/cjs/inference/errors.js +123 -9
- package/dist/cjs/inference/identifiers.js +11 -3
- package/dist/cjs/inference/money.js +43 -0
- package/dist/cjs/inference/streamEvents.js +11 -1
- package/dist/cjs/inference/usage.js +6 -0
- package/dist/cjs/inference/version.js +38 -3
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/index.js +9 -0
- package/dist/esm/inference/accountBilling.js +331 -0
- package/dist/esm/inference/attribution.js +9 -4
- package/dist/esm/inference/entitlement.js +214 -0
- package/dist/esm/inference/errors.js +123 -9
- package/dist/esm/inference/identifiers.js +11 -3
- package/dist/esm/inference/money.js +43 -0
- package/dist/esm/inference/streamEvents.js +11 -1
- package/dist/esm/inference/usage.js +6 -0
- package/dist/esm/inference/version.js +38 -3
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/inference/accountBilling.d.ts +738 -0
- package/dist/types/inference/attribution.d.ts +9 -4
- package/dist/types/inference/entitlement.d.ts +519 -0
- package/dist/types/inference/errors.d.ts +59 -10
- package/dist/types/inference/identifiers.d.ts +11 -3
- package/dist/types/inference/money.d.ts +43 -0
- package/dist/types/inference/streamEvents.d.ts +31 -22
- package/dist/types/inference/usage.d.ts +6 -0
- package/dist/types/inference/version.d.ts +38 -3
- package/package.json +1 -1
|
@@ -31,9 +31,20 @@ import { z } from 'zod';
|
|
|
31
31
|
* `quota_exceeded`, `byok_credential_invalid`), routing/permission policy
|
|
32
32
|
* (`policy_violation`, `commercial_permission_denied`, `no_route_available`),
|
|
33
33
|
* and the platform or its upstreams (everything from `deployment_unavailable`).
|
|
34
|
+
*
|
|
35
|
+
* The platform group is NOT uniformly retryable, and that is the point of
|
|
36
|
+
* `provider_credential_invalid` sitting in it: an upstream that refuses the
|
|
37
|
+
* PLATFORM's own credential fails every identical retry until an operator
|
|
38
|
+
* rotates a key, so classifying it as `provider_error` would send every client
|
|
39
|
+
* into a retry loop against a request that cannot succeed.
|
|
40
|
+
*
|
|
41
|
+
* `provider_billing_refused` is in that group for the same reason and was found
|
|
42
|
+
* the same way — an upstream declining to bill OXY (Anthropic answers 402) has
|
|
43
|
+
* to be distinguishable from the customer's own balance running out, or the
|
|
44
|
+
* error tells them to go and top up an account that is not the one at fault.
|
|
34
45
|
*/
|
|
35
|
-
export declare const INFERENCE_ERROR_CODES: readonly ["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", "service_unavailable", "internal_error"];
|
|
36
|
-
export declare const inferenceErrorCodeSchema: 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", "service_unavailable", "internal_error"]>;
|
|
46
|
+
export declare const INFERENCE_ERROR_CODES: readonly ["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"];
|
|
47
|
+
export declare const inferenceErrorCodeSchema: 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"]>;
|
|
37
48
|
/**
|
|
38
49
|
* Codes for which an identical retried request cannot succeed.
|
|
39
50
|
*
|
|
@@ -42,12 +53,50 @@ export declare const inferenceErrorCodeSchema: z.ZodEnum<["invalid_request", "au
|
|
|
42
53
|
* names, while a quota is an account-level ceiling that only a human raises.
|
|
43
54
|
* `cancelled` is here because the caller already withdrew the request; a client
|
|
44
55
|
* that retries it is contradicting its own cancellation.
|
|
56
|
+
*
|
|
57
|
+
* `byok_credential_invalid` and `provider_credential_invalid` are the same
|
|
58
|
+
* failure seen from the two sides of the BYOK boundary — the customer's own
|
|
59
|
+
* upstream credential and the platform's — and they are two codes rather than
|
|
60
|
+
* one because only the first names an action the customer can take. Both are
|
|
61
|
+
* non-retryable for the same reason: a credential an upstream has refused keeps
|
|
62
|
+
* being refused until somebody replaces it.
|
|
63
|
+
*
|
|
64
|
+
* `quota_exceeded` and `provider_billing_refused` divide along the same line:
|
|
65
|
+
* both are money, but one is the CUSTOMER's ceiling and the other is Oxy's
|
|
66
|
+
* account with an upstream. Reporting the second as the first is retryability-
|
|
67
|
+
* correct and diagnostically wrong, which is the worst combination — it reads
|
|
68
|
+
* as actionable and the action does nothing.
|
|
45
69
|
*/
|
|
46
|
-
export declare const NON_RETRYABLE_INFERENCE_ERROR_CODES: readonly ["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"];
|
|
70
|
+
export declare const NON_RETRYABLE_INFERENCE_ERROR_CODES: readonly ["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", "provider_credential_invalid", "provider_billing_refused"];
|
|
47
71
|
/**
|
|
48
|
-
* Free text that is safe to hand a customer: bounded, and refused
|
|
49
|
-
*
|
|
72
|
+
* Free text that is safe to hand a customer: bounded, and refused if it still
|
|
73
|
+
* looks like it carries a credential. Applied to BOTH the Oxy message and the
|
|
50
74
|
* upstream one — a leak is no less a leak for having been written by a provider.
|
|
75
|
+
*
|
|
76
|
+
* ## This is a last-resort REFUSAL, not protection
|
|
77
|
+
*
|
|
78
|
+
* A pattern over the OUTPUT cannot be the control that keeps a credential out of
|
|
79
|
+
* an error, and a producer that treats it as one has the hole #1027 reported.
|
|
80
|
+
* The only reliable control is redacting the KNOWN SECRET VALUE at the point
|
|
81
|
+
* where the producer still holds the bytes it sent — which is an adapter's job
|
|
82
|
+
* and is available to nobody else. This refinement exists to catch what that
|
|
83
|
+
* control missed, and nothing here is a licence to skip it.
|
|
84
|
+
*
|
|
85
|
+
* Two rules follow, and they are the whole reason this text is longer than the
|
|
86
|
+
* pattern it describes:
|
|
87
|
+
*
|
|
88
|
+
* - **Never redact by replacing the span this pattern matched.** The span is
|
|
89
|
+
* the MARKER; the secret is what follows it. OxyHQ/Relay#3 measured the
|
|
90
|
+
* result: `{x-api-key: <key>}` is refused, `{x-[redacted] <key>}` was
|
|
91
|
+
* accepted, and both carry the key. Redaction made the leak worse by
|
|
92
|
+
* converting "this string is dangerous" into "this string is fine".
|
|
93
|
+
* - **This package deliberately ships no redaction helper.** One keyed on these
|
|
94
|
+
* patterns would rebuild the same defect one layer up, and one that took the
|
|
95
|
+
* secret as an argument would only restate what the producer already has.
|
|
96
|
+
*
|
|
97
|
+
* What it still cannot see, stated so nobody relies on it: a credential with no
|
|
98
|
+
* marker, no issued-token prefix and no placeholder beside it is bytes that look
|
|
99
|
+
* like a request id, and refusing those means refusing request ids.
|
|
51
100
|
*/
|
|
52
101
|
export declare const safeErrorTextSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
53
102
|
/**
|
|
@@ -97,7 +146,7 @@ export declare const providerErrorPassthroughSchema: z.ZodObject<{
|
|
|
97
146
|
export declare const inferenceErrorSchema: z.ZodEffects<z.ZodObject<{
|
|
98
147
|
/** See `version.ts`: this shape appears alone on the wire, so it is versioned. */
|
|
99
148
|
schemaVersion: z.ZodLiteral<1>;
|
|
100
|
-
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", "service_unavailable", "internal_error"]>;
|
|
149
|
+
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"]>;
|
|
101
150
|
message: z.ZodEffects<z.ZodString, string, string>;
|
|
102
151
|
retryable: z.ZodBoolean;
|
|
103
152
|
requestId: z.ZodString;
|
|
@@ -127,7 +176,7 @@ export declare const inferenceErrorSchema: z.ZodEffects<z.ZodObject<{
|
|
|
127
176
|
status?: number | undefined;
|
|
128
177
|
}>>;
|
|
129
178
|
}, "strip", z.ZodTypeAny, {
|
|
130
|
-
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" | "service_unavailable" | "internal_error";
|
|
179
|
+
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";
|
|
131
180
|
message: string;
|
|
132
181
|
requestId: string;
|
|
133
182
|
schemaVersion: 1;
|
|
@@ -142,7 +191,7 @@ export declare const inferenceErrorSchema: z.ZodEffects<z.ZodObject<{
|
|
|
142
191
|
status?: number | undefined;
|
|
143
192
|
} | undefined;
|
|
144
193
|
}, {
|
|
145
|
-
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" | "service_unavailable" | "internal_error";
|
|
194
|
+
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";
|
|
146
195
|
message: string;
|
|
147
196
|
requestId: string;
|
|
148
197
|
schemaVersion: 1;
|
|
@@ -157,7 +206,7 @@ export declare const inferenceErrorSchema: z.ZodEffects<z.ZodObject<{
|
|
|
157
206
|
status?: number | undefined;
|
|
158
207
|
} | undefined;
|
|
159
208
|
}>, {
|
|
160
|
-
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" | "service_unavailable" | "internal_error";
|
|
209
|
+
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";
|
|
161
210
|
message: string;
|
|
162
211
|
requestId: string;
|
|
163
212
|
schemaVersion: 1;
|
|
@@ -172,7 +221,7 @@ export declare const inferenceErrorSchema: z.ZodEffects<z.ZodObject<{
|
|
|
172
221
|
status?: number | undefined;
|
|
173
222
|
} | undefined;
|
|
174
223
|
}, {
|
|
175
|
-
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" | "service_unavailable" | "internal_error";
|
|
224
|
+
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";
|
|
176
225
|
message: string;
|
|
177
226
|
requestId: string;
|
|
178
227
|
schemaVersion: 1;
|
|
@@ -51,9 +51,17 @@ export declare const oxyApplicationIdSchema: z.ZodString;
|
|
|
51
51
|
/** An Oxy `ApplicationCredential._id` — the credential used for this request. */
|
|
52
52
|
export declare const oxyCredentialIdSchema: z.ZodString;
|
|
53
53
|
/**
|
|
54
|
-
* A request id
|
|
55
|
-
*
|
|
56
|
-
*
|
|
54
|
+
* A request id allocated by the Oxy EDGE, at admission and BEFORE
|
|
55
|
+
* authentication, so that a request rejected for a bad credential is as
|
|
56
|
+
* traceable as one that was served (ADR 0007, and step 1 of ADR 0010's edge
|
|
57
|
+
* order). It is required on the inbound envelope, which is what makes the data
|
|
58
|
+
* plane a consumer of this id rather than its source: the data plane echoes it
|
|
59
|
+
* on every stream event, on the usage report and on anything it can be asked
|
|
60
|
+
* about later.
|
|
61
|
+
*
|
|
62
|
+
* Correlates the Oxy edge, the data plane, the financial ledger and the
|
|
63
|
+
* customer-visible receipt, so it appears on every stream event and every
|
|
64
|
+
* ledger record.
|
|
57
65
|
*/
|
|
58
66
|
export declare const requestIdSchema: z.ZodString;
|
|
59
67
|
/**
|
|
@@ -78,6 +78,49 @@ export declare const moneySchema: z.ZodObject<{
|
|
|
78
78
|
/**
|
|
79
79
|
* The closed set of units inference is metered in.
|
|
80
80
|
*
|
|
81
|
+
* **The units PARTITION a request: every unit counts material no other unit
|
|
82
|
+
* counts.** `cached_input_tokens` is not part of `input_tokens`, and
|
|
83
|
+
* `reasoning_tokens` is not part of `output_tokens` — they are siblings, not
|
|
84
|
+
* subsets. A request whose 10 000-token prompt was served 9 000 tokens from
|
|
85
|
+
* cache is reported as `input_tokens: 1000` beside `cached_input_tokens: 9000`,
|
|
86
|
+
* never as `input_tokens: 10000` beside it.
|
|
87
|
+
*
|
|
88
|
+
* That belongs to the definition rather than to a convention somewhere else,
|
|
89
|
+
* because settlement applies a price to EVERY reported unit and sums them
|
|
90
|
+
* (`inferenceLedger.service.ts`'s `computeCharge`). Under the partition rule
|
|
91
|
+
* that sum IS the request's cost, and a cached token can carry its own — lower
|
|
92
|
+
* — price. Under the nested reading the same sum charges the cached and
|
|
93
|
+
* reasoning tokens twice: once inside their parent and once on their own line.
|
|
94
|
+
* It fails silently, because every total still looks plausible and the receipt
|
|
95
|
+
* is still internally consistent, and on a reasoning model the reasoning tokens
|
|
96
|
+
* can dominate the completion, so the error is not marginal.
|
|
97
|
+
*
|
|
98
|
+
* **Every OpenAI-compatible provider reports the other way round**:
|
|
99
|
+
* `prompt_tokens` INCLUDES `prompt_tokens_details.cached_tokens`, and
|
|
100
|
+
* `completion_tokens` INCLUDES `completion_tokens_details.reasoning_tokens`.
|
|
101
|
+
* Normalising is the data plane's job and it is subtraction:
|
|
102
|
+
*
|
|
103
|
+
* ```text
|
|
104
|
+
* input_tokens = prompt_tokens - prompt_tokens_details.cached_tokens
|
|
105
|
+
* output_tokens = completion_tokens - completion_tokens_details.reasoning_tokens
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* No refinement in this package can enforce it, and saying so is part of the
|
|
109
|
+
* rule: a nested report and a disjoint one are the same four non-negative
|
|
110
|
+
* integers, so no predicate over a single report can tell them apart. The two
|
|
111
|
+
* structural guards that DO exist — refining `cached <= input` and
|
|
112
|
+
* `reasoning <= output`, or deriving the parents instead of reporting them —
|
|
113
|
+
* both encode the nested reading, which is the one this rule rejects. What IS
|
|
114
|
+
* enforceable is the arithmetic that depends on the rule, and that is where the
|
|
115
|
+
* enforcement lives — `inferenceLedger.service.test.ts` prices a report in
|
|
116
|
+
* which cached and reasoning tokens are both non-zero and asserts the exact
|
|
117
|
+
* total, which the nested reading cannot produce.
|
|
118
|
+
*
|
|
119
|
+
* Where the public surface has to speak a nested dialect, the sum is put back
|
|
120
|
+
* at the boundary rather than the internal reading being bent to it
|
|
121
|
+
* (`routes/inferenceEdge.ts` renders `prompt_tokens` as
|
|
122
|
+
* `input_tokens + cached_input_tokens`).
|
|
123
|
+
*
|
|
81
124
|
* Time is carried in integer MILLISECONDS rather than seconds so that no unit
|
|
82
125
|
* quantity is ever fractional: a 12.5-second transcription is `12500`, exactly,
|
|
83
126
|
* and the "units are integers" rule holds for every modality instead of holding
|
|
@@ -345,7 +345,7 @@ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
|
|
|
345
345
|
/** Carries its own `schemaVersion`: the same body is returned non-streaming. */
|
|
346
346
|
error: z.ZodEffects<z.ZodObject<{
|
|
347
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", "service_unavailable", "internal_error"]>;
|
|
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", "provider_billing_refused", "service_unavailable", "internal_error"]>;
|
|
349
349
|
message: z.ZodEffects<z.ZodString, string, string>;
|
|
350
350
|
retryable: z.ZodBoolean;
|
|
351
351
|
requestId: z.ZodString;
|
|
@@ -369,7 +369,7 @@ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
|
|
|
369
369
|
status?: number | undefined;
|
|
370
370
|
}>>;
|
|
371
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" | "service_unavailable" | "internal_error";
|
|
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" | "provider_billing_refused" | "service_unavailable" | "internal_error";
|
|
373
373
|
message: string;
|
|
374
374
|
requestId: string;
|
|
375
375
|
schemaVersion: 1;
|
|
@@ -384,7 +384,7 @@ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
|
|
|
384
384
|
status?: number | undefined;
|
|
385
385
|
} | undefined;
|
|
386
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" | "service_unavailable" | "internal_error";
|
|
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" | "provider_billing_refused" | "service_unavailable" | "internal_error";
|
|
388
388
|
message: string;
|
|
389
389
|
requestId: string;
|
|
390
390
|
schemaVersion: 1;
|
|
@@ -399,7 +399,7 @@ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
|
|
|
399
399
|
status?: number | undefined;
|
|
400
400
|
} | undefined;
|
|
401
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" | "service_unavailable" | "internal_error";
|
|
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" | "provider_billing_refused" | "service_unavailable" | "internal_error";
|
|
403
403
|
message: string;
|
|
404
404
|
requestId: string;
|
|
405
405
|
schemaVersion: 1;
|
|
@@ -414,7 +414,7 @@ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
|
|
|
414
414
|
status?: number | undefined;
|
|
415
415
|
} | undefined;
|
|
416
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" | "service_unavailable" | "internal_error";
|
|
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" | "provider_billing_refused" | "service_unavailable" | "internal_error";
|
|
418
418
|
message: string;
|
|
419
419
|
requestId: string;
|
|
420
420
|
schemaVersion: 1;
|
|
@@ -435,7 +435,7 @@ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
|
|
|
435
435
|
schemaVersion: 1;
|
|
436
436
|
sequence: number;
|
|
437
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" | "service_unavailable" | "internal_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" | "provider_billing_refused" | "service_unavailable" | "internal_error";
|
|
439
439
|
message: string;
|
|
440
440
|
requestId: string;
|
|
441
441
|
schemaVersion: 1;
|
|
@@ -456,7 +456,7 @@ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
|
|
|
456
456
|
schemaVersion: 1;
|
|
457
457
|
sequence: number;
|
|
458
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" | "service_unavailable" | "internal_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" | "provider_billing_refused" | "service_unavailable" | "internal_error";
|
|
460
460
|
message: string;
|
|
461
461
|
requestId: string;
|
|
462
462
|
schemaVersion: 1;
|
|
@@ -472,8 +472,17 @@ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
|
|
|
472
472
|
} | undefined;
|
|
473
473
|
};
|
|
474
474
|
}>;
|
|
475
|
-
/**
|
|
476
|
-
|
|
475
|
+
/**
|
|
476
|
+
* Why generation stopped.
|
|
477
|
+
*
|
|
478
|
+
* `refusal` and `content_filter` are separate members because they are separate
|
|
479
|
+
* events: the MODEL declining to answer is a property of the answer, while a
|
|
480
|
+
* filter is an upstream system removing one. The delta channels already carry
|
|
481
|
+
* that distinction (`channel: 'refusal'` beside the filter's own error code),
|
|
482
|
+
* so collapsing it here would have made the terminal event less specific than
|
|
483
|
+
* the stream that produced it.
|
|
484
|
+
*/
|
|
485
|
+
export declare const inferenceFinishReasonSchema: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "refusal", "cancelled"]>;
|
|
477
486
|
/**
|
|
478
487
|
* The successful terminal event.
|
|
479
488
|
*
|
|
@@ -487,7 +496,7 @@ export declare const inferenceStreamDoneEventSchema: z.ZodObject<{
|
|
|
487
496
|
requestId: z.ZodString;
|
|
488
497
|
sequence: z.ZodNumber;
|
|
489
498
|
generationId: z.ZodOptional<z.ZodString>;
|
|
490
|
-
finishReason: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "cancelled"]>;
|
|
499
|
+
finishReason: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "refusal", "cancelled"]>;
|
|
491
500
|
receiptId: z.ZodOptional<z.ZodString>;
|
|
492
501
|
completedAt: z.ZodString;
|
|
493
502
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -495,7 +504,7 @@ export declare const inferenceStreamDoneEventSchema: z.ZodObject<{
|
|
|
495
504
|
requestId: string;
|
|
496
505
|
schemaVersion: 1;
|
|
497
506
|
sequence: number;
|
|
498
|
-
finishReason: "length" | "cancelled" | "content_filter" | "stop" | "tool_calls";
|
|
507
|
+
finishReason: "length" | "cancelled" | "content_filter" | "refusal" | "stop" | "tool_calls";
|
|
499
508
|
completedAt: string;
|
|
500
509
|
generationId?: string | undefined;
|
|
501
510
|
receiptId?: string | undefined;
|
|
@@ -504,7 +513,7 @@ export declare const inferenceStreamDoneEventSchema: z.ZodObject<{
|
|
|
504
513
|
requestId: string;
|
|
505
514
|
schemaVersion: 1;
|
|
506
515
|
sequence: number;
|
|
507
|
-
finishReason: "length" | "cancelled" | "content_filter" | "stop" | "tool_calls";
|
|
516
|
+
finishReason: "length" | "cancelled" | "content_filter" | "refusal" | "stop" | "tool_calls";
|
|
508
517
|
completedAt: string;
|
|
509
518
|
generationId?: string | undefined;
|
|
510
519
|
receiptId?: string | undefined;
|
|
@@ -738,7 +747,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
738
747
|
/** Carries its own `schemaVersion`: the same body is returned non-streaming. */
|
|
739
748
|
error: z.ZodEffects<z.ZodObject<{
|
|
740
749
|
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", "service_unavailable", "internal_error"]>;
|
|
750
|
+
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"]>;
|
|
742
751
|
message: z.ZodEffects<z.ZodString, string, string>;
|
|
743
752
|
retryable: z.ZodBoolean;
|
|
744
753
|
requestId: z.ZodString;
|
|
@@ -762,7 +771,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
762
771
|
status?: number | undefined;
|
|
763
772
|
}>>;
|
|
764
773
|
}, "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" | "service_unavailable" | "internal_error";
|
|
774
|
+
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";
|
|
766
775
|
message: string;
|
|
767
776
|
requestId: string;
|
|
768
777
|
schemaVersion: 1;
|
|
@@ -777,7 +786,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
777
786
|
status?: number | undefined;
|
|
778
787
|
} | undefined;
|
|
779
788
|
}, {
|
|
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" | "service_unavailable" | "internal_error";
|
|
789
|
+
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";
|
|
781
790
|
message: string;
|
|
782
791
|
requestId: string;
|
|
783
792
|
schemaVersion: 1;
|
|
@@ -792,7 +801,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
792
801
|
status?: number | undefined;
|
|
793
802
|
} | undefined;
|
|
794
803
|
}>, {
|
|
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" | "service_unavailable" | "internal_error";
|
|
804
|
+
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";
|
|
796
805
|
message: string;
|
|
797
806
|
requestId: string;
|
|
798
807
|
schemaVersion: 1;
|
|
@@ -807,7 +816,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
807
816
|
status?: number | undefined;
|
|
808
817
|
} | undefined;
|
|
809
818
|
}, {
|
|
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" | "service_unavailable" | "internal_error";
|
|
819
|
+
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";
|
|
811
820
|
message: string;
|
|
812
821
|
requestId: string;
|
|
813
822
|
schemaVersion: 1;
|
|
@@ -828,7 +837,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
828
837
|
schemaVersion: 1;
|
|
829
838
|
sequence: number;
|
|
830
839
|
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" | "service_unavailable" | "internal_error";
|
|
840
|
+
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";
|
|
832
841
|
message: string;
|
|
833
842
|
requestId: string;
|
|
834
843
|
schemaVersion: 1;
|
|
@@ -849,7 +858,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
849
858
|
schemaVersion: 1;
|
|
850
859
|
sequence: number;
|
|
851
860
|
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" | "service_unavailable" | "internal_error";
|
|
861
|
+
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";
|
|
853
862
|
message: string;
|
|
854
863
|
requestId: string;
|
|
855
864
|
schemaVersion: 1;
|
|
@@ -871,7 +880,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
871
880
|
requestId: z.ZodString;
|
|
872
881
|
sequence: z.ZodNumber;
|
|
873
882
|
generationId: z.ZodOptional<z.ZodString>;
|
|
874
|
-
finishReason: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "cancelled"]>;
|
|
883
|
+
finishReason: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "refusal", "cancelled"]>;
|
|
875
884
|
receiptId: z.ZodOptional<z.ZodString>;
|
|
876
885
|
completedAt: z.ZodString;
|
|
877
886
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -879,7 +888,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
879
888
|
requestId: string;
|
|
880
889
|
schemaVersion: 1;
|
|
881
890
|
sequence: number;
|
|
882
|
-
finishReason: "length" | "cancelled" | "content_filter" | "stop" | "tool_calls";
|
|
891
|
+
finishReason: "length" | "cancelled" | "content_filter" | "refusal" | "stop" | "tool_calls";
|
|
883
892
|
completedAt: string;
|
|
884
893
|
generationId?: string | undefined;
|
|
885
894
|
receiptId?: string | undefined;
|
|
@@ -888,7 +897,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
888
897
|
requestId: string;
|
|
889
898
|
schemaVersion: 1;
|
|
890
899
|
sequence: number;
|
|
891
|
-
finishReason: "length" | "cancelled" | "content_filter" | "stop" | "tool_calls";
|
|
900
|
+
finishReason: "length" | "cancelled" | "content_filter" | "refusal" | "stop" | "tool_calls";
|
|
892
901
|
completedAt: string;
|
|
893
902
|
generationId?: string | undefined;
|
|
894
903
|
receiptId?: string | undefined;
|
|
@@ -370,6 +370,12 @@ export declare const inferenceRequestOutcomeSchema: z.ZodEnum<["completed", "par
|
|
|
370
370
|
* `usageSource` is load-bearing when a provider returns no usage at all: the
|
|
371
371
|
* report still arrives, marked `estimated`, so settlement can apply the
|
|
372
372
|
* estimation policy knowingly instead of treating a reconstruction as fact.
|
|
373
|
+
*
|
|
374
|
+
* `units` is a PARTITION of what the request consumed, not a set of totals with
|
|
375
|
+
* details hanging off them — see `USAGE_UNITS` in `money.ts`. Reporting a provider's
|
|
376
|
+
* nested `prompt_tokens`/`completion_tokens` verbatim charges the cached and
|
|
377
|
+
* reasoning tokens twice, so subtracting the children out is part of what
|
|
378
|
+
* "normalized" means in this shape's name.
|
|
373
379
|
*/
|
|
374
380
|
export declare const normalizedUsageReportSchema: z.ZodEffects<z.ZodObject<{
|
|
375
381
|
/** See `version.ts`: emitted by the data plane as a whole message. */
|
|
@@ -34,6 +34,34 @@
|
|
|
34
34
|
* field is additive and does not bump it, because a consumer on the previous
|
|
35
35
|
* version parses the message correctly and simply does not read the new field.
|
|
36
36
|
*
|
|
37
|
+
* ## Which shapes reject an unknown field
|
|
38
|
+
*
|
|
39
|
+
* That last rule is why the shapes EXCHANGED WITH THE DATA PLANE are not
|
|
40
|
+
* `.strict()` at their top level — the request envelope, the four usage records,
|
|
41
|
+
* the stream events, the error body, the catalogue descriptors, the price
|
|
42
|
+
* version. The split is a decision rather than an omission: `.strict()` and
|
|
43
|
+
* "adding an optional field is additive" cannot both hold on one shape, because
|
|
44
|
+
* a producer one minor version ahead would have its whole message REFUSED
|
|
45
|
+
* rather than its new field ignored. For a usage report that means a request
|
|
46
|
+
* already served upstream can never be settled and Oxy absorbs its cost, which
|
|
47
|
+
* is a worse failure than the one strictness would have caught.
|
|
48
|
+
*
|
|
49
|
+
* Their LEAVES are strict, and that is where the protection lives: a stripped
|
|
50
|
+
* field is the worse outcome exactly where it would be a leak or a second
|
|
51
|
+
* source of truth, because it disappears at this parse and survives in the
|
|
52
|
+
* producer, which is where somebody eventually reads it. So
|
|
53
|
+
* `clientRequestMetadataSchema` (no IP, ever), `moneySchema` (no convenience
|
|
54
|
+
* float beside the exact decimal), `providerErrorPassthroughSchema` (no
|
|
55
|
+
* upstream request or headers beside the message), `usageQuantitySchema` and
|
|
56
|
+
* `unitPriceSchema` all refuse an unknown field, while the envelope carrying
|
|
57
|
+
* them tolerates an additive one.
|
|
58
|
+
*
|
|
59
|
+
* A shape Oxy does NOT exchange with the data plane is strict at its top level
|
|
60
|
+
* too, since nothing there can run ahead of this package:
|
|
61
|
+
* `providerConnectionSchema`, where an unknown field is how a BYOK credential
|
|
62
|
+
* escapes, and the billing and entitlement records, where one is a second
|
|
63
|
+
* number beside an exact amount.
|
|
64
|
+
*
|
|
37
65
|
* Decided in: docs/adr/0006-oxy-relay-boundary.md, docs/adr/0010-public-api-compatibility.md.
|
|
38
66
|
*/
|
|
39
67
|
/**
|
|
@@ -43,12 +71,19 @@
|
|
|
43
71
|
*
|
|
44
72
|
* MAJOR is bumped when any individual shape's `schemaVersion` increments (at
|
|
45
73
|
* least one message is now read differently by the two sides); MINOR when a
|
|
46
|
-
* shape or an optional field is added
|
|
47
|
-
*
|
|
74
|
+
* shape or an optional field is added, when a CLOSED ENUM gains a member, or
|
|
75
|
+
* when a refinement changes which bytes parse; PATCH for documentation-only
|
|
76
|
+
* changes that leave every parsed byte identical.
|
|
77
|
+
*
|
|
78
|
+
* The last two are MINOR rather than PATCH because both produce the same
|
|
79
|
+
* failure: a producer on the newer set emits something the older set refuses,
|
|
80
|
+
* with no `schemaVersion` difference to explain it. A new enum member and a
|
|
81
|
+
* loosened refinement are exactly what the handshake exists to surface — a
|
|
82
|
+
* skew the per-message version cannot express.
|
|
48
83
|
*
|
|
49
84
|
* This constant is deliberately NOT embedded in the request envelope. Pinning a
|
|
50
85
|
* request to the version of the whole set would make an unrelated additive
|
|
51
86
|
* change to, say, the catalogue reject every in-flight inference request; the
|
|
52
87
|
* per-shape `schemaVersion` is what a message is validated against.
|
|
53
88
|
*/
|
|
54
|
-
export declare const INFERENCE_CONTRACT_VERSION = "1.
|
|
89
|
+
export declare const INFERENCE_CONTRACT_VERSION = "1.1.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxyhq/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "OxyHQ API contracts — single source of truth for request/response Zod schemas and inferred types, shared by the backend and the client SDKs",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|