@kaana.ai/contracts 4.4.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -112,6 +112,50 @@ export declare const catalogueModelSchema: z.ZodObject<{
112
112
  g711_alaw: "g711_alaw";
113
113
  }>>;
114
114
  }, z.core.$strict>>;
115
+ parameters: z.ZodOptional<z.ZodObject<{
116
+ turnDetection: z.ZodArray<z.ZodObject<{
117
+ type: z.ZodEnum<{
118
+ none: "none";
119
+ server_vad: "server_vad";
120
+ semantic_vad: "semantic_vad";
121
+ }>;
122
+ fixedResponses: z.ZodBoolean;
123
+ threshold: z.ZodOptional<z.ZodObject<{
124
+ min: z.ZodNumber;
125
+ max: z.ZodNumber;
126
+ }, z.core.$strict>>;
127
+ meteredUnits: z.ZodArray<z.ZodEnum<{
128
+ input_tokens: "input_tokens";
129
+ cached_input_tokens: "cached_input_tokens";
130
+ output_tokens: "output_tokens";
131
+ reasoning_tokens: "reasoning_tokens";
132
+ requests: "requests";
133
+ images: "images";
134
+ audio_input_milliseconds: "audio_input_milliseconds";
135
+ audio_output_milliseconds: "audio_output_milliseconds";
136
+ video_milliseconds: "video_milliseconds";
137
+ characters: "characters";
138
+ embeddings: "embeddings";
139
+ audio_input_tokens: "audio_input_tokens";
140
+ cached_audio_input_tokens: "cached_audio_input_tokens";
141
+ audio_output_tokens: "audio_output_tokens";
142
+ session_milliseconds: "session_milliseconds";
143
+ input_transcription_milliseconds: "input_transcription_milliseconds";
144
+ }>>;
145
+ }, z.core.$strict>>;
146
+ outputModalities: z.ZodArray<z.ZodArray<z.ZodEnum<{
147
+ text: "text";
148
+ audio: "audio";
149
+ }>>>;
150
+ toolChoice: z.ZodArray<z.ZodEnum<{
151
+ function: "function";
152
+ none: "none";
153
+ auto: "auto";
154
+ required: "required";
155
+ }>>;
156
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
157
+ inputTranscriptionPrompt: z.ZodBoolean;
158
+ }, z.core.$strict>>;
115
159
  }, z.core.$strict>>;
116
160
  }, z.core.$strict>;
117
161
  license: z.ZodObject<{
@@ -465,6 +509,50 @@ export declare const modelCatalogueEntrySchema: z.ZodObject<{
465
509
  g711_alaw: "g711_alaw";
466
510
  }>>;
467
511
  }, z.core.$strict>>;
512
+ parameters: z.ZodOptional<z.ZodObject<{
513
+ turnDetection: z.ZodArray<z.ZodObject<{
514
+ type: z.ZodEnum<{
515
+ none: "none";
516
+ server_vad: "server_vad";
517
+ semantic_vad: "semantic_vad";
518
+ }>;
519
+ fixedResponses: z.ZodBoolean;
520
+ threshold: z.ZodOptional<z.ZodObject<{
521
+ min: z.ZodNumber;
522
+ max: z.ZodNumber;
523
+ }, z.core.$strict>>;
524
+ meteredUnits: z.ZodArray<z.ZodEnum<{
525
+ input_tokens: "input_tokens";
526
+ cached_input_tokens: "cached_input_tokens";
527
+ output_tokens: "output_tokens";
528
+ reasoning_tokens: "reasoning_tokens";
529
+ requests: "requests";
530
+ images: "images";
531
+ audio_input_milliseconds: "audio_input_milliseconds";
532
+ audio_output_milliseconds: "audio_output_milliseconds";
533
+ video_milliseconds: "video_milliseconds";
534
+ characters: "characters";
535
+ embeddings: "embeddings";
536
+ audio_input_tokens: "audio_input_tokens";
537
+ cached_audio_input_tokens: "cached_audio_input_tokens";
538
+ audio_output_tokens: "audio_output_tokens";
539
+ session_milliseconds: "session_milliseconds";
540
+ input_transcription_milliseconds: "input_transcription_milliseconds";
541
+ }>>;
542
+ }, z.core.$strict>>;
543
+ outputModalities: z.ZodArray<z.ZodArray<z.ZodEnum<{
544
+ text: "text";
545
+ audio: "audio";
546
+ }>>>;
547
+ toolChoice: z.ZodArray<z.ZodEnum<{
548
+ function: "function";
549
+ none: "none";
550
+ auto: "auto";
551
+ required: "required";
552
+ }>>;
553
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
554
+ inputTranscriptionPrompt: z.ZodBoolean;
555
+ }, z.core.$strict>>;
468
556
  }, z.core.$strict>>;
469
557
  }, z.core.$strict>;
470
558
  license: z.ZodObject<{
@@ -617,6 +705,8 @@ export declare const declaredModelSchema: z.ZodObject<{
617
705
  }>>;
618
706
  }, z.core.$strict>>;
619
707
  languages: z.ZodArray<z.ZodString>;
708
+ detectsLanguage: z.ZodOptional<z.ZodBoolean>;
709
+ transcriptionPrompt: z.ZodOptional<z.ZodBoolean>;
620
710
  audioFormats: z.ZodObject<{
621
711
  input: z.ZodArray<z.ZodEnum<{
622
712
  "audio/mpeg": "audio/mpeg";
@@ -713,6 +803,50 @@ export declare const declaredModelSchema: z.ZodObject<{
713
803
  g711_alaw: "g711_alaw";
714
804
  }>>;
715
805
  }, z.core.$strict>>;
806
+ parameters: z.ZodOptional<z.ZodObject<{
807
+ turnDetection: z.ZodArray<z.ZodObject<{
808
+ type: z.ZodEnum<{
809
+ none: "none";
810
+ server_vad: "server_vad";
811
+ semantic_vad: "semantic_vad";
812
+ }>;
813
+ fixedResponses: z.ZodBoolean;
814
+ threshold: z.ZodOptional<z.ZodObject<{
815
+ min: z.ZodNumber;
816
+ max: z.ZodNumber;
817
+ }, z.core.$strict>>;
818
+ meteredUnits: z.ZodArray<z.ZodEnum<{
819
+ input_tokens: "input_tokens";
820
+ cached_input_tokens: "cached_input_tokens";
821
+ output_tokens: "output_tokens";
822
+ reasoning_tokens: "reasoning_tokens";
823
+ requests: "requests";
824
+ images: "images";
825
+ audio_input_milliseconds: "audio_input_milliseconds";
826
+ audio_output_milliseconds: "audio_output_milliseconds";
827
+ video_milliseconds: "video_milliseconds";
828
+ characters: "characters";
829
+ embeddings: "embeddings";
830
+ audio_input_tokens: "audio_input_tokens";
831
+ cached_audio_input_tokens: "cached_audio_input_tokens";
832
+ audio_output_tokens: "audio_output_tokens";
833
+ session_milliseconds: "session_milliseconds";
834
+ input_transcription_milliseconds: "input_transcription_milliseconds";
835
+ }>>;
836
+ }, z.core.$strict>>;
837
+ outputModalities: z.ZodArray<z.ZodArray<z.ZodEnum<{
838
+ text: "text";
839
+ audio: "audio";
840
+ }>>>;
841
+ toolChoice: z.ZodArray<z.ZodEnum<{
842
+ function: "function";
843
+ none: "none";
844
+ auto: "auto";
845
+ required: "required";
846
+ }>>;
847
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
848
+ inputTranscriptionPrompt: z.ZodBoolean;
849
+ }, z.core.$strict>>;
716
850
  }, z.core.$strict>>;
717
851
  }, z.core.$strict>;
718
852
  license: z.ZodObject<{
@@ -841,6 +975,8 @@ export declare const declaredCatalogueSchema: z.ZodObject<{
841
975
  }>>;
842
976
  }, z.core.$strict>>;
843
977
  languages: z.ZodArray<z.ZodString>;
978
+ detectsLanguage: z.ZodOptional<z.ZodBoolean>;
979
+ transcriptionPrompt: z.ZodOptional<z.ZodBoolean>;
844
980
  audioFormats: z.ZodObject<{
845
981
  input: z.ZodArray<z.ZodEnum<{
846
982
  "audio/mpeg": "audio/mpeg";
@@ -937,6 +1073,50 @@ export declare const declaredCatalogueSchema: z.ZodObject<{
937
1073
  g711_alaw: "g711_alaw";
938
1074
  }>>;
939
1075
  }, z.core.$strict>>;
1076
+ parameters: z.ZodOptional<z.ZodObject<{
1077
+ turnDetection: z.ZodArray<z.ZodObject<{
1078
+ type: z.ZodEnum<{
1079
+ none: "none";
1080
+ server_vad: "server_vad";
1081
+ semantic_vad: "semantic_vad";
1082
+ }>;
1083
+ fixedResponses: z.ZodBoolean;
1084
+ threshold: z.ZodOptional<z.ZodObject<{
1085
+ min: z.ZodNumber;
1086
+ max: z.ZodNumber;
1087
+ }, z.core.$strict>>;
1088
+ meteredUnits: z.ZodArray<z.ZodEnum<{
1089
+ input_tokens: "input_tokens";
1090
+ cached_input_tokens: "cached_input_tokens";
1091
+ output_tokens: "output_tokens";
1092
+ reasoning_tokens: "reasoning_tokens";
1093
+ requests: "requests";
1094
+ images: "images";
1095
+ audio_input_milliseconds: "audio_input_milliseconds";
1096
+ audio_output_milliseconds: "audio_output_milliseconds";
1097
+ video_milliseconds: "video_milliseconds";
1098
+ characters: "characters";
1099
+ embeddings: "embeddings";
1100
+ audio_input_tokens: "audio_input_tokens";
1101
+ cached_audio_input_tokens: "cached_audio_input_tokens";
1102
+ audio_output_tokens: "audio_output_tokens";
1103
+ session_milliseconds: "session_milliseconds";
1104
+ input_transcription_milliseconds: "input_transcription_milliseconds";
1105
+ }>>;
1106
+ }, z.core.$strict>>;
1107
+ outputModalities: z.ZodArray<z.ZodArray<z.ZodEnum<{
1108
+ text: "text";
1109
+ audio: "audio";
1110
+ }>>>;
1111
+ toolChoice: z.ZodArray<z.ZodEnum<{
1112
+ function: "function";
1113
+ none: "none";
1114
+ auto: "auto";
1115
+ required: "required";
1116
+ }>>;
1117
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
1118
+ inputTranscriptionPrompt: z.ZodBoolean;
1119
+ }, z.core.$strict>>;
940
1120
  }, z.core.$strict>>;
941
1121
  }, z.core.$strict>;
942
1122
  license: z.ZodObject<{
@@ -102,19 +102,17 @@ export declare const realtimeSessionRequestSchema: z.ZodObject<{
102
102
  tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
103
103
  type: z.ZodLiteral<"function">;
104
104
  name: z.ZodString;
105
- description: z.ZodOptional<z.ZodString>;
106
105
  parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
107
- strict: z.ZodOptional<z.ZodBoolean>;
106
+ description: z.ZodOptional<z.ZodString>;
108
107
  }, z.core.$strict>>>;
109
108
  toolChoice: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
110
- auto: "auto";
111
109
  none: "none";
110
+ auto: "auto";
112
111
  required: "required";
113
112
  }>, z.ZodObject<{
114
113
  type: z.ZodLiteral<"function">;
115
114
  name: z.ZodString;
116
115
  }, z.core.$strict>]>>;
117
- temperature: z.ZodOptional<z.ZodNumber>;
118
116
  maxOutputTokens: z.ZodOptional<z.ZodNumber>;
119
117
  }, z.core.$strict>;
120
118
  limits: z.ZodObject<{
@@ -244,19 +242,17 @@ export declare const realtimeSessionCreatedEventSchema: z.ZodObject<{
244
242
  tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
245
243
  type: z.ZodLiteral<"function">;
246
244
  name: z.ZodString;
247
- description: z.ZodOptional<z.ZodString>;
248
245
  parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
249
- strict: z.ZodOptional<z.ZodBoolean>;
246
+ description: z.ZodOptional<z.ZodString>;
250
247
  }, z.core.$strict>>>;
251
248
  toolChoice: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
252
- auto: "auto";
253
249
  none: "none";
250
+ auto: "auto";
254
251
  required: "required";
255
252
  }>, z.ZodObject<{
256
253
  type: z.ZodLiteral<"function">;
257
254
  name: z.ZodString;
258
255
  }, z.core.$strict>]>>;
259
- temperature: z.ZodOptional<z.ZodNumber>;
260
256
  maxOutputTokens: z.ZodOptional<z.ZodNumber>;
261
257
  }, z.core.$strict>;
262
258
  limits: z.ZodObject<{
@@ -503,19 +499,17 @@ export declare const realtimeServerEventSchema: z.ZodDiscriminatedUnion<[z.ZodOb
503
499
  tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
504
500
  type: z.ZodLiteral<"function">;
505
501
  name: z.ZodString;
506
- description: z.ZodOptional<z.ZodString>;
507
502
  parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
508
- strict: z.ZodOptional<z.ZodBoolean>;
503
+ description: z.ZodOptional<z.ZodString>;
509
504
  }, z.core.$strict>>>;
510
505
  toolChoice: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
511
- auto: "auto";
512
506
  none: "none";
507
+ auto: "auto";
513
508
  required: "required";
514
509
  }>, z.ZodObject<{
515
510
  type: z.ZodLiteral<"function">;
516
511
  name: z.ZodString;
517
512
  }, z.core.$strict>]>>;
518
- temperature: z.ZodOptional<z.ZodNumber>;
519
513
  maxOutputTokens: z.ZodOptional<z.ZodNumber>;
520
514
  }, z.core.$strict>;
521
515
  limits: z.ZodObject<{
@@ -581,19 +575,17 @@ export declare const realtimeServerEventSchema: z.ZodDiscriminatedUnion<[z.ZodOb
581
575
  tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
582
576
  type: z.ZodLiteral<"function">;
583
577
  name: z.ZodString;
584
- description: z.ZodOptional<z.ZodString>;
585
578
  parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
586
- strict: z.ZodOptional<z.ZodBoolean>;
579
+ description: z.ZodOptional<z.ZodString>;
587
580
  }, z.core.$strict>>>;
588
581
  toolChoice: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
589
- auto: "auto";
590
582
  none: "none";
583
+ auto: "auto";
591
584
  required: "required";
592
585
  }>, z.ZodObject<{
593
586
  type: z.ZodLiteral<"function">;
594
587
  name: z.ZodString;
595
588
  }, z.core.$strict>]>>;
596
- temperature: z.ZodOptional<z.ZodNumber>;
597
589
  maxOutputTokens: z.ZodOptional<z.ZodNumber>;
598
590
  }, z.core.$strict>;
599
591
  schemaVersion: z.ZodLiteral<1>;
@@ -344,6 +344,10 @@ export declare const inferenceRequestSchema: z.ZodObject<{
344
344
  }>;
345
345
  speed: z.ZodOptional<z.ZodNumber>;
346
346
  }, z.core.$strict>>;
347
+ transcription: z.ZodOptional<z.ZodObject<{
348
+ language: z.ZodOptional<z.ZodString>;
349
+ prompt: z.ZodOptional<z.ZodString>;
350
+ }, z.core.$strict>>;
347
351
  audioOutput: z.ZodOptional<z.ZodObject<{
348
352
  voice: z.ZodString;
349
353
  format: z.ZodEnum<{
@@ -362,8 +366,8 @@ export declare const inferenceRequestSchema: z.ZodObject<{
362
366
  strict: z.ZodOptional<z.ZodBoolean>;
363
367
  }, z.core.$strict>>>;
364
368
  toolChoice: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
365
- auto: "auto";
366
369
  none: "none";
370
+ auto: "auto";
367
371
  required: "required";
368
372
  }>, z.ZodObject<{
369
373
  type: z.ZodLiteral<"function">;
@@ -619,6 +623,10 @@ export declare const scopedInferenceRequestSchema: z.ZodObject<{
619
623
  }>;
620
624
  speed: z.ZodOptional<z.ZodNumber>;
621
625
  }, z.core.$strict>>;
626
+ transcription: z.ZodOptional<z.ZodObject<{
627
+ language: z.ZodOptional<z.ZodString>;
628
+ prompt: z.ZodOptional<z.ZodString>;
629
+ }, z.core.$strict>>;
622
630
  audioOutput: z.ZodOptional<z.ZodObject<{
623
631
  voice: z.ZodString;
624
632
  format: z.ZodEnum<{
@@ -637,8 +645,8 @@ export declare const scopedInferenceRequestSchema: z.ZodObject<{
637
645
  strict: z.ZodOptional<z.ZodBoolean>;
638
646
  }, z.core.$strict>>>;
639
647
  toolChoice: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
640
- auto: "auto";
641
648
  none: "none";
649
+ auto: "auto";
642
650
  required: "required";
643
651
  }>, z.ZodObject<{
644
652
  type: z.ZodLiteral<"function">;
@@ -864,6 +872,19 @@ export declare const privateAutoInferenceRequestSchema: z.ZodObject<{
864
872
  high: "high";
865
873
  }>;
866
874
  }, z.core.$strict>>;
875
+ transcription: z.ZodOptional<z.ZodObject<{
876
+ language: z.ZodOptional<z.ZodString>;
877
+ prompt: z.ZodOptional<z.ZodString>;
878
+ }, z.core.$strict>>;
879
+ toolChoice: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
880
+ none: "none";
881
+ auto: "auto";
882
+ required: "required";
883
+ }>, z.ZodObject<{
884
+ type: z.ZodLiteral<"function">;
885
+ name: z.ZodString;
886
+ }, z.core.$strict>]>>;
887
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
867
888
  tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
868
889
  type: z.ZodLiteral<"function">;
869
890
  name: z.ZodString;
@@ -871,7 +892,6 @@ export declare const privateAutoInferenceRequestSchema: z.ZodObject<{
871
892
  parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
872
893
  strict: z.ZodOptional<z.ZodBoolean>;
873
894
  }, z.core.$strict>>>;
874
- maxOutputTokens: z.ZodOptional<z.ZodNumber>;
875
895
  stream: z.ZodBoolean;
876
896
  responseFormat: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
877
897
  type: z.ZodLiteral<"text">;
@@ -883,14 +903,6 @@ export declare const privateAutoInferenceRequestSchema: z.ZodObject<{
883
903
  schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
884
904
  strict: z.ZodBoolean;
885
905
  }, z.core.$strict>], "type">>;
886
- toolChoice: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
887
- auto: "auto";
888
- none: "none";
889
- required: "required";
890
- }>, z.ZodObject<{
891
- type: z.ZodLiteral<"function">;
892
- name: z.ZodString;
893
- }, z.core.$strict>]>>;
894
906
  routingPolicy: z.ZodObject<{
895
907
  routingPolicyId: z.ZodString;
896
908
  policyVersion: z.ZodNumber;
@@ -7,7 +7,7 @@ import { z } from 'zod';
7
7
  import { inferenceApiFormatSchema, inferenceModalitySchema } from '../public/catalogue.js';
8
8
  import { decisionInputSchema } from '../public/decisions.js';
9
9
  import { idempotencyKeySchema, inferenceTimestampSchema } from '../public/identifiers.js';
10
- import { inferenceAudioOutputParametersSchema, inferenceMessageSchema, inferenceReasoningSchema, inferenceSpeechParametersSchema, responseFormatSchema, samplingParametersSchema, toolChoiceSchema, toolDefinitionSchema, } from '../public/messages.js';
10
+ import { inferenceAudioOutputParametersSchema, inferenceMessageSchema, inferenceReasoningSchema, inferenceSpeechParametersSchema, inferenceTranscriptionParametersSchema, responseFormatSchema, samplingParametersSchema, toolChoiceSchema, toolDefinitionSchema, } from '../public/messages.js';
11
11
  import { routingPolicyReferenceSchema } from '../public/policy.js';
12
12
  import { inferenceAttributionSchema } from './attribution.js';
13
13
  import { PRIVATE_AUTO_REQUEST_ENVELOPE_VERSION, privateAutoExecutionSchema, privateAutoInputSchema, } from './privateAutoExecution.js';
@@ -96,6 +96,8 @@ const inferenceRequestObjectSchema = z.object({
96
96
  /** Absent means the route's own default reasoning behaviour. */
97
97
  reasoning: inferenceReasoningSchema.optional(),
98
98
  speech: inferenceSpeechParametersSchema.optional(),
99
+ /** File transcription parameters. Contract set 4.5.0. */
100
+ transcription: inferenceTranscriptionParametersSchema.optional(),
99
101
  /** Spoken output from a conversational model. Contract set 3.2.0. */
100
102
  audioOutput: inferenceAudioOutputParametersSchema.optional(),
101
103
  tools: z.array(toolDefinitionSchema).default([]),
@@ -164,6 +166,7 @@ export const inferenceRequestSchema = inferenceRequestObjectSchema.superRefine((
164
166
  request.responseFormat !== undefined ||
165
167
  request.reasoning !== undefined ||
166
168
  request.speech !== undefined ||
169
+ request.transcription !== undefined ||
167
170
  request.audioOutput !== undefined) {
168
171
  ctx.addIssue({
169
172
  code: 'custom',
@@ -191,6 +194,16 @@ export const inferenceRequestSchema = inferenceRequestObjectSchema.superRefine((
191
194
  message: 'speech parameters require the audio_speech API format',
192
195
  });
193
196
  }
197
+ if (request.transcription !== undefined &&
198
+ (request.client.apiFormat !== 'audio_transcriptions' ||
199
+ request.modality !== 'audio' ||
200
+ request.input.format !== 'messages')) {
201
+ ctx.addIssue({
202
+ code: 'custom',
203
+ path: ['transcription'],
204
+ message: 'transcription parameters require the audio_transcriptions API format with audio messages input',
205
+ });
206
+ }
194
207
  if (request.audioOutput !== undefined) {
195
208
  if (request.client.apiFormat !== 'chat_completions') {
196
209
  ctx.addIssue({
@@ -8,6 +8,7 @@
8
8
  * (decision 9) and transcription are new in contract set 4.0.0.
9
9
  */
10
10
  import { z } from 'zod';
11
+ import { type AudioInputMediaType } from './audioFormats.js';
11
12
  import type { ModelAudioCapabilities } from './catalogue.js';
12
13
  /** The longest text one speech request may carry, before any model's own limit. */
13
14
  export declare const MAX_SPEECH_INPUT_CHARACTERS = 100000;
@@ -248,11 +249,6 @@ export declare const transcriptionRequestSchema: z.ZodObject<{
248
249
  model: z.ZodString;
249
250
  language: z.ZodOptional<z.ZodString>;
250
251
  prompt: z.ZodOptional<z.ZodString>;
251
- timestamps: z.ZodOptional<z.ZodEnum<{
252
- none: "none";
253
- segment: "segment";
254
- word: "word";
255
- }>>;
256
252
  }, z.core.$strict>;
257
253
  /**
258
254
  * The longest audio one transcription request may carry, when its container
@@ -277,11 +273,6 @@ export declare const transcriptionJsonRequestSchema: z.ZodObject<{
277
273
  model: z.ZodString;
278
274
  language: z.ZodOptional<z.ZodString>;
279
275
  prompt: z.ZodOptional<z.ZodString>;
280
- timestamps: z.ZodOptional<z.ZodEnum<{
281
- none: "none";
282
- segment: "segment";
283
- word: "word";
284
- }>>;
285
276
  audio: z.ZodObject<{
286
277
  mediaType: z.ZodEnum<{
287
278
  "audio/mpeg": "audio/mpeg";
@@ -296,7 +287,7 @@ export declare const transcriptionJsonRequestSchema: z.ZodObject<{
296
287
  data: z.ZodString;
297
288
  }, z.core.$strict>;
298
289
  }, z.core.$strict>;
299
- /** The response. Segments or words are present only when the request asked for them. */
290
+ /** The response. */
300
291
  export declare const transcriptionSchema: z.ZodObject<{
301
292
  schemaVersion: z.ZodLiteral<1>;
302
293
  requestId: z.ZodString;
@@ -304,16 +295,6 @@ export declare const transcriptionSchema: z.ZodObject<{
304
295
  text: z.ZodString;
305
296
  language: z.ZodOptional<z.ZodString>;
306
297
  durationMs: z.ZodOptional<z.ZodNumber>;
307
- segments: z.ZodOptional<z.ZodArray<z.ZodObject<{
308
- text: z.ZodString;
309
- startMs: z.ZodNumber;
310
- endMs: z.ZodNumber;
311
- }, z.core.$strict>>>;
312
- words: z.ZodOptional<z.ZodArray<z.ZodObject<{
313
- word: z.ZodString;
314
- startMs: z.ZodNumber;
315
- endMs: z.ZodNumber;
316
- }, z.core.$strict>>>;
317
298
  usage: z.ZodArray<z.ZodObject<{
318
299
  unit: z.ZodEnum<{
319
300
  input_tokens: "input_tokens";
@@ -336,6 +317,26 @@ export declare const transcriptionSchema: z.ZodObject<{
336
317
  quantity: z.ZodNumber;
337
318
  }, z.core.$strict>>;
338
319
  }, z.core.$strict>;
320
+ /** Why a transcription request cannot be served by a model, before anything is held. */
321
+ export interface TranscriptionRequestIssue {
322
+ /** The request's field at fault, as `invalid_request.param` names it. */
323
+ readonly param: 'file' | 'language' | 'prompt';
324
+ readonly message: string;
325
+ }
326
+ /**
327
+ * Check a transcription request against the model's published `audio` — the
328
+ * transcription counterpart of {@link checkSpeechRequest}. Kaana refuses a
329
+ * request with `invalid_request` and the first issue's `param` BEFORE asking
330
+ * Oxy for a grant; a client may run the same check to choose a model, and
331
+ * omit `language` where `detectsLanguage` lets the model detect it.
332
+ *
333
+ * `mediaType` is the upload's (the multipart `file` part's content type, or
334
+ * `audio.mediaType` of the JSON form). Returns every issue, in field order.
335
+ */
336
+ export declare function checkTranscriptionRequest(request: {
337
+ readonly language?: string;
338
+ readonly prompt?: string;
339
+ }, mediaType: AudioInputMediaType, audio: ModelAudioCapabilities): TranscriptionRequestIssue[];
339
340
  export type SpeechStreamFormat = z.infer<typeof speechStreamFormatSchema>;
340
341
  export type SpeechRequest = z.infer<typeof speechRequestSchema>;
341
342
  export type SpeechAudioDeltaEvent = z.infer<typeof speechAudioDeltaEventSchema>;
@@ -160,12 +160,16 @@ export const MAX_TRANSCRIPTION_FILE_BYTES = 20 * 1024 * 1024;
160
160
  export const transcriptionRequestSchema = z
161
161
  .object({
162
162
  model: modelReferenceSchema,
163
- /** The spoken language, when known; validated against the model's `audio.languages`. */
163
+ /**
164
+ * The spoken language, when known: one of the model's `audio.languages`.
165
+ * Absent lets a model that `detectsLanguage` detect it.
166
+ */
164
167
  language: languageTagSchema.optional(),
165
- /** Vocabulary or context that helps the model; never an instruction. */
168
+ /**
169
+ * Vocabulary or context that helps the model; never an instruction. Only
170
+ * for a model whose `audio.transcriptionPrompt` is true.
171
+ */
166
172
  prompt: z.string().max(4096).optional(),
167
- /** Absent means `none`. */
168
- timestamps: z.enum(['none', 'segment', 'word']).optional(),
169
173
  })
170
174
  .strict();
171
175
  /**
@@ -201,11 +205,7 @@ export const transcriptionJsonRequestSchema = transcriptionRequestSchema
201
205
  .strict(),
202
206
  })
203
207
  .strict();
204
- const timedSpanFields = {
205
- startMs: z.number().int().nonnegative().safe(),
206
- endMs: z.number().int().nonnegative().safe(),
207
- };
208
- /** The response. Segments or words are present only when the request asked for them. */
208
+ /** The response. */
209
209
  export const transcriptionSchema = z
210
210
  .object({
211
211
  schemaVersion: z.literal(1),
@@ -213,24 +213,37 @@ export const transcriptionSchema = z
213
213
  /** The revision that actually served the request. */
214
214
  model: modelReferenceSchema,
215
215
  text: z.string(),
216
- /** The language the model heard, when it reports one. */
216
+ /** The language the model heard, when its provider reports it as a tag. */
217
217
  language: languageTagSchema.optional(),
218
+ /** The audio's duration, measured from its container before the grant. */
218
219
  durationMs: z.number().int().nonnegative().safe().optional(),
219
- segments: z.array(z.object({ ...timedSpanFields, text: z.string() }).strict()).optional(),
220
- words: z.array(z.object({ ...timedSpanFields, word: z.string() }).strict()).optional(),
221
220
  usage: usageSchema,
222
221
  })
223
- .strict()
224
- .superRefine((transcription, ctx) => {
225
- for (const field of ['segments', 'words']) {
226
- for (const [index, span] of (transcription[field] ?? []).entries()) {
227
- if (span.endMs < span.startMs) {
228
- ctx.addIssue({
229
- code: 'custom',
230
- path: [field, index, 'endMs'],
231
- message: 'a span cannot end before it starts',
232
- });
233
- }
234
- }
222
+ .strict();
223
+ /**
224
+ * Check a transcription request against the model's published `audio` — the
225
+ * transcription counterpart of {@link checkSpeechRequest}. Kaana refuses a
226
+ * request with `invalid_request` and the first issue's `param` BEFORE asking
227
+ * Oxy for a grant; a client may run the same check to choose a model, and
228
+ * omit `language` where `detectsLanguage` lets the model detect it.
229
+ *
230
+ * `mediaType` is the upload's (the multipart `file` part's content type, or
231
+ * `audio.mediaType` of the JSON form). Returns every issue, in field order.
232
+ */
233
+ export function checkTranscriptionRequest(request, mediaType, audio) {
234
+ const issues = [];
235
+ if (!audio.audioFormats.input.includes(mediaType)) {
236
+ issues.push({ param: 'file', message: `this model does not take ${mediaType} audio` });
235
237
  }
236
- });
238
+ if (request.language !== undefined && !audio.languages.includes(request.language)) {
239
+ issues.push({
240
+ param: 'language',
241
+ message: `this model does not declare the language ${request.language}` +
242
+ (audio.detectsLanguage === true ? '; omit it to let the model detect the language' : ''),
243
+ });
244
+ }
245
+ if (request.prompt !== undefined && audio.transcriptionPrompt !== true) {
246
+ issues.push({ param: 'prompt', message: 'this model takes no prompt' });
247
+ }
248
+ return issues;
249
+ }
@@ -50,6 +50,25 @@ export declare const realtimeAudioFormatSchema: z.ZodEnum<{
50
50
  g711_ulaw: "g711_ulaw";
51
51
  g711_alaw: "g711_alaw";
52
52
  }>;
53
+ /**
54
+ * What a session's responses produce. Declared here, beside the encodings and
55
+ * for the same reason, since contract set 5.0.0: the catalogue publishes which
56
+ * sets of them a model serves (`capabilities.realtime.parameters`).
57
+ */
58
+ export declare const realtimeOutputModalitySchema: z.ZodEnum<{
59
+ text: "text";
60
+ audio: "audio";
61
+ }>;
62
+ /**
63
+ * How the end of a caller's turn is detected: the discriminant of
64
+ * `realtimeTurnDetectionSchema`, published per model by the catalogue
65
+ * (contract set 5.0.0).
66
+ */
67
+ export declare const realtimeTurnDetectionTypeSchema: z.ZodEnum<{
68
+ none: "none";
69
+ server_vad: "server_vad";
70
+ semantic_vad: "semantic_vad";
71
+ }>;
53
72
  /**
54
73
  * The media type a speech request's `response_format` produces. A client
55
74
  * knows it before the first byte, which is why the speech stream events do
@@ -42,6 +42,18 @@ export const audioInputMediaTypeSchema = z.enum([
42
42
  * catalogue cannot import the realtime module that imports it.
43
43
  */
44
44
  export const realtimeAudioFormatSchema = z.enum(['pcm16_24khz', 'g711_ulaw', 'g711_alaw']);
45
+ /**
46
+ * What a session's responses produce. Declared here, beside the encodings and
47
+ * for the same reason, since contract set 5.0.0: the catalogue publishes which
48
+ * sets of them a model serves (`capabilities.realtime.parameters`).
49
+ */
50
+ export const realtimeOutputModalitySchema = z.enum(['text', 'audio']);
51
+ /**
52
+ * How the end of a caller's turn is detected: the discriminant of
53
+ * `realtimeTurnDetectionSchema`, published per model by the catalogue
54
+ * (contract set 5.0.0).
55
+ */
56
+ export const realtimeTurnDetectionTypeSchema = z.enum(['none', 'server_vad', 'semantic_vad']);
45
57
  const SPEECH_MEDIA_TYPES = {
46
58
  mp3: 'audio/mpeg',
47
59
  opus: 'audio/ogg',