@oxy.so/contracts 4.3.0 → 4.4.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 +71 -4
- package/dist/cjs/inference/catalogue.js +105 -2
- package/dist/cjs/inference/money.js +23 -0
- package/dist/cjs/inference/realtime.js +826 -0
- package/dist/cjs/inference/request.js +34 -11
- package/dist/cjs/inference/streamEvents.js +7 -1
- package/dist/cjs/inference/version.js +1 -1
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/index.js +5 -2
- package/dist/esm/inference/catalogue.js +104 -1
- package/dist/esm/inference/money.js +23 -0
- package/dist/esm/inference/realtime.js +822 -0
- package/dist/esm/inference/request.js +34 -11
- package/dist/esm/inference/streamEvents.js +7 -1
- package/dist/esm/inference/version.js +1 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +6 -4
- package/dist/types/inference/catalogue.d.ts +299 -10
- package/dist/types/inference/entitlement.d.ts +6 -6
- package/dist/types/inference/inbox.d.ts +2 -2
- package/dist/types/inference/modelDocumentation.d.ts +146 -2
- package/dist/types/inference/money.d.ts +28 -8
- package/dist/types/inference/priceVersion.d.ts +12 -12
- package/dist/types/inference/realtime.d.ts +8012 -0
- package/dist/types/inference/request.d.ts +51 -0
- package/dist/types/inference/routingPolicy.d.ts +7 -7
- package/dist/types/inference/streamEvents.d.ts +28 -16
- package/dist/types/inference/usage.d.ts +28 -28
- package/dist/types/inference/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
import { z } from "zod";
|
|
27
27
|
import { inferenceAttributionSchema } from "./attribution.js";
|
|
28
|
-
import { inferenceModalitySchema, reasoningEffortSchema } from "./catalogue.js";
|
|
28
|
+
import { inferenceApiFormatSchema, inferenceModalitySchema, reasoningEffortSchema, } from "./catalogue.js";
|
|
29
29
|
import { idempotencyKeySchema, inferenceTimestampSchema } from "./identifiers.js";
|
|
30
30
|
import { authorizedRouteSchema, routingPolicyReferenceSchema, routingTargetSchema, } from "./routingPolicy.js";
|
|
31
31
|
/* -------------------------------------------------------------------------- */
|
|
@@ -289,16 +289,7 @@ export const inferenceReasoningSchema = z
|
|
|
289
289
|
export const clientRequestMetadataSchema = z
|
|
290
290
|
.object({
|
|
291
291
|
/** The public dialect the customer called. The response is rendered in it. */
|
|
292
|
-
apiFormat:
|
|
293
|
-
"responses",
|
|
294
|
-
"chat_completions",
|
|
295
|
-
"embeddings",
|
|
296
|
-
"images_generations",
|
|
297
|
-
"audio_transcriptions",
|
|
298
|
-
"audio_speech",
|
|
299
|
-
"rerank",
|
|
300
|
-
"batches",
|
|
301
|
-
]),
|
|
292
|
+
apiFormat: inferenceApiFormatSchema,
|
|
302
293
|
/** The public path, e.g. `/v1/responses`. */
|
|
303
294
|
endpoint: z.string().min(1).max(256),
|
|
304
295
|
/** The customer's own correlation id, when they sent one. */
|
|
@@ -327,6 +318,25 @@ export const inferenceSpeechParametersSchema = z.object({
|
|
|
327
318
|
responseFormat: z.enum(["mp3", "opus", "aac", "flac", "wav", "pcm"]),
|
|
328
319
|
speed: z.number().min(0.25).max(4).optional(),
|
|
329
320
|
}).strict();
|
|
321
|
+
/**
|
|
322
|
+
* Spoken output from a CONVERSATIONAL model (contract set 3.2.0) — an audio chat
|
|
323
|
+
* model answering in its own voice, as opposed to `speech`, which reads given
|
|
324
|
+
* text aloud. Presence is the request: a chat request carrying this asks for
|
|
325
|
+
* the answer as audio AND its transcript, which is the only combination the
|
|
326
|
+
* audio chat models produce (OpenAI's `modalities: ["text", "audio"]`).
|
|
327
|
+
*
|
|
328
|
+
* The audio streams as `audio` events and the words as `delta` events on the
|
|
329
|
+
* `output_audio_transcript` channel — never as `output_text`, because a
|
|
330
|
+
* transcript of speech the customer is already hearing is not a second answer.
|
|
331
|
+
* `pcm` is the only format an audio chat model can STREAM; the refinement on the
|
|
332
|
+
* envelope holds that rather than leaving a provider to refuse it mid-flight.
|
|
333
|
+
*/
|
|
334
|
+
export const inferenceAudioOutputParametersSchema = z
|
|
335
|
+
.object({
|
|
336
|
+
voice: z.string().min(1).max(64),
|
|
337
|
+
format: z.enum(["wav", "mp3", "flac", "opus", "pcm"]),
|
|
338
|
+
})
|
|
339
|
+
.strict();
|
|
330
340
|
/**
|
|
331
341
|
* The canonical internal request Oxy forwards to the data plane.
|
|
332
342
|
*
|
|
@@ -349,6 +359,8 @@ export const inferenceRequestSchema = z
|
|
|
349
359
|
/** Absent means the route's own default reasoning behaviour. */
|
|
350
360
|
reasoning: inferenceReasoningSchema.optional(),
|
|
351
361
|
speech: inferenceSpeechParametersSchema.optional(),
|
|
362
|
+
/** Spoken output from a conversational model. Contract set 3.2.0. */
|
|
363
|
+
audioOutput: inferenceAudioOutputParametersSchema.optional(),
|
|
352
364
|
tools: z.array(toolDefinitionSchema).default([]),
|
|
353
365
|
toolChoice: toolChoiceSchema.optional(),
|
|
354
366
|
responseFormat: responseFormatSchema.optional(),
|
|
@@ -398,6 +410,17 @@ export const inferenceRequestSchema = z
|
|
|
398
410
|
if (!isSpeech && request.speech !== undefined) {
|
|
399
411
|
ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["speech"], message: "speech parameters require the audio_speech API format" });
|
|
400
412
|
}
|
|
413
|
+
if (request.audioOutput !== undefined) {
|
|
414
|
+
if (request.client.apiFormat !== "chat_completions") {
|
|
415
|
+
ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["audioOutput"], message: "spoken output from a conversational model requires the chat_completions API format" });
|
|
416
|
+
}
|
|
417
|
+
if (request.modality !== "audio" || request.input.format !== "messages") {
|
|
418
|
+
ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["audioOutput"], message: "spoken output requires audio modality and a messages input" });
|
|
419
|
+
}
|
|
420
|
+
if (request.stream && request.audioOutput.format !== "pcm") {
|
|
421
|
+
ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["audioOutput", "format"], message: "streamed spoken output is pcm; the other formats exist only whole" });
|
|
422
|
+
}
|
|
423
|
+
}
|
|
401
424
|
if (request.toolChoice !== undefined && request.tools.length === 0) {
|
|
402
425
|
ctx.addIssue({
|
|
403
426
|
code: z.ZodIssueCode.custom,
|
|
@@ -59,7 +59,13 @@ export const inferenceStreamDeltaEventSchema = z.object({
|
|
|
59
59
|
sequence: z.number().int().nonnegative().safe(),
|
|
60
60
|
/** Which output of a multi-output response this chunk belongs to. */
|
|
61
61
|
outputIndex: z.number().int().nonnegative().safe(),
|
|
62
|
-
|
|
62
|
+
/**
|
|
63
|
+
* `output_audio_transcript` (contract set 3.2.0) carries the words of spoken
|
|
64
|
+
* output requested with `audioOutput`. It is its own channel for the same
|
|
65
|
+
* reason `reasoning` is: a renderer that shows it as `output_text` presents
|
|
66
|
+
* the transcript of what the customer is hearing as a second, written answer.
|
|
67
|
+
*/
|
|
68
|
+
channel: z.enum(['output_text', 'reasoning', 'refusal', 'output_audio_transcript']),
|
|
63
69
|
text: z.string(),
|
|
64
70
|
});
|
|
65
71
|
/** The encodings an audio output may carry. */
|
|
@@ -99,4 +99,4 @@
|
|
|
99
99
|
* change to, say, the catalogue reject every in-flight inference request; the
|
|
100
100
|
* per-shape `schemaVersion` is what a message is validated against.
|
|
101
101
|
*/
|
|
102
|
-
export const INFERENCE_CONTRACT_VERSION = '3.
|
|
102
|
+
export const INFERENCE_CONTRACT_VERSION = '3.2.0';
|