@oxyhq/contracts 0.27.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/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 +15 -0
- package/dist/cjs/inference/identifiers.js +11 -3
- package/dist/cjs/inference/money.js +43 -0
- package/dist/cjs/inference/usage.js +6 -0
- package/dist/cjs/inference/version.js +28 -0
- 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 +15 -0
- package/dist/esm/inference/identifiers.js +11 -3
- package/dist/esm/inference/money.js +43 -0
- package/dist/esm/inference/usage.js +6 -0
- package/dist/esm/inference/version.js +28 -0
- 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 +21 -8
- 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 +14 -14
- package/dist/types/inference/usage.d.ts +6 -0
- package/dist/types/inference/version.d.ts +28 -0
- package/package.json +1 -1
|
@@ -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", "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" | "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" | "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" | "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" | "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" | "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" | "service_unavailable" | "internal_error";
|
|
460
460
|
message: string;
|
|
461
461
|
requestId: string;
|
|
462
462
|
schemaVersion: 1;
|
|
@@ -738,7 +738,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
738
738
|
/** Carries its own `schemaVersion`: the same body is returned non-streaming. */
|
|
739
739
|
error: z.ZodEffects<z.ZodObject<{
|
|
740
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", "service_unavailable", "internal_error"]>;
|
|
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
742
|
message: z.ZodEffects<z.ZodString, string, string>;
|
|
743
743
|
retryable: z.ZodBoolean;
|
|
744
744
|
requestId: z.ZodString;
|
|
@@ -762,7 +762,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
762
762
|
status?: number | undefined;
|
|
763
763
|
}>>;
|
|
764
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" | "service_unavailable" | "internal_error";
|
|
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
766
|
message: string;
|
|
767
767
|
requestId: string;
|
|
768
768
|
schemaVersion: 1;
|
|
@@ -777,7 +777,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
777
777
|
status?: number | undefined;
|
|
778
778
|
} | undefined;
|
|
779
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" | "service_unavailable" | "internal_error";
|
|
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
781
|
message: string;
|
|
782
782
|
requestId: string;
|
|
783
783
|
schemaVersion: 1;
|
|
@@ -792,7 +792,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
792
792
|
status?: number | undefined;
|
|
793
793
|
} | undefined;
|
|
794
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" | "service_unavailable" | "internal_error";
|
|
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
796
|
message: string;
|
|
797
797
|
requestId: string;
|
|
798
798
|
schemaVersion: 1;
|
|
@@ -807,7 +807,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
807
807
|
status?: number | undefined;
|
|
808
808
|
} | undefined;
|
|
809
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" | "service_unavailable" | "internal_error";
|
|
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
811
|
message: string;
|
|
812
812
|
requestId: string;
|
|
813
813
|
schemaVersion: 1;
|
|
@@ -828,7 +828,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
828
828
|
schemaVersion: 1;
|
|
829
829
|
sequence: number;
|
|
830
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" | "service_unavailable" | "internal_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
832
|
message: string;
|
|
833
833
|
requestId: string;
|
|
834
834
|
schemaVersion: 1;
|
|
@@ -849,7 +849,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
849
849
|
schemaVersion: 1;
|
|
850
850
|
sequence: number;
|
|
851
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" | "service_unavailable" | "internal_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
853
|
message: string;
|
|
854
854
|
requestId: string;
|
|
855
855
|
schemaVersion: 1;
|
|
@@ -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
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxyhq/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.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",
|