1use crate::{Dialect, Operation, OperationKey, connection::StreamFraming};
10
11#[derive(Debug, Clone, Copy, PartialEq, Eq)]
12pub enum HttpBodyFormat {
13 Empty,
14 Json,
15 Multipart,
16 Binary,
17 Text,
18 JsonStream(StreamFraming),
20}
21
22#[derive(Debug, Clone, Copy, PartialEq, Eq)]
23pub enum OperationTransport {
24 Http {
25 request: &'static [HttpBodyFormat],
26 response: &'static [HttpBodyFormat],
27 },
28 WebSocket,
30}
31
32#[derive(Debug, Clone, Copy, PartialEq, Eq)]
33pub struct OperationSpec {
34 pub key: OperationKey,
35 pub transport: OperationTransport,
36}
37
38pub const OPERATION_SPECS: &[OperationSpec] = &[
42 OperationSpec {
43 key: OperationKey {
44 operation: Operation::ListModels,
45 dialect: Dialect::OpenAi,
46 },
47 transport: OperationTransport::Http {
48 request: &[HttpBodyFormat::Empty],
49 response: &[HttpBodyFormat::Json],
50 },
51 },
52 OperationSpec {
53 key: OperationKey {
54 operation: Operation::ListModels,
55 dialect: Dialect::Claude,
56 },
57 transport: OperationTransport::Http {
58 request: &[HttpBodyFormat::Empty],
59 response: &[HttpBodyFormat::Json],
60 },
61 },
62 OperationSpec {
63 key: OperationKey {
64 operation: Operation::ListModels,
65 dialect: Dialect::Gemini,
66 },
67 transport: OperationTransport::Http {
68 request: &[HttpBodyFormat::Empty],
69 response: &[HttpBodyFormat::Json],
70 },
71 },
72 OperationSpec {
73 key: OperationKey {
74 operation: Operation::GetModel,
75 dialect: Dialect::OpenAi,
76 },
77 transport: OperationTransport::Http {
78 request: &[HttpBodyFormat::Empty],
79 response: &[HttpBodyFormat::Json],
80 },
81 },
82 OperationSpec {
83 key: OperationKey {
84 operation: Operation::GetModel,
85 dialect: Dialect::Claude,
86 },
87 transport: OperationTransport::Http {
88 request: &[HttpBodyFormat::Empty],
89 response: &[HttpBodyFormat::Json],
90 },
91 },
92 OperationSpec {
93 key: OperationKey {
94 operation: Operation::GetModel,
95 dialect: Dialect::Gemini,
96 },
97 transport: OperationTransport::Http {
98 request: &[HttpBodyFormat::Empty],
99 response: &[HttpBodyFormat::Json],
100 },
101 },
102 OperationSpec {
103 key: OperationKey {
104 operation: Operation::CountTokens,
105 dialect: Dialect::OpenAi,
106 },
107 transport: OperationTransport::Http {
108 request: &[HttpBodyFormat::Json],
109 response: &[HttpBodyFormat::Json],
110 },
111 },
112 OperationSpec {
113 key: OperationKey {
114 operation: Operation::CountTokens,
115 dialect: Dialect::Claude,
116 },
117 transport: OperationTransport::Http {
118 request: &[HttpBodyFormat::Json],
119 response: &[HttpBodyFormat::Json],
120 },
121 },
122 OperationSpec {
123 key: OperationKey {
124 operation: Operation::CountTokens,
125 dialect: Dialect::Gemini,
126 },
127 transport: OperationTransport::Http {
128 request: &[HttpBodyFormat::Json],
129 response: &[HttpBodyFormat::Json],
130 },
131 },
132 OperationSpec {
133 key: OperationKey {
134 operation: Operation::GenerateContent,
135 dialect: Dialect::OpenAi,
136 },
137 transport: OperationTransport::Http {
138 request: &[HttpBodyFormat::Json],
139 response: &[HttpBodyFormat::Json],
140 },
141 },
142 OperationSpec {
143 key: OperationKey {
144 operation: Operation::GenerateContent,
145 dialect: Dialect::Claude,
146 },
147 transport: OperationTransport::Http {
148 request: &[HttpBodyFormat::Json],
149 response: &[HttpBodyFormat::Json],
150 },
151 },
152 OperationSpec {
153 key: OperationKey {
154 operation: Operation::GenerateContent,
155 dialect: Dialect::Gemini,
156 },
157 transport: OperationTransport::Http {
158 request: &[HttpBodyFormat::Json],
159 response: &[HttpBodyFormat::Json],
160 },
161 },
162 OperationSpec {
163 key: OperationKey {
164 operation: Operation::GenerateContent,
165 dialect: Dialect::OpenAiChat,
166 },
167 transport: OperationTransport::Http {
168 request: &[HttpBodyFormat::Json],
169 response: &[HttpBodyFormat::Json],
170 },
171 },
172 OperationSpec {
173 key: OperationKey {
174 operation: Operation::StreamGenerateContent,
175 dialect: Dialect::OpenAi,
176 },
177 transport: OperationTransport::Http {
178 request: &[HttpBodyFormat::Json],
179 response: &[HttpBodyFormat::JsonStream(StreamFraming::Sse)],
180 },
181 },
182 OperationSpec {
183 key: OperationKey {
184 operation: Operation::StreamGenerateContent,
185 dialect: Dialect::Claude,
186 },
187 transport: OperationTransport::Http {
188 request: &[HttpBodyFormat::Json],
189 response: &[HttpBodyFormat::JsonStream(StreamFraming::Sse)],
190 },
191 },
192 OperationSpec {
193 key: OperationKey {
194 operation: Operation::StreamGenerateContent,
195 dialect: Dialect::OpenAiChat,
196 },
197 transport: OperationTransport::Http {
198 request: &[HttpBodyFormat::Json],
199 response: &[HttpBodyFormat::JsonStream(StreamFraming::Sse)],
200 },
201 },
202 OperationSpec {
203 key: OperationKey {
204 operation: Operation::StreamGenerateContent,
205 dialect: Dialect::Gemini,
206 },
207 transport: OperationTransport::Http {
208 request: &[HttpBodyFormat::Json],
209 response: &[
210 HttpBodyFormat::JsonStream(StreamFraming::Sse),
211 HttpBodyFormat::JsonStream(StreamFraming::JsonArray),
212 ],
213 },
214 },
215 OperationSpec {
216 key: OperationKey {
217 operation: Operation::CreateModeration,
218 dialect: Dialect::OpenAi,
219 },
220 transport: OperationTransport::Http {
221 request: &[HttpBodyFormat::Json],
222 response: &[HttpBodyFormat::Json],
223 },
224 },
225 OperationSpec {
226 key: OperationKey {
227 operation: Operation::GuardianReview,
228 dialect: Dialect::OpenAi,
229 },
230 transport: OperationTransport::Http {
231 request: &[HttpBodyFormat::Json],
232 response: &[HttpBodyFormat::JsonStream(StreamFraming::Sse)],
233 },
234 },
235 OperationSpec {
236 key: OperationKey {
237 operation: Operation::GuardianClassify,
238 dialect: Dialect::OpenAi,
239 },
240 transport: OperationTransport::Http {
241 request: &[HttpBodyFormat::Json],
242 response: &[HttpBodyFormat::JsonStream(StreamFraming::Sse)],
243 },
244 },
245 OperationSpec {
246 key: OperationKey {
247 operation: Operation::CompactContent,
248 dialect: Dialect::OpenAi,
249 },
250 transport: OperationTransport::Http {
251 request: &[HttpBodyFormat::Json],
252 response: &[HttpBodyFormat::Json],
253 },
254 },
255 OperationSpec {
256 key: OperationKey {
257 operation: Operation::SummarizeMemory,
258 dialect: Dialect::OpenAi,
259 },
260 transport: OperationTransport::Http {
261 request: &[HttpBodyFormat::Json],
262 response: &[HttpBodyFormat::Json],
263 },
264 },
265 OperationSpec {
266 key: OperationKey {
267 operation: Operation::CreateConversation,
268 dialect: Dialect::OpenAi,
269 },
270 transport: OperationTransport::Http {
271 request: &[HttpBodyFormat::Json],
272 response: &[HttpBodyFormat::Json],
273 },
274 },
275 OperationSpec {
276 key: OperationKey {
277 operation: Operation::WebSearch,
278 dialect: Dialect::OpenAi,
279 },
280 transport: OperationTransport::Http {
281 request: &[HttpBodyFormat::Json],
282 response: &[HttpBodyFormat::Json],
283 },
284 },
285 OperationSpec {
286 key: OperationKey {
287 operation: Operation::Rerank,
288 dialect: Dialect::OpenAi,
289 },
290 transport: OperationTransport::Http {
291 request: &[HttpBodyFormat::Json],
292 response: &[HttpBodyFormat::Json],
293 },
294 },
295 OperationSpec {
296 key: OperationKey {
297 operation: Operation::CreateEmbedding,
298 dialect: Dialect::OpenAi,
299 },
300 transport: OperationTransport::Http {
301 request: &[HttpBodyFormat::Json],
302 response: &[HttpBodyFormat::Json],
303 },
304 },
305 OperationSpec {
306 key: OperationKey {
307 operation: Operation::CreateEmbedding,
308 dialect: Dialect::Gemini,
309 },
310 transport: OperationTransport::Http {
311 request: &[HttpBodyFormat::Json],
312 response: &[HttpBodyFormat::Json],
313 },
314 },
315 OperationSpec {
316 key: OperationKey {
317 operation: Operation::BatchCreateEmbedding,
318 dialect: Dialect::Gemini,
319 },
320 transport: OperationTransport::Http {
321 request: &[HttpBodyFormat::Json],
322 response: &[HttpBodyFormat::Json],
323 },
324 },
325 OperationSpec {
326 key: OperationKey {
327 operation: Operation::CreateImage,
328 dialect: Dialect::OpenAi,
329 },
330 transport: OperationTransport::Http {
331 request: &[HttpBodyFormat::Json],
332 response: &[
333 HttpBodyFormat::Json,
334 HttpBodyFormat::JsonStream(StreamFraming::Sse),
335 ],
336 },
337 },
338 OperationSpec {
339 key: OperationKey {
340 operation: Operation::EditImage,
341 dialect: Dialect::OpenAi,
342 },
343 transport: OperationTransport::Http {
344 request: &[HttpBodyFormat::Json, HttpBodyFormat::Multipart],
345 response: &[
346 HttpBodyFormat::Json,
347 HttpBodyFormat::JsonStream(StreamFraming::Sse),
348 ],
349 },
350 },
351 OperationSpec {
352 key: OperationKey {
353 operation: Operation::CreateSpeech,
354 dialect: Dialect::OpenAi,
355 },
356 transport: OperationTransport::Http {
357 request: &[HttpBodyFormat::Json],
358 response: &[
359 HttpBodyFormat::Binary,
360 HttpBodyFormat::JsonStream(StreamFraming::Sse),
361 ],
362 },
363 },
364 OperationSpec {
365 key: OperationKey {
366 operation: Operation::CreateTranscription,
367 dialect: Dialect::OpenAi,
368 },
369 transport: OperationTransport::Http {
370 request: &[HttpBodyFormat::Multipart],
371 response: &[
372 HttpBodyFormat::Json,
373 HttpBodyFormat::Text,
374 HttpBodyFormat::JsonStream(StreamFraming::Sse),
375 ],
376 },
377 },
378 OperationSpec {
379 key: OperationKey {
380 operation: Operation::CreateTranslation,
381 dialect: Dialect::OpenAi,
382 },
383 transport: OperationTransport::Http {
384 request: &[HttpBodyFormat::Multipart],
385 response: &[HttpBodyFormat::Json, HttpBodyFormat::Text],
386 },
387 },
388 OperationSpec {
389 key: OperationKey {
390 operation: Operation::CreateFile,
391 dialect: Dialect::OpenAi,
392 },
393 transport: OperationTransport::Http {
394 request: &[HttpBodyFormat::Multipart],
395 response: &[HttpBodyFormat::Json],
396 },
397 },
398 OperationSpec {
399 key: OperationKey {
400 operation: Operation::CreateFile,
401 dialect: Dialect::Claude,
402 },
403 transport: OperationTransport::Http {
404 request: &[HttpBodyFormat::Multipart],
405 response: &[HttpBodyFormat::Json],
406 },
407 },
408 OperationSpec {
409 key: OperationKey {
410 operation: Operation::CreateFile,
411 dialect: Dialect::Gemini,
412 },
413 transport: OperationTransport::Http {
414 request: &[
415 HttpBodyFormat::Multipart,
416 HttpBodyFormat::Json,
417 HttpBodyFormat::Binary,
418 ],
419 response: &[HttpBodyFormat::Json, HttpBodyFormat::Empty],
420 },
421 },
422 OperationSpec {
423 key: OperationKey {
424 operation: Operation::ListFiles,
425 dialect: Dialect::OpenAi,
426 },
427 transport: OperationTransport::Http {
428 request: &[HttpBodyFormat::Empty],
429 response: &[HttpBodyFormat::Json],
430 },
431 },
432 OperationSpec {
433 key: OperationKey {
434 operation: Operation::ListFiles,
435 dialect: Dialect::Claude,
436 },
437 transport: OperationTransport::Http {
438 request: &[HttpBodyFormat::Empty],
439 response: &[HttpBodyFormat::Json],
440 },
441 },
442 OperationSpec {
443 key: OperationKey {
444 operation: Operation::ListFiles,
445 dialect: Dialect::Gemini,
446 },
447 transport: OperationTransport::Http {
448 request: &[HttpBodyFormat::Empty],
449 response: &[HttpBodyFormat::Json],
450 },
451 },
452 OperationSpec {
453 key: OperationKey {
454 operation: Operation::RetrieveFile,
455 dialect: Dialect::OpenAi,
456 },
457 transport: OperationTransport::Http {
458 request: &[HttpBodyFormat::Empty],
459 response: &[HttpBodyFormat::Json],
460 },
461 },
462 OperationSpec {
463 key: OperationKey {
464 operation: Operation::RetrieveFile,
465 dialect: Dialect::Claude,
466 },
467 transport: OperationTransport::Http {
468 request: &[HttpBodyFormat::Empty],
469 response: &[HttpBodyFormat::Json],
470 },
471 },
472 OperationSpec {
473 key: OperationKey {
474 operation: Operation::RetrieveFile,
475 dialect: Dialect::Gemini,
476 },
477 transport: OperationTransport::Http {
478 request: &[HttpBodyFormat::Empty],
479 response: &[HttpBodyFormat::Json],
480 },
481 },
482 OperationSpec {
483 key: OperationKey {
484 operation: Operation::RetrieveFileContent,
485 dialect: Dialect::OpenAi,
486 },
487 transport: OperationTransport::Http {
488 request: &[HttpBodyFormat::Empty],
489 response: &[HttpBodyFormat::Binary],
490 },
491 },
492 OperationSpec {
493 key: OperationKey {
494 operation: Operation::RetrieveFileContent,
495 dialect: Dialect::Claude,
496 },
497 transport: OperationTransport::Http {
498 request: &[HttpBodyFormat::Empty],
499 response: &[HttpBodyFormat::Binary],
500 },
501 },
502 OperationSpec {
503 key: OperationKey {
504 operation: Operation::RetrieveFileContent,
505 dialect: Dialect::Gemini,
506 },
507 transport: OperationTransport::Http {
508 request: &[HttpBodyFormat::Empty],
509 response: &[HttpBodyFormat::Binary],
510 },
511 },
512 OperationSpec {
513 key: OperationKey {
514 operation: Operation::DeleteFile,
515 dialect: Dialect::OpenAi,
516 },
517 transport: OperationTransport::Http {
518 request: &[HttpBodyFormat::Empty],
519 response: &[HttpBodyFormat::Json],
520 },
521 },
522 OperationSpec {
523 key: OperationKey {
524 operation: Operation::DeleteFile,
525 dialect: Dialect::Claude,
526 },
527 transport: OperationTransport::Http {
528 request: &[HttpBodyFormat::Empty],
529 response: &[HttpBodyFormat::Json],
530 },
531 },
532 OperationSpec {
533 key: OperationKey {
534 operation: Operation::DeleteFile,
535 dialect: Dialect::Gemini,
536 },
537 transport: OperationTransport::Http {
538 request: &[HttpBodyFormat::Empty],
539 response: &[HttpBodyFormat::Json],
540 },
541 },
542 OperationSpec {
543 key: OperationKey {
544 operation: Operation::CreateVideo,
545 dialect: Dialect::OpenAi,
546 },
547 transport: OperationTransport::Http {
548 request: &[HttpBodyFormat::Json, HttpBodyFormat::Multipart],
549 response: &[HttpBodyFormat::Json],
550 },
551 },
552 OperationSpec {
553 key: OperationKey {
554 operation: Operation::RetrieveVideo,
555 dialect: Dialect::OpenAi,
556 },
557 transport: OperationTransport::Http {
558 request: &[HttpBodyFormat::Empty],
559 response: &[HttpBodyFormat::Json],
560 },
561 },
562 OperationSpec {
563 key: OperationKey {
564 operation: Operation::ListVideos,
565 dialect: Dialect::OpenAi,
566 },
567 transport: OperationTransport::Http {
568 request: &[HttpBodyFormat::Empty],
569 response: &[HttpBodyFormat::Json],
570 },
571 },
572 OperationSpec {
573 key: OperationKey {
574 operation: Operation::DeleteVideo,
575 dialect: Dialect::OpenAi,
576 },
577 transport: OperationTransport::Http {
578 request: &[HttpBodyFormat::Empty],
579 response: &[HttpBodyFormat::Json],
580 },
581 },
582 OperationSpec {
583 key: OperationKey {
584 operation: Operation::DownloadVideoContent,
585 dialect: Dialect::OpenAi,
586 },
587 transport: OperationTransport::Http {
588 request: &[HttpBodyFormat::Empty],
589 response: &[HttpBodyFormat::Binary],
590 },
591 },
592 OperationSpec {
593 key: OperationKey {
594 operation: Operation::CreateRealtimeCall,
595 dialect: Dialect::OpenAi,
596 },
597 transport: OperationTransport::Http {
598 request: &[HttpBodyFormat::Multipart],
599 response: &[HttpBodyFormat::Text],
600 },
601 },
602 OperationSpec {
603 key: OperationKey {
604 operation: Operation::GenerateContent,
605 dialect: Dialect::OpenAiResponsesWebSocket,
606 },
607 transport: OperationTransport::WebSocket,
608 },
609 OperationSpec {
610 key: OperationKey {
611 operation: Operation::StreamGenerateContent,
612 dialect: Dialect::OpenAiResponsesWebSocket,
613 },
614 transport: OperationTransport::WebSocket,
615 },
616 OperationSpec {
617 key: OperationKey {
618 operation: Operation::ConnectRealtime,
619 dialect: Dialect::OpenAi,
620 },
621 transport: OperationTransport::WebSocket,
622 },
623 OperationSpec {
624 key: OperationKey {
625 operation: Operation::ConnectRealtime,
626 dialect: Dialect::Gemini,
627 },
628 transport: OperationTransport::WebSocket,
629 },
630];