1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
// This file is @generated by prost-build.
/// API key information.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ApiKey {
/// A redacted API key. The full API key will not be displayed after it has
/// been created.
#[prost(string, tag = "1")]
pub redacted_api_key: ::prost::alloc::string::String,
/// ID of the user who created this API key.
#[prost(string, tag = "3")]
pub user_id: ::prost::alloc::string::String,
/// Human-readable name for the API key.
#[prost(string, tag = "4")]
pub name: ::prost::alloc::string::String,
/// Unix timestamp when the API key was created.
#[prost(message, optional, tag = "5")]
pub create_time: ::core::option::Option<::prost_types::Timestamp>,
/// Unix timestamp when the API key was last modified.
#[prost(message, optional, tag = "9")]
pub modify_time: ::core::option::Option<::prost_types::Timestamp>,
/// ID of the last user who modified the API key
#[prost(string, tag = "11")]
pub modified_by: ::prost::alloc::string::String,
/// ID of the team this API key belongs to.
#[prost(string, tag = "6")]
pub team_id: ::prost::alloc::string::String,
/// Access Control Lists (ACLs) associated with this key.
/// These indicate the resources that the API key has access to.
#[prost(string, repeated, tag = "7")]
pub acls: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// The ID of the API key. This is different from the API key itself.
#[prost(string, tag = "8")]
pub api_key_id: ::prost::alloc::string::String,
/// Whether the API key is currently blocked from making API requests.
#[prost(bool, tag = "10")]
pub api_key_blocked: bool,
/// Whether the team is currently blocked from making API requests.
#[prost(bool, tag = "13")]
pub team_blocked: bool,
/// Whether the API key is currently disabled.
#[prost(bool, tag = "12")]
pub disabled: bool,
}
/// Generated client implementations.
pub mod auth_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// An API service to check status of an API key.
#[derive(Debug, Clone)]
pub struct AuthClient<T> {
inner: tonic::client::Grpc<T>,
}
impl AuthClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> AuthClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> AuthClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
AuthClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Returns some information about an API key.
pub async fn get_api_key_info(
&mut self,
request: impl tonic::IntoRequest<()>,
) -> std::result::Result<tonic::Response<super::ApiKey>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Auth/get_api_key_info",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Auth", "get_api_key_info"));
self.inner.unary(req, path, codec).await
}
}
}
/// The response from the service, when creating a deferred completion request.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct StartDeferredResponse {
/// The ID of this request. This ID can be used to retrieve completion results
/// later.
#[prost(string, tag = "1")]
pub request_id: ::prost::alloc::string::String,
}
/// Retrieve the deferred chat request's response with the `request_id` in
/// StartDeferredResponse.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetDeferredRequest {
/// The ID of this request to get.
#[prost(string, tag = "1")]
pub request_id: ::prost::alloc::string::String,
}
/// Status of deferred completion request.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum DeferredStatus {
/// Invalid status.
InvalidDeferredStatus = 0,
/// The request has been processed and is available for download.
Done = 1,
/// The request has been processed but the content has expired and is not
/// available anymore.
Expired = 2,
/// The request is still being processed.
Pending = 3,
/// The request failed due to an internal service error.
/// The error message is in the `error` field of the response.
Failed = 4,
}
impl DeferredStatus {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::InvalidDeferredStatus => "INVALID_DEFERRED_STATUS",
Self::Done => "DONE",
Self::Expired => "EXPIRED",
Self::Pending => "PENDING",
Self::Failed => "FAILED",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"INVALID_DEFERRED_STATUS" => Some(Self::InvalidDeferredStatus),
"DONE" => Some(Self::Done),
"EXPIRED" => Some(Self::Expired),
"PENDING" => Some(Self::Pending),
"FAILED" => Some(Self::Failed),
_ => None,
}
}
}
/// Document search using a combination of keyword and semantic search.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HybridRetrieval {
/// Overfetch multiplier applied to the requested search limit.
/// When set, fetches (limit * search_multiplier) results from each retrieval method
/// before reranking, then returns the top `limit` results after reranking.
/// Valid range is \[1, 100\]. Defaults to 1 when unset.
#[prost(int32, optional, tag = "1")]
pub search_multiplier: ::core::option::Option<i32>,
/// Which reranker to use to limit results to the desired value.
#[prost(oneof = "hybrid_retrieval::Reranker", tags = "2, 3")]
pub reranker: ::core::option::Option<hybrid_retrieval::Reranker>,
}
/// Nested message and enum types in `HybridRetrieval`.
pub mod hybrid_retrieval {
/// Which reranker to use to limit results to the desired value.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Reranker {
/// Use a reranker model to perform the reranking.
#[prost(message, tag = "2")]
RerankerModel(super::RerankerModel),
/// Use RRF to perform the reranking.
#[prost(message, tag = "3")]
ReciprocalRankFusion(super::ReciprocalRankFusion),
}
}
/// Document search using keyword matching (sparse embeddings).
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct KeywordRetrieval {
/// Optional, but always used when doing search across multiple collections.
#[prost(message, optional, tag = "1")]
pub reranker: ::core::option::Option<RerankerModel>,
}
/// Document search using semantic similarity (dense embeddings).
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SemanticRetrieval {
/// Optional, but always used when doing search across multiple collections.
#[prost(message, optional, tag = "1")]
pub reranker: ::core::option::Option<RerankerModel>,
}
/// Configuration for reciprocal rank fusion (RRF) reranking.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct ReciprocalRankFusion {
/// The RRF constant k used in the reciprocal rank fusion formula. Defaults to 60.
#[prost(int32, optional, tag = "1")]
pub k: ::core::option::Option<i32>,
/// Weight for embedding (dense) search results. Should be between 0 and 1. Defaults to 0.5.
#[prost(float, tag = "3")]
pub embedding_weight: f32,
/// Weight for keyword (sparse) search results. Should be between 0 and 1. Defaults to 0.5.
#[prost(float, tag = "4")]
pub text_weight: f32,
}
/// Configuration for model-based reranking.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct RerankerModel {
/// The model to use for reranking. Defaults to standard reranker model.
#[prost(string, optional, tag = "1")]
pub model: ::core::option::Option<::prost::alloc::string::String>,
/// Instructions for the reranking model. Defaults to generic reranking instructions.
#[prost(string, optional, tag = "2")]
pub instructions: ::core::option::Option<::prost::alloc::string::String>,
}
/// Message that contains settings needed to do a document search.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SearchRequest {
/// The query to search for which will be embedded using the
/// same embedding model as the one used for the source to query.
#[prost(string, tag = "1")]
pub query: ::prost::alloc::string::String,
/// The source to query.
#[prost(message, optional, tag = "2")]
pub source: ::core::option::Option<DocumentsSource>,
/// The number of chunks to return.
/// Will always return the top matching chunks.
/// Optional, defaults to 10.
#[prost(int32, optional, tag = "3")]
pub limit: ::core::option::Option<i32>,
/// User-defined instructions to be included in the search query. Defaults to generic search instructions.
#[prost(string, optional, tag = "5")]
pub instructions: ::core::option::Option<::prost::alloc::string::String>,
/// Deprecated: Metric now comes from what is set during collection creation.
#[deprecated]
#[prost(enumeration = "RankingMetric", optional, tag = "4")]
pub ranking_metric: ::core::option::Option<i32>,
/// How to perform the document search. Defaults to HybridRetrieval
#[prost(oneof = "search_request::RetrievalMode", tags = "11, 12, 13")]
pub retrieval_mode: ::core::option::Option<search_request::RetrievalMode>,
}
/// Nested message and enum types in `SearchRequest`.
pub mod search_request {
/// How to perform the document search. Defaults to HybridRetrieval
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum RetrievalMode {
#[prost(message, tag = "11")]
HybridRetrieval(super::HybridRetrieval),
#[prost(message, tag = "12")]
SemanticRetrieval(super::SemanticRetrieval),
#[prost(message, tag = "13")]
KeywordRetrieval(super::KeywordRetrieval),
}
}
/// SearchResponse message contains the results of a document search operation.
/// It returns a collection of matching document chunks sorted by relevance score.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SearchResponse {
/// Collection of document chunks that match the search query, ordered by relevance score
/// from highest to lowest.
#[prost(message, repeated, tag = "1")]
pub matches: ::prost::alloc::vec::Vec<SearchMatch>,
}
/// SearchMatch message represents a single document chunk that matches the search query.
/// It contains the document ID, chunk ID, content text, and a relevance score indicating
/// how well it matches the query.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SearchMatch {
/// Unique identifier of the document that contains the matching chunk.
#[prost(string, tag = "1")]
pub file_id: ::prost::alloc::string::String,
/// Unique identifier of the specific chunk within the document that matched the search query.
#[prost(string, tag = "2")]
pub chunk_id: ::prost::alloc::string::String,
/// The actual text content of the matching chunk that can be presented to the user.
#[prost(string, tag = "3")]
pub chunk_content: ::prost::alloc::string::String,
/// Score is the score of the chunk, which is determined by the ranking metric.
/// For L2 distance, lower scores indicate better matches. Range is \[0, inf).
/// For cosine similarity, higher scores indicate better matches. Range is \[0, 1\].
#[prost(float, tag = "4")]
pub score: f32,
/// The ID(s) of the collection(s) to which this document belongs.
#[prost(string, repeated, tag = "5")]
pub collection_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
/// Configuration for a documents sources in search requests.
///
/// This message configures a source for search content within documents or collections of documents.
/// Those documents must be uploaded through the management API or directly on the xAI console:
/// <https://console.x.ai.>
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct DocumentsSource {
/// IDs of collections to use.
#[prost(string, repeated, tag = "1")]
pub collection_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
/// RankingMetric is the metric to use for the search.
/// Deprecated: Metric now comes from what is set in the collection creation.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum RankingMetric {
Unknown = 0,
L2Distance = 1,
CosineSimilarity = 2,
}
impl RankingMetric {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unknown => "RANKING_METRIC_UNKNOWN",
Self::L2Distance => "RANKING_METRIC_L2_DISTANCE",
Self::CosineSimilarity => "RANKING_METRIC_COSINE_SIMILARITY",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"RANKING_METRIC_UNKNOWN" => Some(Self::Unknown),
"RANKING_METRIC_L2_DISTANCE" => Some(Self::L2Distance),
"RANKING_METRIC_COSINE_SIMILARITY" => Some(Self::CosineSimilarity),
_ => None,
}
}
}
/// Generated client implementations.
pub mod documents_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct DocumentsClient<T> {
inner: tonic::client::Grpc<T>,
}
impl DocumentsClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> DocumentsClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> DocumentsClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
DocumentsClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn search(
&mut self,
request: impl tonic::IntoRequest<super::SearchRequest>,
) -> std::result::Result<tonic::Response<super::SearchResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/xai_api.Documents/Search");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("xai_api.Documents", "Search"));
self.inner.unary(req, path, codec).await
}
}
}
/// Records the cost associated with a sampling request (both chat and sample
/// endpoints).
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SamplingUsage {
/// Total number of text completion tokens generated across all choices
/// (in case of n>1).
#[prost(int32, tag = "1")]
pub completion_tokens: i32,
/// Total number of reasoning tokens generated across all choices.
#[prost(int32, tag = "6")]
pub reasoning_tokens: i32,
/// Total number of prompt tokens (both text and images).
#[prost(int32, tag = "2")]
pub prompt_tokens: i32,
/// Total number of tokens (prompt + completion).
#[prost(int32, tag = "3")]
pub total_tokens: i32,
/// Total number of (uncached) text tokens in the prompt.
#[prost(int32, tag = "4")]
pub prompt_text_tokens: i32,
/// Total number of cached text tokens in the prompt.
#[prost(int32, tag = "7")]
pub cached_prompt_text_tokens: i32,
/// Total number of image tokens in the prompt.
#[prost(int32, tag = "5")]
pub prompt_image_tokens: i32,
/// \[DEPRECATED - live search feature has been deprecated so this field is
/// redundant\] Number of individual live search sources used. Only applicable
/// when live search is enabled. e.g. If a live search query returns citations
/// from both X and Web and news sources, this will be 3. If it returns
/// citations from only X, this will be 1.
#[prost(int32, tag = "8")]
pub num_sources_used: i32,
/// List of server side tools called.
#[prost(enumeration = "ServerSideTool", repeated, tag = "9")]
pub server_side_tools_used: ::prost::alloc::vec::Vec<i32>,
/// Full price paid by the user for this request, in USD ticks.
/// For requests with server-side tools, this is the sum of token cost and
/// server-side tool cost. Also used for image gen, video gen, etc.
/// 1 USD = 10,000,000,000 ticks (i.e. 1 tick = 1e-10 USD).
/// To convert to dollars, divide by 10,000,000,000.
#[prost(int64, optional, tag = "11")]
pub cost_in_usd_ticks: ::core::option::Option<i64>,
}
/// Usage of embedding models.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct EmbeddingUsage {
/// The number of feature vectors produced from text inputs.
#[prost(int32, tag = "1")]
pub num_text_embeddings: i32,
/// The number of feature vectors produced from image inputs.
#[prost(int32, tag = "2")]
pub num_image_embeddings: i32,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ServerSideTool {
Invalid = 0,
WebSearch = 1,
XSearch = 2,
CodeExecution = 3,
ViewImage = 4,
ViewXVideo = 5,
CollectionsSearch = 6,
Mcp = 7,
AttachmentSearch = 8,
}
impl ServerSideTool {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Invalid => "SERVER_SIDE_TOOL_INVALID",
Self::WebSearch => "SERVER_SIDE_TOOL_WEB_SEARCH",
Self::XSearch => "SERVER_SIDE_TOOL_X_SEARCH",
Self::CodeExecution => "SERVER_SIDE_TOOL_CODE_EXECUTION",
Self::ViewImage => "SERVER_SIDE_TOOL_VIEW_IMAGE",
Self::ViewXVideo => "SERVER_SIDE_TOOL_VIEW_X_VIDEO",
Self::CollectionsSearch => "SERVER_SIDE_TOOL_COLLECTIONS_SEARCH",
Self::Mcp => "SERVER_SIDE_TOOL_MCP",
Self::AttachmentSearch => "SERVER_SIDE_TOOL_ATTACHMENT_SEARCH",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"SERVER_SIDE_TOOL_INVALID" => Some(Self::Invalid),
"SERVER_SIDE_TOOL_WEB_SEARCH" => Some(Self::WebSearch),
"SERVER_SIDE_TOOL_X_SEARCH" => Some(Self::XSearch),
"SERVER_SIDE_TOOL_CODE_EXECUTION" => Some(Self::CodeExecution),
"SERVER_SIDE_TOOL_VIEW_IMAGE" => Some(Self::ViewImage),
"SERVER_SIDE_TOOL_VIEW_X_VIDEO" => Some(Self::ViewXVideo),
"SERVER_SIDE_TOOL_COLLECTIONS_SEARCH" => Some(Self::CollectionsSearch),
"SERVER_SIDE_TOOL_MCP" => Some(Self::Mcp),
"SERVER_SIDE_TOOL_ATTACHMENT_SEARCH" => Some(Self::AttachmentSearch),
_ => None,
}
}
}
/// Request message for generating an image.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenerateImageRequest {
/// Input prompt to generate an image from.
#[prost(string, tag = "1")]
pub prompt: ::prost::alloc::string::String,
/// Optional input image to perform generations based on.
#[prost(message, optional, tag = "5")]
pub image: ::core::option::Option<ImageUrlContent>,
/// Name or alias of the image generation model to be used.
#[prost(string, tag = "2")]
pub model: ::prost::alloc::string::String,
/// Number of images to generate. Allowed values are \[1, 10\].
#[prost(int32, optional, tag = "3")]
pub n: ::core::option::Option<i32>,
/// An opaque string supplied by the API client (customer) to identify a user.
/// The string will be stored in the logs and can be used in customer service
/// requests to identify certain requests.
#[prost(string, tag = "4")]
pub user: ::prost::alloc::string::String,
/// Optional field to specify the image format to return the generated image(s)
/// in. See ImageFormat enum for options.
#[prost(enumeration = "ImageFormat", tag = "11")]
pub format: i32,
/// Optional aspect ratio for image generation/editing.
/// Only supported by grok-imagine models.
/// Defaults to 1:1 if not specified. Auto is only supported for image generation
/// with a thinking upsampler.
#[prost(enumeration = "ImageAspectRatio", optional, tag = "14")]
pub aspect_ratio: ::core::option::Option<i32>,
/// Optional resolution for image generation/editing.
/// Only supported by grok-imagine models.
/// Defaults to 1k if not specified.
/// When 2k is selected, the image is generated at 1k and upscaled using super-resolution.
/// The final output area is capped at approximately 2048x2048 pixels, with dimensions
/// adjusted to preserve aspect ratio and rounded to multiples of 16.
#[prost(enumeration = "ImageResolution", optional, tag = "15")]
pub resolution: ::core::option::Option<i32>,
/// Optional list of input images for multi-reference image editing.
/// Each image is either an image URL or a base64-encoded version of the image.
/// This field cannot be set together with the `image` field.
#[prost(message, repeated, tag = "17")]
pub images: ::prost::alloc::vec::Vec<ImageUrlContent>,
}
/// The response from the image generation models containing the generated image(s).
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ImageResponse {
/// A list of generated images (including relevant metadata).
#[prost(message, repeated, tag = "1")]
pub images: ::prost::alloc::vec::Vec<GeneratedImage>,
/// The model used to generate the image (ignoring aliases).
#[prost(string, tag = "2")]
pub model: ::prost::alloc::string::String,
/// The usage of the request.
#[prost(message, optional, tag = "3")]
pub usage: ::core::option::Option<SamplingUsage>,
}
/// Contains all data related to a generated image.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GeneratedImage {
/// Whether the image generated by the model respects moderation rules.
/// The field will be true if the image respect moderation rules. Otherwise
/// the field will be false and the image field is replaced by a placeholder.
#[prost(bool, tag = "4")]
pub respect_moderation: bool,
/// The generated image.
#[prost(oneof = "generated_image::Image", tags = "1, 3")]
pub image: ::core::option::Option<generated_image::Image>,
}
/// Nested message and enum types in `GeneratedImage`.
pub mod generated_image {
/// The generated image.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
pub enum Image {
/// A base-64 encoded string of the image. Provided if user specified `IMG_FORMAT_BASE64` in `format` field of the
/// `GenerateImageRequest` message.
#[prost(string, tag = "1")]
Base64(::prost::alloc::string::String),
/// A url that points to the generated image. Provided if user specified `IMG_FORMAT_URL` in `format` field of the
/// `GenerateImageRequest` message.
#[prost(string, tag = "3")]
Url(::prost::alloc::string::String),
}
}
/// Contains data relating to an image that is provided to the model.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ImageUrlContent {
/// This is either an image URL or a base64-encoded version of the image.
/// The following image formats are supported: PNG, JPG, and WebP.
/// If an image URL is provided, the image will be downloaded for every API
/// request without being cached. Images are fetched using
/// "XaiImageApiFetch/1.0" user agent, and will timeout after 5 seconds.
/// The image size is limited to 10 MiB. If the image download fails, the API
/// request will fail as well.
#[prost(string, tag = "1")]
pub image_url: ::prost::alloc::string::String,
/// The level of pre-processing resolution that will be applied to the image.
#[prost(enumeration = "ImageDetail", tag = "2")]
pub detail: i32,
}
/// Indicates the level of preprocessing to apply to images that will be fed to
/// the model.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ImageDetail {
/// Detail level is invalid.
DetailInvalid = 0,
/// The system will decide the image resolution to use.
DetailAuto = 1,
/// The model will process a low-resolution version of the image. This is
/// faster and cheaper (i.e. consumes fewer tokens).
DetailLow = 2,
/// The model will process a high-resolution of the image. This is slower and
/// more expensive but will allow the model to attend to more nuanced details
/// in the image.
DetailHigh = 3,
}
impl ImageDetail {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::DetailInvalid => "DETAIL_INVALID",
Self::DetailAuto => "DETAIL_AUTO",
Self::DetailLow => "DETAIL_LOW",
Self::DetailHigh => "DETAIL_HIGH",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"DETAIL_INVALID" => Some(Self::DetailInvalid),
"DETAIL_AUTO" => Some(Self::DetailAuto),
"DETAIL_LOW" => Some(Self::DetailLow),
"DETAIL_HIGH" => Some(Self::DetailHigh),
_ => None,
}
}
}
/// The image format to be returned (base-64 encoded string or a url of
/// the image).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ImageFormat {
/// Image format is invalid.
ImgFormatInvalid = 0,
/// A base-64 encoding of the image.
ImgFormatBase64 = 1,
/// An URL at which the user can download the image.
ImgFormatUrl = 2,
}
impl ImageFormat {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::ImgFormatInvalid => "IMG_FORMAT_INVALID",
Self::ImgFormatBase64 => "IMG_FORMAT_BASE64",
Self::ImgFormatUrl => "IMG_FORMAT_URL",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"IMG_FORMAT_INVALID" => Some(Self::ImgFormatInvalid),
"IMG_FORMAT_BASE64" => Some(Self::ImgFormatBase64),
"IMG_FORMAT_URL" => Some(Self::ImgFormatUrl),
_ => None,
}
}
}
/// Quality levels for image generation with their corresponding resolutions.
/// Currently only supported by grok-imagine models.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ImageQuality {
/// Quality is invalid.
ImgQualityInvalid = 0,
/// Low quality.
ImgQualityLow = 1,
/// Medium quality: (default).
ImgQualityMedium = 2,
/// High quality.
ImgQualityHigh = 3,
}
impl ImageQuality {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::ImgQualityInvalid => "IMG_QUALITY_INVALID",
Self::ImgQualityLow => "IMG_QUALITY_LOW",
Self::ImgQualityMedium => "IMG_QUALITY_MEDIUM",
Self::ImgQualityHigh => "IMG_QUALITY_HIGH",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"IMG_QUALITY_INVALID" => Some(Self::ImgQualityInvalid),
"IMG_QUALITY_LOW" => Some(Self::ImgQualityLow),
"IMG_QUALITY_MEDIUM" => Some(Self::ImgQualityMedium),
"IMG_QUALITY_HIGH" => Some(Self::ImgQualityHigh),
_ => None,
}
}
}
/// Aspect ratio for image generation.
/// Only supported by grok-imagine models.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ImageAspectRatio {
/// Invalid aspect ratio.
ImgAspectRatioInvalid = 0,
/// 1:1 aspect ratio (square).
ImgAspectRatio11 = 1,
/// 3:4 aspect ratio (portrait).
ImgAspectRatio34 = 2,
/// 4:3 aspect ratio (landscape).
ImgAspectRatio43 = 3,
/// 9:16 aspect ratio (tall portrait).
ImgAspectRatio916 = 4,
/// 16:9 aspect ratio (wide landscape).
ImgAspectRatio169 = 5,
/// 2:3 aspect ratio (photo portrait).
ImgAspectRatio23 = 6,
/// 3:2 aspect ratio (photo landscape).
ImgAspectRatio32 = 7,
/// Auto aspect ratio (model auto-selects based on prompt).
/// Only supported for image generation with a thinking upsampler.
ImgAspectRatioAuto = 8,
/// 9:19.5 aspect ratio (extra tall portrait - phone screens).
ImgAspectRatio9195 = 9,
/// 19.5:9 aspect ratio (extra wide landscape).
ImgAspectRatio1959 = 10,
/// 9:20 aspect ratio (tall portrait - modern phone screens).
ImgAspectRatio920 = 11,
/// 20:9 aspect ratio (ultra wide landscape).
ImgAspectRatio209 = 12,
/// 1:2 aspect ratio (tall portrait).
ImgAspectRatio12 = 13,
/// 2:1 aspect ratio (wide landscape).
ImgAspectRatio21 = 14,
}
impl ImageAspectRatio {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::ImgAspectRatioInvalid => "IMG_ASPECT_RATIO_INVALID",
Self::ImgAspectRatio11 => "IMG_ASPECT_RATIO_1_1",
Self::ImgAspectRatio34 => "IMG_ASPECT_RATIO_3_4",
Self::ImgAspectRatio43 => "IMG_ASPECT_RATIO_4_3",
Self::ImgAspectRatio916 => "IMG_ASPECT_RATIO_9_16",
Self::ImgAspectRatio169 => "IMG_ASPECT_RATIO_16_9",
Self::ImgAspectRatio23 => "IMG_ASPECT_RATIO_2_3",
Self::ImgAspectRatio32 => "IMG_ASPECT_RATIO_3_2",
Self::ImgAspectRatioAuto => "IMG_ASPECT_RATIO_AUTO",
Self::ImgAspectRatio9195 => "IMG_ASPECT_RATIO_9_19_5",
Self::ImgAspectRatio1959 => "IMG_ASPECT_RATIO_19_5_9",
Self::ImgAspectRatio920 => "IMG_ASPECT_RATIO_9_20",
Self::ImgAspectRatio209 => "IMG_ASPECT_RATIO_20_9",
Self::ImgAspectRatio12 => "IMG_ASPECT_RATIO_1_2",
Self::ImgAspectRatio21 => "IMG_ASPECT_RATIO_2_1",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"IMG_ASPECT_RATIO_INVALID" => Some(Self::ImgAspectRatioInvalid),
"IMG_ASPECT_RATIO_1_1" => Some(Self::ImgAspectRatio11),
"IMG_ASPECT_RATIO_3_4" => Some(Self::ImgAspectRatio34),
"IMG_ASPECT_RATIO_4_3" => Some(Self::ImgAspectRatio43),
"IMG_ASPECT_RATIO_9_16" => Some(Self::ImgAspectRatio916),
"IMG_ASPECT_RATIO_16_9" => Some(Self::ImgAspectRatio169),
"IMG_ASPECT_RATIO_2_3" => Some(Self::ImgAspectRatio23),
"IMG_ASPECT_RATIO_3_2" => Some(Self::ImgAspectRatio32),
"IMG_ASPECT_RATIO_AUTO" => Some(Self::ImgAspectRatioAuto),
"IMG_ASPECT_RATIO_9_19_5" => Some(Self::ImgAspectRatio9195),
"IMG_ASPECT_RATIO_19_5_9" => Some(Self::ImgAspectRatio1959),
"IMG_ASPECT_RATIO_9_20" => Some(Self::ImgAspectRatio920),
"IMG_ASPECT_RATIO_20_9" => Some(Self::ImgAspectRatio209),
"IMG_ASPECT_RATIO_1_2" => Some(Self::ImgAspectRatio12),
"IMG_ASPECT_RATIO_2_1" => Some(Self::ImgAspectRatio21),
_ => None,
}
}
}
/// Resolution for image generation.
/// Only supported by grok-imagine models.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ImageResolution {
/// Invalid resolution.
ImgResolutionInvalid = 0,
/// 1k resolution (~1 megapixel total).
/// Dimensions vary by aspect ratio.
ImgResolution1k = 1,
/// 2k resolution (~4 megapixel total).
ImgResolution2k = 2,
}
impl ImageResolution {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::ImgResolutionInvalid => "IMG_RESOLUTION_INVALID",
Self::ImgResolution1k => "IMG_RESOLUTION_1K",
Self::ImgResolution2k => "IMG_RESOLUTION_2K",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"IMG_RESOLUTION_INVALID" => Some(Self::ImgResolutionInvalid),
"IMG_RESOLUTION_1K" => Some(Self::ImgResolution1k),
"IMG_RESOLUTION_2K" => Some(Self::ImgResolution2k),
_ => None,
}
}
}
/// Generated client implementations.
pub mod image_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// An API service for interaction with image generation models.
#[derive(Debug, Clone)]
pub struct ImageClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ImageClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> ImageClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> ImageClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
ImageClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Create an image based on a text prompt and optionally another image.
pub async fn generate_image(
&mut self,
request: impl tonic::IntoRequest<super::GenerateImageRequest>,
) -> std::result::Result<tonic::Response<super::ImageResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Image/GenerateImage",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Image", "GenerateImage"));
self.inner.unary(req, path, codec).await
}
}
}
/// Request to get a text completion response sampling.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SampleTextRequest {
/// Text prompts to sample on.
#[prost(string, repeated, tag = "1")]
pub prompt: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Name or alias of the model to be used.
#[prost(string, tag = "3")]
pub model: ::prost::alloc::string::String,
/// The number of completions to create concurrently. A single completion will
/// be generated if the parameter is unset. Each completion is charged at the
/// same rate. You can generate at most 128 concurrent completions.
#[prost(int32, optional, tag = "8")]
pub n: ::core::option::Option<i32>,
/// The maximum number of tokens to sample. If unset, the model samples until
/// one of the following stop-conditions is reached:
///
/// * The context length of the model is exceeded
/// * One of the `stop` sequences has been observed.
///
/// We recommend choosing a reasonable value to reduce the risk of accidental
/// long-generations that consume many tokens.
#[prost(int32, optional, tag = "7")]
pub max_tokens: ::core::option::Option<i32>,
/// A random seed used to make the sampling process deterministic. This is
/// provided in a best-effort basis without guarantee that sampling is 100%
/// deterministic given a seed. This is primarily provided for short-lived
/// testing purposes. Given a fixed request and seed, the answers may change
/// over time as our systems evolve.
#[prost(int32, optional, tag = "11")]
pub seed: ::core::option::Option<i32>,
/// String patterns that will cause the sampling procedure to stop prematurely
/// when observed.
/// Note that the completion is based on individual tokens and sampling can
/// only terminate at token boundaries. If a stop string is a substring of an
/// individual token, the completion will include the entire token, which
/// extends beyond the stop string.
/// For example, if `stop = \["wor"\]` and we prompt the model with "hello" to
/// which it responds with "world", then the sampling procedure will stop after
/// observing the "world" token and the completion will contain
/// the entire world "world" even though the stop string was just "wor".
/// You can provide at most 8 stop strings.
#[prost(string, repeated, tag = "12")]
pub stop: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// A number between 0 and 2 used to control the variance of completions.
/// The smaller the value, the more deterministic the model will become. For
/// example, if we sample 1000 answers to the same prompt at a temperature of
/// 0.001, then most of the 1000 answers will be identical. Conversely, if we
/// conduct the same experiment at a temperature of 2, virtually no two answers
/// will be identical. Note that increasing the temperature will cause
/// the model to hallucinate more strongly.
#[prost(float, optional, tag = "14")]
pub temperature: ::core::option::Option<f32>,
/// A number between 0 and 1 controlling the likelihood of the model to use
/// less-common answers. Recall that the model produces a probability for
/// each token. This means, for any choice of token there are thousands of
/// possibilities to choose from. This parameter controls the "nucleus sampling
/// algorithm". Instead of considering every possible token at every step, we
/// only look at the K tokens who's probabilities exceed `top_p`.
/// For example, if we set `top_p = 0.9`, then the set of tokens we actually
/// sample from, will have a probability mass of at least 90%. In practice,
/// low values will make the model more deterministic.
#[prost(float, optional, tag = "15")]
pub top_p: ::core::option::Option<f32>,
/// Number between -2.0 and 2.0.
/// Positive values penalize new tokens based on their existing frequency in the text so far,
/// decreasing the model's likelihood to repeat the same line verbatim.
#[prost(float, optional, tag = "13")]
pub frequency_penalty: ::core::option::Option<f32>,
/// Whether to return log probabilities of the output tokens or not.
/// If true, returns the log probabilities of each output token returned in the content of message.
#[prost(bool, tag = "5")]
pub logprobs: bool,
/// Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
/// Not supported by grok-3 models.
#[prost(float, optional, tag = "9")]
pub presence_penalty: ::core::option::Option<f32>,
/// An integer between 0 and 8 specifying the number of most likely tokens to return at each token position,
/// each with an associated log probability.
/// logprobs must be set to true if this parameter is used.
#[prost(int32, optional, tag = "6")]
pub top_logprobs: ::core::option::Option<i32>,
/// An opaque string supplied by the API client (customer) to identify a user.
/// The string will be stored in the logs and can be used in customer service
/// requests to identify certain requests.
#[prost(string, tag = "17")]
pub user: ::prost::alloc::string::String,
}
/// Response of a text completion response sampling.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SampleTextResponse {
/// The ID of this request. This ID will also show up on your billing records
/// and you can use it when contacting us regarding a specific request.
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
/// Completions in response to the input messages. The number of completions is
/// controlled via the `n` parameter on the request.
#[prost(message, repeated, tag = "2")]
pub choices: ::prost::alloc::vec::Vec<SampleChoice>,
/// A UNIX timestamp (UTC) indicating when the response object was created.
/// The timestamp is taken when the model starts generating response.
#[prost(message, optional, tag = "5")]
pub created: ::core::option::Option<::prost_types::Timestamp>,
/// The name of the model used for the request. This model name contains
/// the actual model name used rather than any aliases.
/// This means the this can be `grok-2-1212` even when the request was
/// specifying `grok-2-latest`.
#[prost(string, tag = "6")]
pub model: ::prost::alloc::string::String,
/// Note supported yet. Included for compatibility reasons.
#[prost(string, tag = "7")]
pub system_fingerprint: ::prost::alloc::string::String,
/// The number of tokens consumed by this request.
#[prost(message, optional, tag = "9")]
pub usage: ::core::option::Option<SamplingUsage>,
}
/// Contains the response generated by the model.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SampleChoice {
/// Indicating why the model stopped sampling.
#[prost(enumeration = "FinishReason", tag = "1")]
pub finish_reason: i32,
/// The index of this choice in the list of choices. If you set `n > 1` on
/// your request, you will receive more than one choice in your response.
#[prost(int32, tag = "2")]
pub index: i32,
/// The actual text generated by the model.
#[prost(string, tag = "3")]
pub text: ::prost::alloc::string::String,
}
/// Reasons why the model stopped sampling.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum FinishReason {
/// Invalid reason.
ReasonInvalid = 0,
/// The max_len parameter specified on the input is reached.
ReasonMaxLen = 1,
/// The maximum context length of the model is reached.
ReasonMaxContext = 2,
/// One of the stop words was found.
ReasonStop = 3,
/// A tool call is included in the response.
ReasonToolCalls = 4,
/// Time limit has been reached.
ReasonTimeLimit = 5,
}
impl FinishReason {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::ReasonInvalid => "REASON_INVALID",
Self::ReasonMaxLen => "REASON_MAX_LEN",
Self::ReasonMaxContext => "REASON_MAX_CONTEXT",
Self::ReasonStop => "REASON_STOP",
Self::ReasonToolCalls => "REASON_TOOL_CALLS",
Self::ReasonTimeLimit => "REASON_TIME_LIMIT",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"REASON_INVALID" => Some(Self::ReasonInvalid),
"REASON_MAX_LEN" => Some(Self::ReasonMaxLen),
"REASON_MAX_CONTEXT" => Some(Self::ReasonMaxContext),
"REASON_STOP" => Some(Self::ReasonStop),
"REASON_TOOL_CALLS" => Some(Self::ReasonToolCalls),
"REASON_TIME_LIMIT" => Some(Self::ReasonTimeLimit),
_ => None,
}
}
}
/// Generated client implementations.
pub mod sample_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// An API service for sampling the responses of available language models.
#[derive(Debug, Clone)]
pub struct SampleClient<T> {
inner: tonic::client::Grpc<T>,
}
impl SampleClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> SampleClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> SampleClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
SampleClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Get raw sampling of text response from the model inference.
pub async fn sample_text(
&mut self,
request: impl tonic::IntoRequest<super::SampleTextRequest>,
) -> std::result::Result<
tonic::Response<super::SampleTextResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Sample/SampleText",
);
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("xai_api.Sample", "SampleText"));
self.inner.unary(req, path, codec).await
}
/// Get streaming raw sampling of text response from the model inference.
pub async fn sample_text_streaming(
&mut self,
request: impl tonic::IntoRequest<super::SampleTextRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::SampleTextResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Sample/SampleTextStreaming",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Sample", "SampleTextStreaming"));
self.inner.server_streaming(req, path, codec).await
}
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetCompletionsRequest {
/// A sequence of messages in the conversation. There must be at least a single
/// message that the model can respond to.
#[prost(message, repeated, tag = "1")]
pub messages: ::prost::alloc::vec::Vec<Message>,
/// Name of the model. This is the name as reported by the models API. More
/// details can be found on your console at <https://console.x.ai.>
#[prost(string, tag = "2")]
pub model: ::prost::alloc::string::String,
/// An opaque string supplied by the API client (customer) to identify a user.
/// The string will be stored in the logs and can be used in customer service
/// requests to identify certain requests.
#[prost(string, tag = "16")]
pub user: ::prost::alloc::string::String,
/// The number of completions to create concurrently. A single completion will
/// be generated if the parameter is unset. Each completion is charged at the
/// same rate. You can generate at most 128 concurrent completions.
/// PLEASE NOTE: This field is deprecated and will be removed in the future.
#[prost(int32, optional, tag = "8")]
pub n: ::core::option::Option<i32>,
/// The maximum number of tokens to sample. If unset, the model samples until
/// one of the following stop-conditions is reached:
///
/// * The context length of the model is exceeded
/// * One of the `stop` sequences has been observed.
/// * The time limit exceeds.
///
/// Note that for reasoning models and models that support function calls, the
/// limit is only applied to the main content and not to the reasoning content
/// or function calls.
///
/// We recommend choosing a reasonable value to reduce the risk of accidental
/// long-generations that consume many tokens.
#[prost(int32, optional, tag = "7")]
pub max_tokens: ::core::option::Option<i32>,
/// A random seed used to make the sampling process deterministic. This is
/// provided in a best-effort basis without guarantee that sampling is 100%
/// deterministic given a seed. This is primarily provided for short-lived
/// testing purposes. Given a fixed request and seed, the answers may change
/// over time as our systems evolve.
#[prost(int32, optional, tag = "11")]
pub seed: ::core::option::Option<i32>,
/// String patterns that will cause the sampling procedure to stop prematurely
/// when observed.
/// Note that the completion is based on individual tokens and sampling can
/// only terminate at token boundaries. If a stop string is a substring of an
/// individual token, the completion will include the entire token, which
/// extends beyond the stop string.
/// For example, if `stop = \["wor"\]` and we prompt the model with "hello" to
/// which it responds with "world", then the sampling procedure will stop after
/// observing the "world" token and the completion will contain
/// the entire world "world" even though the stop string was just "wor".
/// You can provide at most 8 stop strings.
#[prost(string, repeated, tag = "12")]
pub stop: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// A number between 0 and 2 used to control the variance of completions.
/// The smaller the value, the more deterministic the model will become. For
/// example, if we sample 1000 answers to the same prompt at a temperature of
/// 0.001, then most of the 1000 answers will be identical. Conversely, if we
/// conduct the same experiment at a temperature of 2, virtually no two answers
/// will be identical. Note that increasing the temperature will cause
/// the model to hallucinate more strongly.
#[prost(float, optional, tag = "14")]
pub temperature: ::core::option::Option<f32>,
/// A number between 0 and 1 controlling the likelihood of the model to use
/// less-common answers. Recall that the model produces a probability for
/// each token. This means, for any choice of token there are thousands of
/// possibilities to choose from. This parameter controls the "nucleus sampling
/// algorithm". Instead of considering every possible token at every step, we
/// only look at the K tokens who's probabilities exceed `top_p`.
/// For example, if we set `top_p = 0.9`, then the set of tokens we actually
/// sample from, will have a probability mass of at least 90%. In practice,
/// low values will make the model more deterministic.
#[prost(float, optional, tag = "15")]
pub top_p: ::core::option::Option<f32>,
/// If set to true, log probabilities of the sampling are returned.
#[prost(bool, tag = "5")]
pub logprobs: bool,
/// Number of top log probabilities to return.
#[prost(int32, optional, tag = "6")]
pub top_logprobs: ::core::option::Option<i32>,
/// A list of tools the model may call. Currently, only functions are supported
/// as a tool. Use this to provide a list of functions the model may generate
/// JSON inputs for.
#[prost(message, repeated, tag = "17")]
pub tools: ::prost::alloc::vec::Vec<Tool>,
/// Controls if the model can, should, or must not use tools.
#[prost(message, optional, tag = "18")]
pub tool_choice: ::core::option::Option<ToolChoice>,
/// Formatting constraint on the response.
#[prost(message, optional, tag = "10")]
pub response_format: ::core::option::Option<ResponseFormat>,
/// Positive values penalize new tokens based on their existing frequency in
/// the text so far, decreasing the model's likelihood to repeat the same line
/// verbatim.
#[prost(float, optional, tag = "3")]
pub frequency_penalty: ::core::option::Option<f32>,
/// Positive values penalize new tokens based on whether they appear in
/// the text so far, increasing the model's likelihood to talk about
/// new topics.
#[prost(float, optional, tag = "9")]
pub presence_penalty: ::core::option::Option<f32>,
/// Constrains effort on reasoning for reasoning models. Default to `EFFORT_MEDIUM`.
#[prost(enumeration = "ReasoningEffort", optional, tag = "19")]
pub reasoning_effort: ::core::option::Option<i32>,
/// Set the parameters to be used for realtime data. If not set, no realtime data will be acquired by the model.
#[prost(message, optional, tag = "20")]
pub search_parameters: ::core::option::Option<SearchParameters>,
/// / If set to false, the model can perform maximum one tool call per response. Default to true.
#[prost(bool, optional, tag = "21")]
pub parallel_tool_calls: ::core::option::Option<bool>,
/// Previous response id. The messages from this response must be chained.
#[prost(string, optional, tag = "22")]
pub previous_response_id: ::core::option::Option<::prost::alloc::string::String>,
/// Whether to store request and responses. Default is false.
#[prost(bool, tag = "23")]
pub store_messages: bool,
/// Whether to use encrypted thinking for thinking trace rehydration.
#[prost(bool, tag = "24")]
pub use_encrypted_content: bool,
/// Maximum number of agentic tool calling turns allowed for this request.
/// If not set, defaults to the server's global cap.
/// The effective max_turns will be the min of the server's global cap and the request's max_turns.
/// This parameter will be ignored for any non-agentic requests.
/// With parallel tool calls, multiple tool calls can occur within a single turn,
/// so max_turns does not necessarily equal the total number of tool calls.
#[prost(int32, optional, tag = "25")]
pub max_turns: ::core::option::Option<i32>,
/// Allow the users to control what optional fields to be returned in the response.
#[prost(enumeration = "IncludeOption", repeated, tag = "26")]
pub include: ::prost::alloc::vec::Vec<i32>,
/// Number of agents to use for multi-agent models.
/// Only valid when model is a `multi-agent` model. Defaults to `AGENT_COUNT_UNSPECIFIED`.
#[prost(enumeration = "AgentCount", optional, tag = "29")]
pub agent_count: ::core::option::Option<i32>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetChatCompletionResponse {
/// The ID of this request. This ID will also show up on your billing records
/// and you can use it when contacting us regarding a specific request.
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
/// Model-generated outputs/responses to the input messages. Each output contains
/// the model's response including text content, reasoning traces, tool calls, and
/// metadata about the generation process.
#[prost(message, repeated, tag = "2")]
pub outputs: ::prost::alloc::vec::Vec<CompletionOutput>,
/// A UNIX timestamp (UTC) indicating when the response object was created.
/// The timestamp is taken when the model starts generating response.
#[prost(message, optional, tag = "5")]
pub created: ::core::option::Option<::prost_types::Timestamp>,
/// The name of the model used for the request. This model name contains
/// the actual model name used rather than any aliases.
/// This means the this can be `grok-2-1212` even when the request was
/// specifying `grok-2-latest`.
#[prost(string, tag = "6")]
pub model: ::prost::alloc::string::String,
/// This fingerprint represents the backend configuration that the model runs
/// with.
#[prost(string, tag = "7")]
pub system_fingerprint: ::prost::alloc::string::String,
/// The number of tokens consumed by this request.
#[prost(message, optional, tag = "9")]
pub usage: ::core::option::Option<SamplingUsage>,
/// / List of all the external pages (urls) used by the model to produce its final answer.
/// This is only present when live search is enabled, (That is `SearchParameters` have been defined in `GetCompletionsRequest`).
#[prost(string, repeated, tag = "10")]
pub citations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Settings used while generating the response.
#[prost(message, optional, tag = "11")]
pub settings: ::core::option::Option<RequestSettings>,
/// Debug output. Only available to trusted testers.
#[prost(message, optional, tag = "12")]
pub debug_output: ::core::option::Option<DebugOutput>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetChatCompletionChunk {
/// The ID of this request. This ID will also show up on your billing records
/// and you can use it when contacting us regarding a specific request.
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
/// Model-generated outputs/responses being streamed as they are generated.
/// Each output chunk contains incremental updates to the model's response.
#[prost(message, repeated, tag = "2")]
pub outputs: ::prost::alloc::vec::Vec<CompletionOutputChunk>,
/// A UNIX timestamp (UTC) indicating when the response object was created.
/// The timestamp is taken when the model starts generating response.
#[prost(message, optional, tag = "3")]
pub created: ::core::option::Option<::prost_types::Timestamp>,
/// The name of the model used for the request. This model name contains
/// the actual model name used rather than any aliases.
/// This means the this can be `grok-2-1212` even when the request was
/// specifying `grok-2-latest`.
#[prost(string, tag = "4")]
pub model: ::prost::alloc::string::String,
/// This fingerprint represents the backend configuration that the model runs
/// with.
#[prost(string, tag = "5")]
pub system_fingerprint: ::prost::alloc::string::String,
/// The total number of tokens consumed when this chunk was streamed. Note that
/// this is not the final number of tokens billed unless this is the last chunk
/// in the stream.
#[prost(message, optional, tag = "6")]
pub usage: ::core::option::Option<SamplingUsage>,
/// / List of all the external pages used by the model to answer. Only populated for the last chunk.
/// This is only present for requests that make use of live search or server-side search tools.
#[prost(string, repeated, tag = "7")]
pub citations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Only available for teams that have debugging privileges.
#[prost(message, optional, tag = "10")]
pub debug_output: ::core::option::Option<DebugOutput>,
}
/// Response from GetDeferredCompletion, including the response if the completion
/// request has been processed without error.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetDeferredCompletionResponse {
/// Current status of the request.
#[prost(enumeration = "DeferredStatus", tag = "2")]
pub status: i32,
/// Response. Only present if `status=DONE`
#[prost(message, optional, tag = "1")]
pub response: ::core::option::Option<GetChatCompletionResponse>,
}
/// Contains the response generated by the model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompletionOutput {
/// Indicating why the model stopped sampling.
#[prost(enumeration = "FinishReason", tag = "1")]
pub finish_reason: i32,
/// The index of this output in the list of outputs. When multiple outputs are
/// generated, each output is assigned a sequential index starting from 0.
#[prost(int32, tag = "2")]
pub index: i32,
/// The actual message generated by the model.
#[prost(message, optional, tag = "3")]
pub message: ::core::option::Option<CompletionMessage>,
/// The log probabilities of the sampling.
#[prost(message, optional, tag = "4")]
pub logprobs: ::core::option::Option<LogProbs>,
}
/// Holds the model output (i.e. the result of the sampling process).
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompletionMessage {
/// The generated text based on the input prompt.
#[prost(string, tag = "1")]
pub content: ::prost::alloc::string::String,
/// Reasoning trace the model produced before issuing the final answer.
#[prost(string, tag = "4")]
pub reasoning_content: ::prost::alloc::string::String,
/// The role of the message author. Will always default to "assistant".
#[prost(enumeration = "MessageRole", tag = "2")]
pub role: i32,
/// The tools that the assistant wants to call.
#[prost(message, repeated, tag = "3")]
pub tool_calls: ::prost::alloc::vec::Vec<ToolCall>,
/// The encrypted content.
#[prost(string, tag = "5")]
pub encrypted_content: ::prost::alloc::string::String,
/// The citations that the model used to answer the question.
#[prost(message, repeated, tag = "6")]
pub citations: ::prost::alloc::vec::Vec<InlineCitation>,
}
/// Holds the differences (deltas) that when concatenated make up the entire
/// agent response.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompletionOutputChunk {
/// The actual text differences that need to be accumulated on the client.
#[prost(message, optional, tag = "1")]
pub delta: ::core::option::Option<Delta>,
/// The log probability of the choice.
#[prost(message, optional, tag = "2")]
pub logprobs: ::core::option::Option<LogProbs>,
/// Indicating why the model stopped sampling.
#[prost(enumeration = "FinishReason", tag = "3")]
pub finish_reason: i32,
/// The index of this output chunk in the list of output chunks.
#[prost(int32, tag = "4")]
pub index: i32,
}
/// The delta of a streaming response.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Delta {
/// The main model output/answer.
#[prost(string, tag = "1")]
pub content: ::prost::alloc::string::String,
/// Part of the model's reasoning trace.
#[prost(string, tag = "4")]
pub reasoning_content: ::prost::alloc::string::String,
/// The entity type who sent the message. For example, a message can be sent by
/// a user or the assistant.
#[prost(enumeration = "MessageRole", tag = "2")]
pub role: i32,
/// A list of tool calls if tool call is requested by the model.
#[prost(message, repeated, tag = "3")]
pub tool_calls: ::prost::alloc::vec::Vec<ToolCall>,
/// The encrypted content.
#[prost(string, tag = "5")]
pub encrypted_content: ::prost::alloc::string::String,
/// The citations that the model used to answer the question.
#[prost(message, repeated, tag = "6")]
pub citations: ::prost::alloc::vec::Vec<InlineCitation>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InlineCitation {
/// The display number for this citation (e.g., "1", "2", "3").
/// This ID is reused when the same source is cited multiple times in a
/// response, ensuring consistent numbering (e.g., the same URL always shows as
/// \[1\]).
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
/// The character position in the response text where the citation markdown
/// link begins. This is the index of the first '\[' character in the citation
/// format [id](id)(url). Uses inclusive indexing (the character at this index is
/// part of the citation).
#[prost(int32, tag = "2")]
pub start_index: i32,
/// The character position in the response text immediately after the citation
/// markdown link ends. This is the index after the final '\]' character in the
/// citation format [id](id)(url). Uses exclusive indexing (the character at this
/// index is NOT part of the citation). Together with start_index,
/// text\[start_index:end_index\] extracts the full citation link.
#[prost(int32, tag = "6")]
pub end_index: i32,
/// The citation type.
#[prost(oneof = "inline_citation::Citation", tags = "3, 4, 5")]
pub citation: ::core::option::Option<inline_citation::Citation>,
}
/// Nested message and enum types in `InlineCitation`.
pub mod inline_citation {
/// The citation type.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Citation {
/// The citation returned from the web search tool.
#[prost(message, tag = "3")]
WebCitation(super::WebCitation),
/// The citation returned from the X search tool.
#[prost(message, tag = "4")]
XCitation(super::XCitation),
/// The citation returned from the collections search tool.
#[prost(message, tag = "5")]
CollectionsCitation(super::CollectionsCitation),
}
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct WebCitation {
/// The url of the web page that the citation is from.
#[prost(string, tag = "1")]
pub url: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct XCitation {
/// The url of the X post or profile that the citation is from.
/// The url is always a x.com url.
#[prost(string, tag = "1")]
pub url: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CollectionsCitation {
/// The id of the file that the citation is from.
#[prost(string, tag = "1")]
pub file_id: ::prost::alloc::string::String,
/// The id of the chunk that the citation is from.
#[prost(string, tag = "2")]
pub chunk_id: ::prost::alloc::string::String,
/// The content of the chunk that the citation is from.
#[prost(string, tag = "3")]
pub chunk_content: ::prost::alloc::string::String,
/// The relevance score of the citation.
#[prost(float, tag = "4")]
pub score: f32,
/// The ids of the collections that the citation is from.
#[prost(string, repeated, tag = "5")]
pub collection_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
/// Holding the log probabilities of the sampling.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LogProbs {
/// A list of log probability entries, each corresponding to a sampled token
/// and its associated data.
#[prost(message, repeated, tag = "1")]
pub content: ::prost::alloc::vec::Vec<LogProb>,
}
/// Represents the logarithmic probability and metadata for a single sampled
/// token.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LogProb {
/// The text representation of the sampled token.
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
/// The logarithmic probability of this token being sampled, given the prior
/// context.
#[prost(float, tag = "2")]
pub logprob: f32,
/// The raw byte representation of the token, useful for handling non-text or
/// encoded data.
#[prost(bytes = "vec", tag = "3")]
pub bytes: ::prost::alloc::vec::Vec<u8>,
/// A list of the top alternative tokens and their log probabilities at this
/// sampling step.
#[prost(message, repeated, tag = "4")]
pub top_logprobs: ::prost::alloc::vec::Vec<TopLogProb>,
}
/// Represents an alternative token and its log probability among the top
/// candidates.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TopLogProb {
/// The text representation of an alternative token considered by the model.
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
/// The logarithmic probability of this alternative token being sampled.
#[prost(float, tag = "2")]
pub logprob: f32,
/// The raw byte representation of the alternative token.
#[prost(bytes = "vec", tag = "3")]
pub bytes: ::prost::alloc::vec::Vec<u8>,
}
/// Holds a single content element that is part of an input message.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Content {
#[prost(oneof = "content::Content", tags = "1, 2, 3")]
pub content: ::core::option::Option<content::Content>,
}
/// Nested message and enum types in `Content`.
pub mod content {
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
pub enum Content {
/// The content is a pure text message.
#[prost(string, tag = "1")]
Text(::prost::alloc::string::String),
/// The content is a single image.
#[prost(message, tag = "2")]
ImageUrl(super::ImageUrlContent),
/// The content is a file attachment (PDF, document, etc.).
#[prost(message, tag = "3")]
File(super::FileContent),
}
}
/// A file attachment in a message.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct FileContent {
/// The file ID from the Files API.
///
/// When set, the file content will be fetched via the Files API.
#[prost(string, tag = "1")]
pub file_id: ::prost::alloc::string::String,
/// Inline file bytes (optional).
///
/// When set, the file content is provided directly in the chat request and does
/// NOT require uploading to the Files API first.
///
/// Exactly one of `file_id`, `data`, or `url` SHOULD be set.
#[prost(bytes = "vec", tag = "2")]
pub data: ::prost::alloc::vec::Vec<u8>,
/// Filename for inline uploads.
///
/// Recommended when `data` is set. Used for display and may be used by
/// downstream systems to infer file type.
#[prost(string, tag = "3")]
pub filename: ::prost::alloc::string::String,
/// Optional MIME type for inline uploads (e.g. "application/pdf").
///
/// If unset, downstream systems may attempt to infer the MIME type from the
/// content and/or filename.
#[prost(string, tag = "4")]
pub mime_type: ::prost::alloc::string::String,
/// Public URL to a file attachment.
///
/// When set, the file will be fetched from this URL as an attachment.
/// Exactly one of `file_id`, `data`, or `url` SHOULD be set.
#[prost(string, tag = "5")]
pub url: ::prost::alloc::string::String,
}
/// A message in a conversation. This message is part of the model input. Each
/// message originates from a "role", which indicates the entity type who sent
/// the message. Messages can contain multiple content elements such as text and
/// images.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Message {
/// The content of the message. Some model support multi-modal message contents
/// that consist of text and images. At least one content element must be set
/// for each message.
#[prost(message, repeated, tag = "1")]
pub content: ::prost::alloc::vec::Vec<Content>,
/// Reasoning trace the model produced before issuing the final answer.
#[prost(string, optional, tag = "5")]
pub reasoning_content: ::core::option::Option<::prost::alloc::string::String>,
/// The entity type who sent the message. For example, a message can be sent by
/// a user or the assistant.
#[prost(enumeration = "MessageRole", tag = "2")]
pub role: i32,
/// The name of the entity who sent the message. The name can only be set if
/// the role is ROLE_USER.
#[prost(string, tag = "3")]
pub name: ::prost::alloc::string::String,
/// The tools that the assistant wants to call.
#[prost(message, repeated, tag = "4")]
pub tool_calls: ::prost::alloc::vec::Vec<ToolCall>,
/// The encrypted content.
#[prost(string, tag = "6")]
pub encrypted_content: ::prost::alloc::string::String,
/// The ID associating this tool response with a prior invocation (for role = ROLE_TOOL).
#[prost(string, optional, tag = "7")]
pub tool_call_id: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ToolChoice {
#[prost(oneof = "tool_choice::ToolChoice", tags = "1, 2")]
pub tool_choice: ::core::option::Option<tool_choice::ToolChoice>,
}
/// Nested message and enum types in `ToolChoice`.
pub mod tool_choice {
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
pub enum ToolChoice {
/// Force the model to perform in a given mode.
#[prost(enumeration = "super::ToolMode", tag = "1")]
Mode(i32),
/// Force the model to call a particular function.
#[prost(string, tag = "2")]
FunctionName(::prost::alloc::string::String),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Tool {
#[prost(oneof = "tool::Tool", tags = "1, 3, 4, 5, 6, 7, 8")]
pub tool: ::core::option::Option<tool::Tool>,
}
/// Nested message and enum types in `Tool`.
pub mod tool {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Tool {
/// Tool Call defined by user
#[prost(message, tag = "1")]
Function(super::Function),
/// Built in web search.
#[prost(message, tag = "3")]
WebSearch(super::WebSearch),
/// Built in X search.
#[prost(message, tag = "4")]
XSearch(super::XSearch),
/// Built in code execution.
#[prost(message, tag = "5")]
CodeExecution(super::CodeExecution),
/// Built in collections search.
#[prost(message, tag = "6")]
CollectionsSearch(super::CollectionsSearch),
/// A remote MCP server to use.
#[prost(message, tag = "7")]
Mcp(super::Mcp),
/// Built in attachment search.
#[prost(message, tag = "8")]
AttachmentSearch(super::AttachmentSearch),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Mcp {
/// A label for the server. if provided, this will be used to prefix tool calls.
#[prost(string, tag = "1")]
pub server_label: ::prost::alloc::string::String,
/// A description of the server.
#[prost(string, tag = "2")]
pub server_description: ::prost::alloc::string::String,
/// The URL of the MCP server.
#[prost(string, tag = "3")]
pub server_url: ::prost::alloc::string::String,
/// A list of tool names that are allowed to be called by the model. If empty, all tools are allowed.
#[prost(string, repeated, tag = "4")]
pub allowed_tool_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// An optional authorization token to use when calling the MCP server. This will be set as the Authorization header.
#[prost(string, optional, tag = "5")]
pub authorization: ::core::option::Option<::prost::alloc::string::String>,
/// Extra headers that will be included in the request to the MCP server.
#[prost(map = "string, string", tag = "6")]
pub extra_headers: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct WebSearch {
/// List of website domains (without protocol specification or subdomains) to exclude from search results (e.g., \["example.com"\]).
/// Use this to prevent results from unwanted sites. A maximum of 5 websites can be excluded.
/// This parameter cannot be set together with `allowed_domains`.
#[prost(string, repeated, tag = "1")]
pub excluded_domains: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// List of website domains (without protocol specification or subdomains)
/// to restrict search results to (e.g., \["example.com"\]). A maximum of 5 websites can be allowed.
/// Use this as a whitelist to limit results to only these specific sites; no other websites will
/// be considered. If no relevant information is found on these websites, the number of results
/// returned might be smaller than `max_search_results` set in `SearchParameters`. Note: This
/// parameter cannot be set together with `excluded_domains`.
#[prost(string, repeated, tag = "2")]
pub allowed_domains: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Enable image understanding in downstream tools (e.g. allow fetching and interpreting images).
/// When true, the server may add image viewing tools to the active MCP toolset.
#[prost(bool, optional, tag = "3")]
pub enable_image_understanding: ::core::option::Option<bool>,
/// The user location to use for a preference on the search results.
/// Setting this will make the agentic search results more relevant to the specified location,
/// which is useful for geolocation-based search results refinement.
#[prost(message, optional, tag = "4")]
pub user_location: ::core::option::Option<WebSearchUserLocation>,
}
/// The user location to use for a preference on the search results.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct WebSearchUserLocation {
/// Two-letter ISO 3166-1 alpha-2 country code, like US, GB, etc.
#[prost(string, optional, tag = "1")]
pub country: ::core::option::Option<::prost::alloc::string::String>,
/// Free text string for the city.
#[prost(string, optional, tag = "2")]
pub city: ::core::option::Option<::prost::alloc::string::String>,
/// Free text string for the region.
#[prost(string, optional, tag = "3")]
pub region: ::core::option::Option<::prost::alloc::string::String>,
/// IANA timezone like America/Chicago, Europe/London, etc.
#[prost(string, optional, tag = "4")]
pub timezone: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct XSearch {
/// Optional start date for search results in ISO-8601 YYYY-MM-DD format (e.g., "2024-05-24").
/// Only content after this date will be considered. Defaults to unset (no start date restriction).
/// See <https://en.wikipedia.org/wiki/ISO_8601> for format details.
#[prost(message, optional, tag = "1")]
pub from_date: ::core::option::Option<::prost_types::Timestamp>,
/// Optional end date for search results in ISO-8601 YYYY-MM-DD format (e.g., "2024-12-24").
/// Only content before this date will be considered. Defaults to unset (no end date restriction).
/// See <https://en.wikipedia.org/wiki/ISO_8601> for format details.
#[prost(message, optional, tag = "2")]
pub to_date: ::core::option::Option<::prost_types::Timestamp>,
/// Optional list of X usernames (without the '@' symbol) to limit search results to posts
/// from specific accounts (e.g., \["xai"\]). If set, only posts authored by these
/// handles will be considered in the agentic search.
/// This field can not be set together with `excluded_x_handles`.
/// Defaults to unset (no exclusions).
#[prost(string, repeated, tag = "3")]
pub allowed_x_handles: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Optional list of X usernames (without the '@' symbol) used to exclude posts from specific accounts.
/// If set, posts authored by these handles will be excluded from the agentic search results.
/// This field can not be set together with `allowed_x_handles`.
/// Defaults to unset (no exclusions).
#[prost(string, repeated, tag = "4")]
pub excluded_x_handles: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Enable image understanding in downstream tools (e.g. allow fetching and interpreting images).
/// When true, the server may add image viewing tools to the active MCP toolset.
#[prost(bool, optional, tag = "5")]
pub enable_image_understanding: ::core::option::Option<bool>,
/// Enable video understanding in downstream tools (e.g. allow fetching and interpreting videos).
/// When true, the server may add video viewing tools to the active MCP toolset.
#[prost(bool, optional, tag = "6")]
pub enable_video_understanding: ::core::option::Option<bool>,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CodeExecution {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CollectionsSearch {
/// The ID(s) of the source collection(s) within which the search should be performed.
/// A maximum of 10 collections IDs can be used for search.
#[prost(string, repeated, tag = "1")]
pub collection_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Optional number of chunks to be returned for each collections search.
/// Defaults to 10.
#[prost(int32, optional, tag = "2")]
pub limit: ::core::option::Option<i32>,
/// User-defined instructions to be included in the search query. Defaults to generic search
/// instructions used by the collections search backend if unset.
#[prost(string, optional, tag = "3")]
pub instructions: ::core::option::Option<::prost::alloc::string::String>,
/// How to perform the document search. Defaults to hybrid retrieval when unset.
#[prost(oneof = "collections_search::RetrievalMode", tags = "4, 5, 6")]
pub retrieval_mode: ::core::option::Option<collections_search::RetrievalMode>,
}
/// Nested message and enum types in `CollectionsSearch`.
pub mod collections_search {
/// How to perform the document search. Defaults to hybrid retrieval when unset.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum RetrievalMode {
/// Perform hybrid retrieval combining keyword and semantic search.
#[prost(message, tag = "4")]
HybridRetrieval(super::HybridRetrieval),
/// Perform pure semantic retrieval using dense embeddings.
#[prost(message, tag = "5")]
SemanticRetrieval(super::SemanticRetrieval),
/// Perform keyword-based retrieval using sparse embeddings.
#[prost(message, tag = "6")]
KeywordRetrieval(super::KeywordRetrieval),
}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct AttachmentSearch {
/// Optional number of files to limit the search to.
#[prost(int32, optional, tag = "2")]
pub limit: ::core::option::Option<i32>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Function {
/// Name of the function.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Description of the function.
#[prost(string, tag = "2")]
pub description: ::prost::alloc::string::String,
/// Not supported: Only kept for compatibility reasons.
#[prost(bool, tag = "3")]
pub strict: bool,
/// The parameters the functions accepts, described as a JSON Schema object.
#[prost(string, tag = "4")]
pub parameters: ::prost::alloc::string::String,
}
/// Content of a tool call, typically in a response from model.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ToolCall {
/// The ID of the tool call.
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
/// Information to indicate whether the tool call needs to be executed on client side or server side.
/// By default, it will be a client-side tool call if not specified.
#[prost(enumeration = "ToolCallType", tag = "2")]
pub r#type: i32,
/// Status of the tool call.
#[prost(enumeration = "ToolCallStatus", tag = "3")]
pub status: i32,
/// Error message if the tool call is failed.
#[prost(string, optional, tag = "4")]
pub error_message: ::core::option::Option<::prost::alloc::string::String>,
/// Information regarding invoking the tool call.
#[prost(oneof = "tool_call::Tool", tags = "10")]
pub tool: ::core::option::Option<tool_call::Tool>,
}
/// Nested message and enum types in `ToolCall`.
pub mod tool_call {
/// Information regarding invoking the tool call.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
pub enum Tool {
#[prost(message, tag = "10")]
Function(super::FunctionCall),
}
}
/// Tool call information.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct FunctionCall {
/// Name of the function to call.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Arguments used to call the function as json string.
#[prost(string, tag = "2")]
pub arguments: ::prost::alloc::string::String,
}
/// The response format for structured response.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ResponseFormat {
/// Type of format expected for the response. Default to `FORMAT_TYPE_TEXT`
#[prost(enumeration = "FormatType", tag = "1")]
pub format_type: i32,
/// The JSON schema that the response should conform to.
/// Only considered if `format_type` is `FORMAT_TYPE_JSON_SCHEMA`.
#[prost(string, optional, tag = "2")]
pub schema: ::core::option::Option<::prost::alloc::string::String>,
}
/// Parameters for configuring search behavior in a chat request.
///
/// This message allows customization of search functionality when using models that support
/// searching external sources for information. You can specify which sources to search,
/// set date ranges for relevant content, control the search mode, and configure how
/// results are returned.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SearchParameters {
/// Controls when search is performed. Possible values are:
///
/// * OFF_SEARCH_MODE (default): No search is performed, and no external data will be considered.
/// * ON_SEARCH_MODE: Search is always performed when sampling from the model and the model will search in every source provided for relevant data.
/// * AUTO_SEARCH_MODE: The model decides whether to perform a search based on the prompt and which sources to use.
#[prost(enumeration = "SearchMode", tag = "1")]
pub mode: i32,
/// A list of search sources to query, such as web, news, X, or RSS feeds.
/// Multiple sources can be specified. If no sources are provided, the model will default to
/// searching the web and X.
#[prost(message, repeated, tag = "9")]
pub sources: ::prost::alloc::vec::Vec<Source>,
/// Optional start date for search results in ISO-8601 YYYY-MM-DD format (e.g., "2024-05-24").
/// Only content after this date will be considered. Defaults to unset (no start date restriction).
/// See <https://en.wikipedia.org/wiki/ISO_8601> for format details.
#[prost(message, optional, tag = "4")]
pub from_date: ::core::option::Option<::prost_types::Timestamp>,
/// Optional end date for search results in ISO-8601 YYYY-MM-DD format (e.g., "2024-12-24").
/// Only content before this date will be considered. Defaults to unset (no end date restriction).
/// See <https://en.wikipedia.org/wiki/ISO_8601> for format details.
#[prost(message, optional, tag = "5")]
pub to_date: ::core::option::Option<::prost_types::Timestamp>,
/// If set to true, the model will return a list of citations (URLs or references)
/// to the sources used in generating the response. Defaults to true.
#[prost(bool, tag = "7")]
pub return_citations: bool,
/// Optional limit on the number of search results to consider
/// when generating a response. Must be in the range \[1, 30\]. Defaults to 15.
#[prost(int32, optional, tag = "8")]
pub max_search_results: ::core::option::Option<i32>,
}
/// Defines a source for search requests, specifying the type of content to search.
/// This message acts as a container for different types of search sources. Only one type
/// of source can be specified per instance using the oneof field.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Source {
#[prost(oneof = "source::Source", tags = "1, 2, 3, 4")]
pub source: ::core::option::Option<source::Source>,
}
/// Nested message and enum types in `Source`.
pub mod source {
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
pub enum Source {
/// Configuration for searching online web content. Use this to search general websites
/// with options to filter by country, exclude specific domains, or only allow specific domains.
#[prost(message, tag = "1")]
Web(super::WebSource),
/// Configuration for searching recent articles and reports from news outlets.
/// Useful for current events or topic-specific updates.
#[prost(message, tag = "2")]
News(super::NewsSource),
/// Configuration for searching content on X. Allows focusing on
/// specific user handles for targeted content.
#[prost(message, tag = "3")]
X(super::XSource),
/// Configuration for searching content from RSS feeds. Requires specific feed URLs
/// to query.
#[prost(message, tag = "4")]
Rss(super::RssSource),
}
}
/// Configuration for a web search source in search requests.
///
/// This message configures a source for searching online web content. It allows specification
/// of regional content through country codes and filtering of results by excluding or allowing
/// specific websites.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct WebSource {
/// List of website domains (without protocol specification or subdomains) to exclude from search results (e.g., \["example.com"\]).
/// Use this to prevent results from unwanted sites. A maximum of 5 websites can be excluded.
/// This parameter cannot be set together with `allowed_websites`.
#[prost(string, repeated, tag = "2")]
pub excluded_websites: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// List of website domains (without protocol specification or subdomains)
/// to restrict search results to (e.g., \["example.com"\]). A maximum of 5 websites can be allowed.
/// Use this as a whitelist to limit results to only these specific sites; no other websites will
/// be considered. If no relevant information is found on these websites, the number of results
/// returned might be smaller than `max_search_results` set in `SearchParameters`. Note: This
/// parameter cannot be set together with `excluded_websites`.
#[prost(string, repeated, tag = "5")]
pub allowed_websites: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Optional ISO alpha-2 country code (e.g., "BE" for Belgium) to limit search results
/// to content from a specific region or country. Defaults to unset (global search).
/// See <https://en.wikipedia.org/wiki/ISO_3166-2> for valid codes.
#[prost(string, optional, tag = "3")]
pub country: ::core::option::Option<::prost::alloc::string::String>,
/// Whether to exclude adult content from the search results. Defaults to true.
#[prost(bool, tag = "4")]
pub safe_search: bool,
}
/// Configuration for a news search source in search requests.
///
/// This message configures a source for searching recent articles and reports from news outlets.
/// It is useful for obtaining current events or topic-specific updates with regional filtering.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct NewsSource {
/// List of website domains (without protocol specification or subdomains)
/// to exclude from search results (e.g., \["example.com"\]). A maximum of 5 websites can be excluded.
/// Use this to prevent results from specific news sites. Defaults to unset (no exclusions).
#[prost(string, repeated, tag = "2")]
pub excluded_websites: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Optional ISO alpha-2 country code (e.g., "BE" for Belgium) to limit search results
/// to news from a specific region or country. Defaults to unset (global news).
/// See <https://en.wikipedia.org/wiki/ISO_3166-2> for valid codes.
#[prost(string, optional, tag = "3")]
pub country: ::core::option::Option<::prost::alloc::string::String>,
/// Whether to exclude adult content from the search results. Defaults to true.
#[prost(bool, tag = "4")]
pub safe_search: bool,
}
/// Configuration for an X (formerly Twitter) search source in search requests.
///
/// This message configures a source for searching content on X. It allows focusing the search
/// on specific user handles to retrieve targeted posts and interactions.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct XSource {
/// Optional list of X usernames (without the '@' symbol) to limit search results to posts
/// from specific accounts (e.g., \["xai"\]). If set, only posts authored by these
/// handles will be considered in the live search.
/// This field can not be set together with `excluded_x_handles`.
/// Defaults to unset (no exclusions).
#[prost(string, repeated, tag = "7")]
pub included_x_handles: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Optional list of X usernames (without the '@' symbol) used to exclude posts from specific accounts.
/// If set, posts authored by these handles will be excluded from the live search results.
/// This field can not be set together with `included_x_handles`.
/// Defaults to unset (no exclusions).
#[prost(string, repeated, tag = "8")]
pub excluded_x_handles: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Optional post favorite count threshold. Defaults to unset (don't filter posts by post favorite count).
/// If set, only posts with a favorite count greater than or equal to this threshold will be considered.
#[prost(int32, optional, tag = "9")]
pub post_favorite_count: ::core::option::Option<i32>,
/// Optional post view count threshold. Defaults to unset (don't filter posts by post view count).
/// If set, only posts with a view count greater than or equal to this threshold will be considered.
#[prost(int32, optional, tag = "10")]
pub post_view_count: ::core::option::Option<i32>,
}
/// Configuration for an RSS search source in search requests.
///
/// This message configures a source for searching content from RSS feeds. It requires specific
/// feed URLs to query for content updates.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct RssSource {
/// List of RSS feed URLs to search. Each URL must point to a valid RSS feed.
/// At least one link must be provided.
#[prost(string, repeated, tag = "1")]
pub links: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RequestSettings {
/// Max number of tokens that can be generated in a response. This includes both output and reasoning tokens.
#[prost(int32, optional, tag = "1")]
pub max_tokens: ::core::option::Option<i32>,
/// / If set to false, the model can perform maximum one tool call. Default to true.
#[prost(bool, tag = "2")]
pub parallel_tool_calls: bool,
/// The ID of the previous response from the model.
#[prost(string, optional, tag = "3")]
pub previous_response_id: ::core::option::Option<::prost::alloc::string::String>,
/// Constrains effort on reasoning for reasoning models. Default to `EFFORT_MEDIUM`.
#[prost(enumeration = "ReasoningEffort", optional, tag = "4")]
pub reasoning_effort: ::core::option::Option<i32>,
/// A number between 0 and 2 used to control the variance of completions.
/// The smaller the value, the more deterministic the model will become. For
/// example, if we sample 1000 answers to the same prompt at a temperature of
/// 0.001, then most of the 1000 answers will be identical. Conversely, if we
/// conduct the same experiment at a temperature of 2, virtually no two answers
/// will be identical. Note that increasing the temperature will cause
/// the model to hallucinate more strongly.
#[prost(float, optional, tag = "5")]
pub temperature: ::core::option::Option<f32>,
/// Formatting constraint on the response.
#[prost(message, optional, tag = "6")]
pub response_format: ::core::option::Option<ResponseFormat>,
/// Controls if the model can, should, or must not use tools.
#[prost(message, optional, tag = "7")]
pub tool_choice: ::core::option::Option<ToolChoice>,
/// A list of tools the model may call. Currently, only functions are supported
/// as a tool. Use this to provide a list of functions the model may generate
/// JSON inputs for.
#[prost(message, repeated, tag = "8")]
pub tools: ::prost::alloc::vec::Vec<Tool>,
/// A number between 0 and 1 controlling the likelihood of the model to use
/// less-common answers. Recall that the model produces a probability for
/// each token. This means, for any choice of token there are thousands of
/// possibilities to choose from. This parameter controls the "nucleus sampling
/// algorithm". Instead of considering every possible token at every step, we
/// only look at the K tokens who's probabilities exceed `top_p`.
/// For example, if we set `top_p = 0.9`, then the set of tokens we actually
/// sample from, will have a probability mass of at least 90%. In practice,
/// low values will make the model more deterministic.
#[prost(float, optional, tag = "9")]
pub top_p: ::core::option::Option<f32>,
/// An opaque string supplied by the API client (customer) to identify a user.
/// The string will be stored in the logs and can be used in customer service
/// requests to identify certain requests.
#[prost(string, tag = "10")]
pub user: ::prost::alloc::string::String,
/// Set the parameters to be used for realtime data. If not set, no realtime data will be acquired by the model.
#[prost(message, optional, tag = "11")]
pub search_parameters: ::core::option::Option<SearchParameters>,
/// Whether to store request and responses. Default is false.
#[prost(bool, tag = "12")]
pub store_messages: bool,
/// Whether to use encrypted thinking for thinking trace rehydration.
#[prost(bool, tag = "13")]
pub use_encrypted_content: bool,
/// Allow the users to control what optional fields to be returned in the response.
#[prost(enumeration = "IncludeOption", repeated, tag = "14")]
pub include: ::prost::alloc::vec::Vec<i32>,
}
/// Request to retrieve a stored completion response.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetStoredCompletionRequest {
/// The response id to be retrieved.
#[prost(string, tag = "1")]
pub response_id: ::prost::alloc::string::String,
}
/// Request to delete a stored completion response.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct DeleteStoredCompletionRequest {
/// The response id to be deleted.
#[prost(string, tag = "1")]
pub response_id: ::prost::alloc::string::String,
}
/// Response for deleting a stored completion.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct DeleteStoredCompletionResponse {
/// The response id that was deleted.
#[prost(string, tag = "1")]
pub response_id: ::prost::alloc::string::String,
}
/// Holds debug information. Only available to trusted testers.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct DebugOutput {
/// Number of attempts made to the model.
#[prost(int32, tag = "1")]
pub attempts: i32,
/// The request received from the user.
#[prost(string, tag = "2")]
pub request: ::prost::alloc::string::String,
/// The prompt sent to the model in text form.
#[prost(string, tag = "3")]
pub prompt: ::prost::alloc::string::String,
/// The JSON-serialized request sent to the inference engine.
#[prost(string, tag = "9")]
pub engine_request: ::prost::alloc::string::String,
/// The response(s) received from the model.
#[prost(string, repeated, tag = "4")]
pub responses: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// The raw chunks returned from the pipeline of samplers.
#[prost(string, repeated, tag = "12")]
pub chunks: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Number of cache reads
#[prost(uint32, tag = "5")]
pub cache_read_count: u32,
/// Size of cache read
#[prost(uint64, tag = "6")]
pub cache_read_input_bytes: u64,
/// Number of cache writes
#[prost(uint32, tag = "7")]
pub cache_write_count: u32,
/// Size of cache write
#[prost(uint64, tag = "8")]
pub cache_write_input_bytes: u64,
/// The lb address header
#[prost(string, tag = "10")]
pub lb_address: ::prost::alloc::string::String,
/// The tag of the sampler that served this request.
#[prost(string, tag = "11")]
pub sampler_tag: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum IncludeOption {
/// Default value / invalid option.
Invalid = 0,
/// Include the encrypted output from the web search tool in the response.
WebSearchCallOutput = 1,
/// Include the encrypted output from the X search tool in the response.
XSearchCallOutput = 2,
/// Include the plaintext output from the code execution tool in the response.
CodeExecutionCallOutput = 3,
/// Include the plaintext output from the collections search tool in the response.
CollectionsSearchCallOutput = 4,
/// Include the plaintext output from the attachment search tool in the response.
AttachmentSearchCallOutput = 5,
/// Include the plaintext output from the MCP tool in the response.
McpCallOutput = 6,
/// Include the inline citations in the final response.
InlineCitations = 7,
/// Stream back any chunks that are generated by the model or the agent tools
/// even if there is no user-visible content in the chunk, e.g. only the usage
/// statistics are being updated.
/// The chunks without user-visible content are not streamed to the client when
/// this option is not included by default.
/// This option is only available for streaming responses.
VerboseStreaming = 8,
}
impl IncludeOption {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Invalid => "INCLUDE_OPTION_INVALID",
Self::WebSearchCallOutput => "INCLUDE_OPTION_WEB_SEARCH_CALL_OUTPUT",
Self::XSearchCallOutput => "INCLUDE_OPTION_X_SEARCH_CALL_OUTPUT",
Self::CodeExecutionCallOutput => "INCLUDE_OPTION_CODE_EXECUTION_CALL_OUTPUT",
Self::CollectionsSearchCallOutput => {
"INCLUDE_OPTION_COLLECTIONS_SEARCH_CALL_OUTPUT"
}
Self::AttachmentSearchCallOutput => {
"INCLUDE_OPTION_ATTACHMENT_SEARCH_CALL_OUTPUT"
}
Self::McpCallOutput => "INCLUDE_OPTION_MCP_CALL_OUTPUT",
Self::InlineCitations => "INCLUDE_OPTION_INLINE_CITATIONS",
Self::VerboseStreaming => "INCLUDE_OPTION_VERBOSE_STREAMING",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"INCLUDE_OPTION_INVALID" => Some(Self::Invalid),
"INCLUDE_OPTION_WEB_SEARCH_CALL_OUTPUT" => Some(Self::WebSearchCallOutput),
"INCLUDE_OPTION_X_SEARCH_CALL_OUTPUT" => Some(Self::XSearchCallOutput),
"INCLUDE_OPTION_CODE_EXECUTION_CALL_OUTPUT" => {
Some(Self::CodeExecutionCallOutput)
}
"INCLUDE_OPTION_COLLECTIONS_SEARCH_CALL_OUTPUT" => {
Some(Self::CollectionsSearchCallOutput)
}
"INCLUDE_OPTION_ATTACHMENT_SEARCH_CALL_OUTPUT" => {
Some(Self::AttachmentSearchCallOutput)
}
"INCLUDE_OPTION_MCP_CALL_OUTPUT" => Some(Self::McpCallOutput),
"INCLUDE_OPTION_INLINE_CITATIONS" => Some(Self::InlineCitations),
"INCLUDE_OPTION_VERBOSE_STREAMING" => Some(Self::VerboseStreaming),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum MessageRole {
/// Default value / invalid role.
InvalidRole = 0,
/// User role.
RoleUser = 1,
/// Assistant role, normally the response from the model.
RoleAssistant = 2,
/// System role, typically for system instructions.
RoleSystem = 3,
/// Indicates a return from a tool call. Deprecated in favor of ROLE_TOOL.
#[deprecated]
RoleFunction = 4,
/// Indicates a return from a tool call.
RoleTool = 5,
/// Developer role, typically for developer instructions, e.g. tool usage instructions.
RoleDeveloper = 6,
}
impl MessageRole {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::InvalidRole => "INVALID_ROLE",
Self::RoleUser => "ROLE_USER",
Self::RoleAssistant => "ROLE_ASSISTANT",
Self::RoleSystem => "ROLE_SYSTEM",
#[allow(deprecated)]
Self::RoleFunction => "ROLE_FUNCTION",
Self::RoleTool => "ROLE_TOOL",
Self::RoleDeveloper => "ROLE_DEVELOPER",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"INVALID_ROLE" => Some(Self::InvalidRole),
"ROLE_USER" => Some(Self::RoleUser),
"ROLE_ASSISTANT" => Some(Self::RoleAssistant),
"ROLE_SYSTEM" => Some(Self::RoleSystem),
"ROLE_FUNCTION" => Some(#[allow(deprecated)] Self::RoleFunction),
"ROLE_TOOL" => Some(Self::RoleTool),
"ROLE_DEVELOPER" => Some(Self::RoleDeveloper),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ReasoningEffort {
InvalidEffort = 0,
EffortLow = 1,
EffortMedium = 2,
EffortHigh = 3,
EffortNone = 4,
}
impl ReasoningEffort {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::InvalidEffort => "INVALID_EFFORT",
Self::EffortLow => "EFFORT_LOW",
Self::EffortMedium => "EFFORT_MEDIUM",
Self::EffortHigh => "EFFORT_HIGH",
Self::EffortNone => "EFFORT_NONE",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"INVALID_EFFORT" => Some(Self::InvalidEffort),
"EFFORT_LOW" => Some(Self::EffortLow),
"EFFORT_MEDIUM" => Some(Self::EffortMedium),
"EFFORT_HIGH" => Some(Self::EffortHigh),
"EFFORT_NONE" => Some(Self::EffortNone),
_ => None,
}
}
}
/// Number of agents to use for multi-agent models.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum AgentCount {
/// Unspecified / unset value.
Unspecified = 0,
/// Use 4 agents.
AgentCount4 = 1,
/// Use 16 agents.
AgentCount16 = 2,
}
impl AgentCount {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "AGENT_COUNT_UNSPECIFIED",
Self::AgentCount4 => "AGENT_COUNT_4",
Self::AgentCount16 => "AGENT_COUNT_16",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"AGENT_COUNT_UNSPECIFIED" => Some(Self::Unspecified),
"AGENT_COUNT_4" => Some(Self::AgentCount4),
"AGENT_COUNT_16" => Some(Self::AgentCount16),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ToolMode {
/// Invalid tool mode.
Invalid = 0,
/// Let the model decide if a tool shall be used.
Auto = 1,
/// Force the model to not use tools.
None = 2,
/// Force the model to use tools.
Required = 3,
}
impl ToolMode {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Invalid => "TOOL_MODE_INVALID",
Self::Auto => "TOOL_MODE_AUTO",
Self::None => "TOOL_MODE_NONE",
Self::Required => "TOOL_MODE_REQUIRED",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"TOOL_MODE_INVALID" => Some(Self::Invalid),
"TOOL_MODE_AUTO" => Some(Self::Auto),
"TOOL_MODE_NONE" => Some(Self::None),
"TOOL_MODE_REQUIRED" => Some(Self::Required),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum FormatType {
/// Invalid format type.
Invalid = 0,
/// Raw text.
Text = 1,
/// Any JSON object.
JsonObject = 2,
/// Follow a JSON schema.
JsonSchema = 3,
}
impl FormatType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Invalid => "FORMAT_TYPE_INVALID",
Self::Text => "FORMAT_TYPE_TEXT",
Self::JsonObject => "FORMAT_TYPE_JSON_OBJECT",
Self::JsonSchema => "FORMAT_TYPE_JSON_SCHEMA",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"FORMAT_TYPE_INVALID" => Some(Self::Invalid),
"FORMAT_TYPE_TEXT" => Some(Self::Text),
"FORMAT_TYPE_JSON_OBJECT" => Some(Self::JsonObject),
"FORMAT_TYPE_JSON_SCHEMA" => Some(Self::JsonSchema),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ToolCallType {
Invalid = 0,
/// Indicates the tool is a client-side tool, and should be executed on client side.
/// Maps to `function_call` type in OAI Responses API.
ClientSideTool = 1,
/// Indicates the tool is a server-side web_search tool, and client side won't need to execute.
/// Maps to `web_search_call` type in OAI Responses API.
WebSearchTool = 2,
/// Indicates the tool is a server-side x_search tool, and client side won't need to execute.
/// Maps to `x_search_call` type in OAI Responses API.
XSearchTool = 3,
/// Indicates the tool is a server-side code_execution tool, and client side won't need to execute.
/// Maps to `code_interpreter_call` type in OAI Responses API.
CodeExecutionTool = 4,
/// Indicates the tool is a server-side collections_search tool, and client side won't need to execute.
/// Maps to `file_search_call` type in OAI Responses API.
CollectionsSearchTool = 5,
/// Indicates the tool is a server-side mcp_tool, and client side won't need to execute.
/// Maps to `mcp_call` type in OAI Responses API.
McpTool = 6,
/// Indicates the tool is a server-side attachment_search tool, and client side won't need to execute.
/// Maps to `attachment_search_call` type in OAI Responses API.
AttachmentSearchTool = 7,
}
impl ToolCallType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Invalid => "TOOL_CALL_TYPE_INVALID",
Self::ClientSideTool => "TOOL_CALL_TYPE_CLIENT_SIDE_TOOL",
Self::WebSearchTool => "TOOL_CALL_TYPE_WEB_SEARCH_TOOL",
Self::XSearchTool => "TOOL_CALL_TYPE_X_SEARCH_TOOL",
Self::CodeExecutionTool => "TOOL_CALL_TYPE_CODE_EXECUTION_TOOL",
Self::CollectionsSearchTool => "TOOL_CALL_TYPE_COLLECTIONS_SEARCH_TOOL",
Self::McpTool => "TOOL_CALL_TYPE_MCP_TOOL",
Self::AttachmentSearchTool => "TOOL_CALL_TYPE_ATTACHMENT_SEARCH_TOOL",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"TOOL_CALL_TYPE_INVALID" => Some(Self::Invalid),
"TOOL_CALL_TYPE_CLIENT_SIDE_TOOL" => Some(Self::ClientSideTool),
"TOOL_CALL_TYPE_WEB_SEARCH_TOOL" => Some(Self::WebSearchTool),
"TOOL_CALL_TYPE_X_SEARCH_TOOL" => Some(Self::XSearchTool),
"TOOL_CALL_TYPE_CODE_EXECUTION_TOOL" => Some(Self::CodeExecutionTool),
"TOOL_CALL_TYPE_COLLECTIONS_SEARCH_TOOL" => Some(Self::CollectionsSearchTool),
"TOOL_CALL_TYPE_MCP_TOOL" => Some(Self::McpTool),
"TOOL_CALL_TYPE_ATTACHMENT_SEARCH_TOOL" => Some(Self::AttachmentSearchTool),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ToolCallStatus {
/// The tool call is in progress.
InProgress = 0,
/// The tool call is completed.
Completed = 1,
/// The tool call is incomplete.
Incomplete = 2,
/// The tool call is failed.
Failed = 3,
}
impl ToolCallStatus {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::InProgress => "TOOL_CALL_STATUS_IN_PROGRESS",
Self::Completed => "TOOL_CALL_STATUS_COMPLETED",
Self::Incomplete => "TOOL_CALL_STATUS_INCOMPLETE",
Self::Failed => "TOOL_CALL_STATUS_FAILED",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"TOOL_CALL_STATUS_IN_PROGRESS" => Some(Self::InProgress),
"TOOL_CALL_STATUS_COMPLETED" => Some(Self::Completed),
"TOOL_CALL_STATUS_INCOMPLETE" => Some(Self::Incomplete),
"TOOL_CALL_STATUS_FAILED" => Some(Self::Failed),
_ => None,
}
}
}
/// Mode to control the web search.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SearchMode {
InvalidSearchMode = 0,
OffSearchMode = 1,
OnSearchMode = 2,
AutoSearchMode = 3,
}
impl SearchMode {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::InvalidSearchMode => "INVALID_SEARCH_MODE",
Self::OffSearchMode => "OFF_SEARCH_MODE",
Self::OnSearchMode => "ON_SEARCH_MODE",
Self::AutoSearchMode => "AUTO_SEARCH_MODE",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"INVALID_SEARCH_MODE" => Some(Self::InvalidSearchMode),
"OFF_SEARCH_MODE" => Some(Self::OffSearchMode),
"ON_SEARCH_MODE" => Some(Self::OnSearchMode),
"AUTO_SEARCH_MODE" => Some(Self::AutoSearchMode),
_ => None,
}
}
}
/// Generated client implementations.
pub mod chat_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// An API that exposes our language models via a Chat interface.
#[derive(Debug, Clone)]
pub struct ChatClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ChatClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> ChatClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> ChatClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
ChatClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Samples a response from the model and blocks until the response has been
/// fully generated.
pub async fn get_completion(
&mut self,
request: impl tonic::IntoRequest<super::GetCompletionsRequest>,
) -> std::result::Result<
tonic::Response<super::GetChatCompletionResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Chat/GetCompletion",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Chat", "GetCompletion"));
self.inner.unary(req, path, codec).await
}
/// Samples a response from the model and streams out the model tokens as they
/// are being generated.
pub async fn get_completion_chunk(
&mut self,
request: impl tonic::IntoRequest<super::GetCompletionsRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::GetChatCompletionChunk>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Chat/GetCompletionChunk",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Chat", "GetCompletionChunk"));
self.inner.server_streaming(req, path, codec).await
}
/// Starts sampling of the model and immediately returns a response containing
/// a request id. The request id may be used to poll
/// the `GetDeferredCompletion` RPC.
pub async fn start_deferred_completion(
&mut self,
request: impl tonic::IntoRequest<super::GetCompletionsRequest>,
) -> std::result::Result<
tonic::Response<super::StartDeferredResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Chat/StartDeferredCompletion",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Chat", "StartDeferredCompletion"));
self.inner.unary(req, path, codec).await
}
/// Gets the result of a deferred completion started by calling `StartDeferredCompletion`.
pub async fn get_deferred_completion(
&mut self,
request: impl tonic::IntoRequest<super::GetDeferredRequest>,
) -> std::result::Result<
tonic::Response<super::GetDeferredCompletionResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Chat/GetDeferredCompletion",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Chat", "GetDeferredCompletion"));
self.inner.unary(req, path, codec).await
}
/// Retrieve a stored response using the response ID.
pub async fn get_stored_completion(
&mut self,
request: impl tonic::IntoRequest<super::GetStoredCompletionRequest>,
) -> std::result::Result<
tonic::Response<super::GetChatCompletionResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Chat/GetStoredCompletion",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Chat", "GetStoredCompletion"));
self.inner.unary(req, path, codec).await
}
/// Delete a stored response using the response ID.
pub async fn delete_stored_completion(
&mut self,
request: impl tonic::IntoRequest<super::DeleteStoredCompletionRequest>,
) -> std::result::Result<
tonic::Response<super::DeleteStoredCompletionResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Chat/DeleteStoredCompletion",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Chat", "DeleteStoredCompletion"));
self.inner.unary(req, path, codec).await
}
}
}
/// Specifies a video by URL for video editing.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct VideoUrlContent {
/// Either a URL of the video (e.g., a public URL) or a base64-encoded video
/// as a data URL (e.g., "data:video/mp4;base64,...").
#[prost(string, tag = "1")]
pub url: ::prost::alloc::string::String,
}
/// Request message for generating a video.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenerateVideoRequest {
/// Input prompt to generate a video from.
#[prost(string, tag = "1")]
pub prompt: ::prost::alloc::string::String,
/// Optional input image for image-to-video generation.
/// If provided, generates video with this image as the first frame.
/// If omitted, generates text-to-video.
/// Supports the same formats as image generation: URL or base64-encoded image.
#[prost(message, optional, tag = "2")]
pub image: ::core::option::Option<ImageUrlContent>,
/// Name or alias of the video generation model to be used.
#[prost(string, tag = "3")]
pub model: ::prost::alloc::string::String,
/// Duration of the video to be generated in seconds (1-15 seconds).
#[prost(int32, optional, tag = "4")]
pub duration: ::core::option::Option<i32>,
/// Optional input video for video editing.
/// If provided, the video will be edited based on the prompt.
/// Supports URL or base64-encoded video data.
#[prost(message, optional, tag = "6")]
pub video: ::core::option::Option<VideoUrlContent>,
/// Optional aspect ratio for video generation.
/// Defaults to 16:9 if not specified.
#[prost(enumeration = "VideoAspectRatio", optional, tag = "7")]
pub aspect_ratio: ::core::option::Option<i32>,
/// Optional resolution for video generation.
/// Defaults to 480p if not specified.
#[prost(enumeration = "VideoResolution", optional, tag = "8")]
pub resolution: ::core::option::Option<i32>,
/// Optional reference images for reference-to-video (R2V) generation.
/// When provided (and `image` is not set), generates video using these images
/// as style/content references.
#[prost(message, repeated, tag = "13")]
pub reference_images: ::prost::alloc::vec::Vec<ImageUrlContent>,
}
/// Request for retrieving deferred video generation results.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetDeferredVideoRequest {
/// The ID of the request to get.
#[prost(string, tag = "1")]
pub request_id: ::prost::alloc::string::String,
}
/// The response from the video generation models containing the generated video.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct VideoResponse {
/// The generated video.
#[prost(message, optional, tag = "1")]
pub video: ::core::option::Option<GeneratedVideo>,
/// The model used to generate the video (ignoring aliases).
#[prost(string, tag = "2")]
pub model: ::prost::alloc::string::String,
/// Billing and cost information for this request.
#[prost(message, optional, tag = "3")]
pub usage: ::core::option::Option<SamplingUsage>,
/// Structured error describing why video generation failed.
/// Only present when the background generation encountered a failure
/// (either client error 4xx or server error 5xx).
#[prost(message, optional, tag = "6")]
pub error: ::core::option::Option<VideoError>,
/// Approximate completion percentage for the video generation task (0-100).
///
/// * When status is `PENDING`: progress is between 0-99, indicating current
/// completion.
/// * When status is `DONE`: progress is 100.
/// * When status is `FAILED`: progress is 0.
#[prost(int32, tag = "7")]
pub progress: i32,
}
/// Contains all data related to a generated video.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GeneratedVideo {
/// A url that points to the generated video.
#[prost(string, tag = "1")]
pub url: ::prost::alloc::string::String,
/// Duration of the generated video in seconds.
#[prost(int32, tag = "4")]
pub duration: i32,
/// Whether the video generated by the model respects moderation rules.
/// The field will be true if the video respects moderation rules. Otherwise
/// the field will be false and the video url field will be empty.
#[prost(bool, tag = "5")]
pub respect_moderation: bool,
}
/// Response from GetDeferredVideo, including the response if the video
/// generation request has been processed without error.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetDeferredVideoResponse {
/// Current status of the request.
#[prost(enumeration = "DeferredStatus", tag = "1")]
pub status: i32,
/// Response. Only present if `status=DONE` or `status=FAILED`.
/// When failed, the `error` field in VideoResponse describes the failure.
#[prost(message, optional, tag = "2")]
pub response: ::core::option::Option<VideoResponse>,
}
/// Structured error returned when video generation fails.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct VideoError {
/// Machine-readable error code (e.g. "invalid_argument", "internal_error").
#[prost(string, tag = "1")]
pub code: ::prost::alloc::string::String,
/// Human-readable error message describing the failure.
#[prost(string, tag = "2")]
pub message: ::prost::alloc::string::String,
}
/// Request message for extending an existing video.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ExtendVideoRequest {
/// Prompt describing what should happen next in the video.
#[prost(string, tag = "1")]
pub prompt: ::prost::alloc::string::String,
/// Input video to extend. The extension continues from the end of this video.
/// Supports URL or base64-encoded video data.
/// Input video must be between 2 and 30 seconds long.
#[prost(message, optional, tag = "2")]
pub video: ::core::option::Option<VideoUrlContent>,
/// Name or alias of the video generation model to be used.
#[prost(string, tag = "3")]
pub model: ::prost::alloc::string::String,
/// Duration of the extension segment to generate in seconds (1-10).
/// Defaults to 6 seconds if not specified.
#[prost(int32, optional, tag = "4")]
pub duration: ::core::option::Option<i32>,
}
/// Aspect ratio for video generation.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum VideoAspectRatio {
/// Invalid/unspecified aspect ratio - defaults to 16:9.
Unspecified = 0,
/// 1:1 aspect ratio (square).
VideoAspectRatio11 = 1,
/// 16:9 aspect ratio (wide landscape).
VideoAspectRatio169 = 2,
/// 9:16 aspect ratio (tall portrait).
VideoAspectRatio916 = 3,
/// 4:3 aspect ratio (standard landscape).
VideoAspectRatio43 = 4,
/// 3:4 aspect ratio (standard portrait).
VideoAspectRatio34 = 5,
/// 3:2 aspect ratio (photo landscape).
VideoAspectRatio32 = 6,
/// 2:3 aspect ratio (photo portrait).
VideoAspectRatio23 = 7,
}
impl VideoAspectRatio {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "VIDEO_ASPECT_RATIO_UNSPECIFIED",
Self::VideoAspectRatio11 => "VIDEO_ASPECT_RATIO_1_1",
Self::VideoAspectRatio169 => "VIDEO_ASPECT_RATIO_16_9",
Self::VideoAspectRatio916 => "VIDEO_ASPECT_RATIO_9_16",
Self::VideoAspectRatio43 => "VIDEO_ASPECT_RATIO_4_3",
Self::VideoAspectRatio34 => "VIDEO_ASPECT_RATIO_3_4",
Self::VideoAspectRatio32 => "VIDEO_ASPECT_RATIO_3_2",
Self::VideoAspectRatio23 => "VIDEO_ASPECT_RATIO_2_3",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"VIDEO_ASPECT_RATIO_UNSPECIFIED" => Some(Self::Unspecified),
"VIDEO_ASPECT_RATIO_1_1" => Some(Self::VideoAspectRatio11),
"VIDEO_ASPECT_RATIO_16_9" => Some(Self::VideoAspectRatio169),
"VIDEO_ASPECT_RATIO_9_16" => Some(Self::VideoAspectRatio916),
"VIDEO_ASPECT_RATIO_4_3" => Some(Self::VideoAspectRatio43),
"VIDEO_ASPECT_RATIO_3_4" => Some(Self::VideoAspectRatio34),
"VIDEO_ASPECT_RATIO_3_2" => Some(Self::VideoAspectRatio32),
"VIDEO_ASPECT_RATIO_2_3" => Some(Self::VideoAspectRatio23),
_ => None,
}
}
}
/// Resolution for video generation.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum VideoResolution {
/// Invalid/unspecified resolution - defaults to 480p.
Unspecified = 0,
/// 480p resolution.
/// Dimensions vary by aspect ratio
VideoResolution480p = 1,
/// 720p resolution.
/// Dimensions vary by aspect ratio
VideoResolution720p = 2,
}
impl VideoResolution {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "VIDEO_RESOLUTION_UNSPECIFIED",
Self::VideoResolution480p => "VIDEO_RESOLUTION_480P",
Self::VideoResolution720p => "VIDEO_RESOLUTION_720P",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"VIDEO_RESOLUTION_UNSPECIFIED" => Some(Self::Unspecified),
"VIDEO_RESOLUTION_480P" => Some(Self::VideoResolution480p),
"VIDEO_RESOLUTION_720P" => Some(Self::VideoResolution720p),
_ => None,
}
}
}
/// Generated client implementations.
pub mod video_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// An API service for interaction with video generation models.
#[derive(Debug, Clone)]
pub struct VideoClient<T> {
inner: tonic::client::Grpc<T>,
}
impl VideoClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> VideoClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> VideoClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
VideoClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Create a video based on a text prompt and optionally an image.
/// If an image is provided, generates video with the image as the first frame
/// (image-to-video). If no image is provided, generates video from text only
/// (text-to-video).
///
/// This is an asynchronous operation. The method returns immediately with a
/// request_id that can be used to poll for the result using GetDeferredVideo.
pub async fn generate_video(
&mut self,
request: impl tonic::IntoRequest<super::GenerateVideoRequest>,
) -> std::result::Result<
tonic::Response<super::StartDeferredResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Video/GenerateVideo",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Video", "GenerateVideo"));
self.inner.unary(req, path, codec).await
}
/// Extend an existing video by generating continuation content.
///
/// This is an asynchronous operation. The method returns immediately with a
/// request_id that can be used to poll for the result using GetDeferredVideo.
pub async fn extend_video(
&mut self,
request: impl tonic::IntoRequest<super::ExtendVideoRequest>,
) -> std::result::Result<
tonic::Response<super::StartDeferredResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Video/ExtendVideo",
);
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("xai_api.Video", "ExtendVideo"));
self.inner.unary(req, path, codec).await
}
/// Gets the result of a video generation started by calling `GenerateVideo` or
/// `ExtendVideo`.
pub async fn get_deferred_video(
&mut self,
request: impl tonic::IntoRequest<super::GetDeferredVideoRequest>,
) -> std::result::Result<
tonic::Response<super::GetDeferredVideoResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Video/GetDeferredVideo",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Video", "GetDeferredVideo"));
self.inner.unary(req, path, codec).await
}
}
}
/// Holds basic information about a batch process.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Batch {
/// The ID of the batch. Can be used to retrieve batch results and metadata, etc.
#[prost(string, tag = "1")]
pub batch_id: ::prost::alloc::string::String,
/// The name of the batch.
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String,
/// The time when the batch was created.
#[prost(message, optional, tag = "3")]
pub create_time: ::core::option::Option<::prost_types::Timestamp>,
/// The time when the batch expires.
#[prost(message, optional, tag = "4")]
pub expire_time: ::core::option::Option<::prost_types::Timestamp>,
/// ID of the API key that was used to create the batch.
#[prost(string, tag = "5")]
pub create_api_key_id: ::prost::alloc::string::String,
/// Time when the batch was cancelled.
#[prost(message, optional, tag = "6")]
pub cancel_time: ::core::option::Option<::prost_types::Timestamp>,
/// If the batch was cancelled by xAI, an error message explaining why.
#[prost(string, optional, tag = "7")]
pub cancel_by_xai_message: ::core::option::Option<::prost::alloc::string::String>,
/// The state information of the batch. Not always populated.
#[prost(message, optional, tag = "8")]
pub state: ::core::option::Option<BatchState>,
/// Cost breakdown for processed requests.
#[prost(message, optional, tag = "9")]
pub cost_breakdown: ::core::option::Option<BatchCostBreakdown>,
/// File ID of the uploaded JSONL input file (from Files API). Only set
/// when the batch was created via file upload.
#[prost(string, optional, tag = "10")]
pub input_file_id: ::core::option::Option<::prost::alloc::string::String>,
}
/// Holds aggregate information about the current state of a batch process.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct BatchState {
/// Total number of requests in the batch.
#[prost(int64, tag = "1")]
pub num_requests: i64,
/// Total number of pending requests.
#[prost(int64, tag = "2")]
pub num_pending: i64,
/// Total number of requests that have finished successfully.
#[prost(int64, tag = "3")]
pub num_success: i64,
/// Total number of requests that finished with an error.
#[prost(int64, tag = "4")]
pub num_error: i64,
/// Total number of requests that have been cancelled.
#[prost(int64, tag = "5")]
pub num_cancelled: i64,
}
/// Holds cost information for processed batch requests.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchCostBreakdown {
/// Total cost across all processed requests of all endpoints in USD ticks ($0.0000000001 / $1e-10).
#[prost(int64, tag = "1")]
pub total_cost_usd_ticks: i64,
/// Cost breakdown by endpoint.
#[prost(message, repeated, tag = "2")]
pub endpoint_costs: ::prost::alloc::vec::Vec<EndpointCost>,
/// Timestamp when the cost was calculated.
#[prost(message, optional, tag = "3")]
pub calculation_time: ::core::option::Option<::prost_types::Timestamp>,
}
/// Cost breakdown for a specific endpoint.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct EndpointCost {
/// Endpoint for cost aggregation.
#[prost(string, tag = "1")]
pub endpoint: ::prost::alloc::string::String,
/// Cost for this endpoint in USD ticks ($0.0000000001 / $1e-10).
#[prost(int64, tag = "2")]
pub cost_usd_ticks: i64,
/// Number of requests processed for this endpoint.
#[prost(int64, tag = "3")]
pub request_count: i64,
}
/// A request that can be added to a batch for processing.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchRequest {
/// An optional user-provided identifier for the input request. If provided, it must be unique within the batch.
/// Used to identify the corresponding result when the response is returned to the user.
/// This is because the order of the returned results is not guaranteed to be the same as the order of the requests.
#[prost(string, optional, tag = "1")]
pub batch_request_id: ::core::option::Option<::prost::alloc::string::String>,
/// The request to add for processing in the batch.
#[prost(oneof = "batch_request::Request", tags = "2, 3, 4, 5")]
pub request: ::core::option::Option<batch_request::Request>,
}
/// Nested message and enum types in `BatchRequest`.
pub mod batch_request {
/// The request to add for processing in the batch.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Request {
/// A completion request to send for processing in the batch.
#[prost(message, tag = "2")]
CompletionRequest(super::GetCompletionsRequest),
/// An image generation or editing request to send for processing in the batch.
#[prost(message, tag = "3")]
ImageRequest(super::GenerateImageRequest),
/// A video generation request to send for processing in the batch.
#[prost(message, tag = "4")]
VideoRequest(super::GenerateVideoRequest),
/// A video extension request to send for processing in the batch.
#[prost(message, tag = "5")]
VideoExtensionRequest(super::ExtendVideoRequest),
}
}
/// A container for the response that is returned in a `BatchResult`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchResultData {
/// The response from the batch request.
#[prost(oneof = "batch_result_data::Response", tags = "2, 3, 4")]
pub response: ::core::option::Option<batch_result_data::Response>,
}
/// Nested message and enum types in `BatchResultData`.
pub mod batch_result_data {
/// The response from the batch request.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Response {
/// A completion response that has finished processing in the batch.
#[prost(message, tag = "2")]
CompletionResponse(super::GetChatCompletionResponse),
/// An image generation response that has finished processing in the batch.
#[prost(message, tag = "3")]
ImageResponse(super::ImageResponse),
/// A video generation response that has finished processing in the batch.
#[prost(message, tag = "4")]
VideoResponse(super::VideoResponse),
}
}
/// The result corresponding to a `BatchRequest`. Returns the result if processing is successful, or error if processing
/// has failed.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchResult {
/// User-provided or generated identifier for the batch request. If a user has provided `batch_request_id` in the
/// `BatchRequest`, the value will match the user-provided value.
/// The value is unique within the batch.
#[prost(string, tag = "1")]
pub batch_request_id: ::prost::alloc::string::String,
/// The result data, or error status if processing has failed.
#[prost(oneof = "batch_result::Result", tags = "4, 3")]
pub result: ::core::option::Option<batch_result::Result>,
}
/// Nested message and enum types in `BatchResult`.
pub mod batch_result {
/// The result data, or error status if processing has failed.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Result {
#[prost(message, tag = "4")]
Response(super::BatchResultData),
#[prost(message, tag = "3")]
Error(super::super::google::rpc::Status),
}
}
/// Metadata about an individual batch request.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct BatchRequestMetadata {
/// User-provided or generated identifier for the batch request. The value is unique within the batch.
#[prost(string, tag = "1")]
pub batch_request_id: ::prost::alloc::string::String,
/// API endpoint to query.
#[prost(string, tag = "2")]
pub endpoint: ::prost::alloc::string::String,
/// Model name to query.
#[prost(string, tag = "3")]
pub model: ::prost::alloc::string::String,
#[prost(enumeration = "batch_request_metadata::State", tag = "4")]
pub state: i32,
/// Time when the request was recorded.
#[prost(message, optional, tag = "5")]
pub create_time: ::core::option::Option<::prost_types::Timestamp>,
/// Time when the response was recorded.
#[prost(message, optional, tag = "6")]
pub finish_time: ::core::option::Option<::prost_types::Timestamp>,
}
/// Nested message and enum types in `BatchRequestMetadata`.
pub mod batch_request_metadata {
/// The processing state of this batch request.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum State {
Unknown = 0,
Pending = 1,
Succeeded = 2,
Cancelled = 3,
Failed = 4,
}
impl State {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unknown => "STATE_UNKNOWN",
Self::Pending => "STATE_PENDING",
Self::Succeeded => "STATE_SUCCEEDED",
Self::Cancelled => "STATE_CANCELLED",
Self::Failed => "STATE_FAILED",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"STATE_UNKNOWN" => Some(Self::Unknown),
"STATE_PENDING" => Some(Self::Pending),
"STATE_SUCCEEDED" => Some(Self::Succeeded),
"STATE_CANCELLED" => Some(Self::Cancelled),
"STATE_FAILED" => Some(Self::Failed),
_ => None,
}
}
}
}
/// Request to create a new batch.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CreateBatchRequest {
/// The name of the batch to be created.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Optional file ID of a JSONL input file (uploaded via the Files API).
/// When provided, the batch will be populated from the file's contents.
#[prost(string, tag = "2")]
pub input_file_id: ::prost::alloc::string::String,
}
/// Request to add `BatchRequest`s to an existing batch for processing.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AddBatchRequestsRequest {
/// The ID of the batch to add the requests to.
#[prost(string, tag = "1")]
pub batch_id: ::prost::alloc::string::String,
/// The requests to add to the batch.
#[prost(message, repeated, tag = "2")]
pub batch_requests: ::prost::alloc::vec::Vec<BatchRequest>,
}
/// Request to get the information of a batch.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetBatchRequest {
/// The ID of the batch.
#[prost(string, tag = "1")]
pub batch_id: ::prost::alloc::string::String,
}
/// Request to list all batches in the team.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ListBatchesRequest {
/// Number of batches to return on a page. Defaults to 100.
#[prost(int32, tag = "1")]
pub limit: i32,
/// Optional pagination token to retrieve a specific page. Provided by `pagination_token` in `ListBatchesResponse`.
#[prost(string, optional, tag = "2")]
pub pagination_token: ::core::option::Option<::prost::alloc::string::String>,
}
/// Response containing all the batches on a page.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListBatchesResponse {
/// The information about the batches.
#[prost(message, repeated, tag = "1")]
pub batches: ::prost::alloc::vec::Vec<Batch>,
/// The pagination token to retrieve batches from the next page. Will be empty if this is the last page.
#[prost(string, optional, tag = "2")]
pub pagination_token: ::core::option::Option<::prost::alloc::string::String>,
}
/// Request to cancel processing of all the batch requests in a batch.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CancelBatchRequest {
/// The ID of the batch that we are cancelling the requests.
#[prost(string, tag = "1")]
pub batch_id: ::prost::alloc::string::String,
}
/// Request for the request metadata within a batch.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ListBatchRequestMetadataRequest {
/// ID of the batch whose batch requests' metadata shall be listed.
#[prost(string, tag = "1")]
pub batch_id: ::prost::alloc::string::String,
/// Number of batch request metadata to return on a page. Defaults to 100.
#[prost(int32, tag = "2")]
pub limit: i32,
/// Optional pagination token to retrieve a specific page. Provided by `pagination_token` in `ListBatchRequestMetadataResponse`.
#[prost(string, optional, tag = "3")]
pub pagination_token: ::core::option::Option<::prost::alloc::string::String>,
/// Optional filter by request state. If empty, all states are returned.
#[prost(enumeration = "batch_request_metadata::State", repeated, tag = "4")]
pub status: ::prost::alloc::vec::Vec<i32>,
}
/// Response with the metadata of batch requests within a batch.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListBatchRequestMetadataResponse {
/// The batch requests' metadata for the given batch.
#[prost(message, repeated, tag = "1")]
pub batch_request_metadata: ::prost::alloc::vec::Vec<BatchRequestMetadata>,
/// The pagination token to retrieve results from the next page. Will be empty if this is the last page.
#[prost(string, optional, tag = "2")]
pub pagination_token: ::core::option::Option<::prost::alloc::string::String>,
}
/// Request to list a batch's processing results.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ListBatchResultsRequest {
/// The ID of the batch we are retrieving the results from.
#[prost(string, tag = "1")]
pub batch_id: ::prost::alloc::string::String,
/// Number of batch request results to return on a page. Defaults to 100.
#[prost(int32, tag = "2")]
pub limit: i32,
/// Optional pagination token to retrieve a specific page. Provided by `pagination_token` in `ListBatchResultsResponse`.
#[prost(string, optional, tag = "3")]
pub pagination_token: ::core::option::Option<::prost::alloc::string::String>,
}
/// Response with the batch's processing results.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListBatchResultsResponse {
/// The results that has been processed.
#[prost(message, repeated, tag = "1")]
pub results: ::prost::alloc::vec::Vec<BatchResult>,
/// The pagination token to retrieve results from the next page. Will be empty if this is the last page.
#[prost(string, optional, tag = "2")]
pub pagination_token: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetBatchRequestResultRequest {
/// The ID of the batch we are retrieving the request from.
#[prost(string, tag = "1")]
pub batch_id: ::prost::alloc::string::String,
/// The ID of the request we are retrieving.
#[prost(string, tag = "2")]
pub batch_request_id: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetBatchRequestResultResponse {
/// The request that was processed.
#[prost(message, optional, tag = "1")]
pub request: ::core::option::Option<BatchRequest>,
/// The response that was returned.
#[prost(message, optional, tag = "2")]
pub result: ::core::option::Option<BatchResult>,
}
/// Generated client implementations.
pub mod batch_mgmt_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// An API service for processing batch requests asynchronously at lower priority than chat service.
#[derive(Debug, Clone)]
pub struct BatchMgmtClient<T> {
inner: tonic::client::Grpc<T>,
}
impl BatchMgmtClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> BatchMgmtClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> BatchMgmtClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
BatchMgmtClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Creates a new batch.
pub async fn create_batch(
&mut self,
request: impl tonic::IntoRequest<super::CreateBatchRequest>,
) -> std::result::Result<tonic::Response<super::Batch>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.BatchMgmt/CreateBatch",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.BatchMgmt", "CreateBatch"));
self.inner.unary(req, path, codec).await
}
/// Retrieves an individual batch.
pub async fn get_batch(
&mut self,
request: impl tonic::IntoRequest<super::GetBatchRequest>,
) -> std::result::Result<tonic::Response<super::Batch>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.BatchMgmt/GetBatch",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.BatchMgmt", "GetBatch"));
self.inner.unary(req, path, codec).await
}
/// Retrieves a list of all batches owned by the team.
pub async fn list_batches(
&mut self,
request: impl tonic::IntoRequest<super::ListBatchesRequest>,
) -> std::result::Result<
tonic::Response<super::ListBatchesResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.BatchMgmt/ListBatches",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.BatchMgmt", "ListBatches"));
self.inner.unary(req, path, codec).await
}
/// Stops processing of all outstanding requests in the batch.
pub async fn cancel_batch(
&mut self,
request: impl tonic::IntoRequest<super::CancelBatchRequest>,
) -> std::result::Result<tonic::Response<super::Batch>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.BatchMgmt/CancelBatch",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.BatchMgmt", "CancelBatch"));
self.inner.unary(req, path, codec).await
}
/// Adds requests to a batch.
pub async fn add_batch_requests(
&mut self,
request: impl tonic::IntoRequest<super::AddBatchRequestsRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.BatchMgmt/AddBatchRequests",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.BatchMgmt", "AddBatchRequests"));
self.inner.unary(req, path, codec).await
}
/// Lists metadata about individual requests in a batch.
pub async fn list_batch_request_metadata(
&mut self,
request: impl tonic::IntoRequest<super::ListBatchRequestMetadataRequest>,
) -> std::result::Result<
tonic::Response<super::ListBatchRequestMetadataResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.BatchMgmt/ListBatchRequestMetadata",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new("xai_api.BatchMgmt", "ListBatchRequestMetadata"),
);
self.inner.unary(req, path, codec).await
}
/// Lists processing results of a batch.
pub async fn list_batch_results(
&mut self,
request: impl tonic::IntoRequest<super::ListBatchResultsRequest>,
) -> std::result::Result<
tonic::Response<super::ListBatchResultsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.BatchMgmt/ListBatchResults",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.BatchMgmt", "ListBatchResults"));
self.inner.unary(req, path, codec).await
}
/// Retrieves an individual request in a batch.
pub async fn get_batch_request_result(
&mut self,
request: impl tonic::IntoRequest<super::GetBatchRequestResultRequest>,
) -> std::result::Result<
tonic::Response<super::GetBatchRequestResultResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.BatchMgmt/GetBatchRequestResult",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.BatchMgmt", "GetBatchRequestResult"));
self.inner.unary(req, path, codec).await
}
}
}
/// Request message for generating embeddings.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EmbedRequest {
/// The entities to embed. Note that not every model supports images and text.
/// Some models are text-only and some are image-only. You can at most embed
/// 128 inputs in a single request.
#[prost(message, repeated, tag = "1")]
pub input: ::prost::alloc::vec::Vec<EmbedInput>,
/// Name or alias of the embedding model to use.
#[prost(string, tag = "2")]
pub model: ::prost::alloc::string::String,
/// Format of the returned embeddings.
#[prost(enumeration = "EmbedEncodingFormat", tag = "3")]
pub encoding_format: i32,
/// An opaque string supplied by the API client (customer) to identify a user.
/// The string will be stored in the logs and can be used in customer service
/// requests to identify certain requests.
#[prost(string, tag = "4")]
pub user: ::prost::alloc::string::String,
}
/// Input content to be embedded.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct EmbedInput {
#[prost(oneof = "embed_input::Input", tags = "1, 2")]
pub input: ::core::option::Option<embed_input::Input>,
}
/// Nested message and enum types in `EmbedInput`.
pub mod embed_input {
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
pub enum Input {
/// A string to be embedded.
#[prost(string, tag = "1")]
String(::prost::alloc::string::String),
/// An image to be embedded.
#[prost(message, tag = "2")]
ImageUrl(super::ImageUrlContent),
}
}
/// Response object for the `Embed` RPC.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EmbedResponse {
/// An identifier of this request. The same ID will be used in your billing
/// records.
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
/// The embeddings generated from the inputs.
#[prost(message, repeated, tag = "2")]
pub embeddings: ::prost::alloc::vec::Vec<Embedding>,
/// The usage associated with this request.
#[prost(message, optional, tag = "3")]
pub usage: ::core::option::Option<EmbeddingUsage>,
/// The name of the model used for the request. This model name contains
/// the actual model name used rather than any aliases.
/// This means it can be `embed-0205` even when the request was specifying
/// `embed-latest`.
#[prost(string, tag = "4")]
pub model: ::prost::alloc::string::String,
/// This fingerprint represents the backend configuration that the model runs
/// with.
#[prost(string, tag = "5")]
pub system_fingerprint: ::prost::alloc::string::String,
}
/// Holds the embedding vector for a single embedding input.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Embedding {
/// The index of the input this embedding was produced from.
#[prost(int32, tag = "1")]
pub index: i32,
/// The feature vectors derived from the inputs. Note that some inputs such as
/// images may produce multiple feature vectors.
#[prost(message, repeated, tag = "2")]
pub embeddings: ::prost::alloc::vec::Vec<FeatureVector>,
}
/// A single feature vector.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FeatureVector {
/// The feature vector encoded as an array of floats. Only populated if
/// the encoding format is FORMAT_FLOAT.
#[prost(float, repeated, tag = "1")]
pub float_array: ::prost::alloc::vec::Vec<f32>,
/// The feature vector encoded as a base64 string. Only populated if
/// the encoding format is FORMAT_BASE64.
#[prost(string, tag = "2")]
pub base64_array: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum EmbedEncodingFormat {
/// Invalid format.
FormatInvalid = 0,
/// Returns the embeddings as an array of floats.
FormatFloat = 1,
/// Returns the embeddings as a base64-encoded string.
FormatBase64 = 2,
}
impl EmbedEncodingFormat {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::FormatInvalid => "FORMAT_INVALID",
Self::FormatFloat => "FORMAT_FLOAT",
Self::FormatBase64 => "FORMAT_BASE64",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"FORMAT_INVALID" => Some(Self::FormatInvalid),
"FORMAT_FLOAT" => Some(Self::FormatFloat),
"FORMAT_BASE64" => Some(Self::FormatBase64),
_ => None,
}
}
}
/// Generated client implementations.
pub mod embedder_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// An API service for interaction with available embedding models.
#[derive(Debug, Clone)]
pub struct EmbedderClient<T> {
inner: tonic::client::Grpc<T>,
}
impl EmbedderClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> EmbedderClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> EmbedderClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
EmbedderClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Produces one embedding for each input object. The size of the produced
/// feature vectors depends on the chosen model.
pub async fn embed(
&mut self,
request: impl tonic::IntoRequest<super::EmbedRequest>,
) -> std::result::Result<tonic::Response<super::EmbedResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/xai_api.Embedder/Embed");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("xai_api.Embedder", "Embed"));
self.inner.unary(req, path, codec).await
}
}
}
/// First stream message of an `UploadFile` call. Sent exactly once, before
/// any data chunks.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct UploadFileInit {
/// Filename (max 255 Unicode chars). Must not contain ASCII control
/// chars, line terminators (CR/LF/NEL/U+2028/U+2029), null bytes, `"`,
/// `;`, or `\` — these would break `Content-Disposition` headers.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Optional TTL in seconds, measured from upload time. Must be in
/// \[3600, 2592000\] (1h to 30d) inclusive — 0 and out-of-range values are
/// rejected. Unset means no expiration.
#[prost(int64, optional, tag = "2")]
pub expires_after: ::core::option::Option<i64>,
}
/// One message in an `UploadFile` stream: either `init` (required first) or
/// a `data` chunk.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct UploadFileChunk {
#[prost(oneof = "upload_file_chunk::Chunk", tags = "1, 2")]
pub chunk: ::core::option::Option<upload_file_chunk::Chunk>,
}
/// Nested message and enum types in `UploadFileChunk`.
pub mod upload_file_chunk {
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
pub enum Chunk {
/// Information about the file being uploaded.
#[prost(message, tag = "1")]
Init(super::UploadFileInit),
/// Up to ~5 MB per chunk recommended; cumulative size capped at 512 MB.
#[prost(bytes, tag = "2")]
Data(::prost::alloc::vec::Vec<u8>),
}
}
/// Metadata for an uploaded file.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct File {
/// Size in bytes.
#[prost(int64, tag = "1")]
pub size: i64,
/// UTC timestamp the file was uploaded.
#[prost(message, optional, tag = "2")]
pub created_at: ::core::option::Option<::prost_types::Timestamp>,
/// UTC timestamp the file will be auto-deleted at. Present only if the
/// upload set `UploadFileInit.expires_after`.
#[prost(message, optional, tag = "3")]
pub expires_at: ::core::option::Option<::prost_types::Timestamp>,
/// Filename as supplied at upload.
#[prost(string, tag = "4")]
pub filename: ::prost::alloc::string::String,
/// Opaque server-assigned ID (e.g. `file_<uuid>`). Use this in
/// `RetrieveFile`, `DeleteFile`, `RetrieveFileContent`, and other xAI
/// APIs that accept a file reference.
#[prost(string, tag = "5")]
pub id: ::prost::alloc::string::String,
}
/// Request message for `Files.ListFiles`.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ListFilesRequest {
/// Page size, in \[1, 100\]. Values \<= 0 default to 100; values > 100 are
/// clamped.
#[prost(int32, tag = "1")]
pub limit: i32,
/// Sort direction. Defaults to ASCENDING.
#[prost(enumeration = "Ordering", tag = "2")]
pub order: i32,
/// Opaque token from a prior `ListFilesResponse.pagination_token`, used to
/// resume listing where the previous page left off. Omit on the first
/// call. Use the same `order` and `sort_by` as the request that produced
/// the token; otherwise paging behavior is undefined. Treat as opaque;
/// format may change.
#[prost(string, optional, tag = "3")]
pub pagination_token: ::core::option::Option<::prost::alloc::string::String>,
/// Sort field. Defaults to `FILES_SORT_BY_CREATED_AT`.
#[prost(enumeration = "FilesSortBy", optional, tag = "4")]
pub sort_by: ::core::option::Option<i32>,
}
/// Response message for `Files.ListFiles`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListFilesResponse {
/// List of file metadata.
#[prost(message, repeated, tag = "1")]
pub data: ::prost::alloc::vec::Vec<File>,
/// Token for the next page; absent on the final page.
#[prost(string, optional, tag = "2")]
pub pagination_token: ::core::option::Option<::prost::alloc::string::String>,
}
/// Request message for `Files.RetrieveFile`.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct RetrieveFileRequest {
/// The ID of the file to use for this request.
#[prost(string, tag = "1")]
pub file_id: ::prost::alloc::string::String,
}
/// Request message for `Files.DeleteFile`.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct DeleteFileRequest {
/// The ID of the file to use for this request.
#[prost(string, tag = "1")]
pub file_id: ::prost::alloc::string::String,
}
/// Response message for `Files.DeleteFile`.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct DeleteFileResponse {
/// Echoes the deleted file's id.
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
/// Always true on success (failures surface as gRPC errors).
#[prost(bool, tag = "2")]
pub deleted: bool,
}
/// Request message for `Files.RetrieveFileContent`.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct RetrieveFileContentRequest {
/// The ID of the file to download.
#[prost(string, tag = "1")]
pub file_id: ::prost::alloc::string::String,
/// Format of the downloaded content.
/// ORIGINAL: raw file bytes (default).
/// TEXT: extracted/converted text content.
#[prost(enumeration = "DownloadFormat", optional, tag = "2")]
pub format: ::core::option::Option<i32>,
}
/// One chunk of a `RetrieveFileContent` stream.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct FileContentChunk {
/// Up to 5 MB of file bytes. Final/intermediate chunks may be smaller.
#[prost(bytes = "vec", tag = "1")]
pub data: ::prost::alloc::vec::Vec<u8>,
}
/// Sort direction for list-style RPCs.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Ordering {
Ascending = 0,
Descending = 1,
}
impl Ordering {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Ascending => "ASCENDING",
Self::Descending => "DESCENDING",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ASCENDING" => Some(Self::Ascending),
"DESCENDING" => Some(Self::Descending),
_ => None,
}
}
}
/// Field to sort `ListFiles` results by.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum FilesSortBy {
/// Default.
CreatedAt = 0,
/// Case-sensitive lexicographic order.
Filename = 1,
Size = 2,
}
impl FilesSortBy {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::CreatedAt => "FILES_SORT_BY_CREATED_AT",
Self::Filename => "FILES_SORT_BY_FILENAME",
Self::Size => "FILES_SORT_BY_SIZE",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"FILES_SORT_BY_CREATED_AT" => Some(Self::CreatedAt),
"FILES_SORT_BY_FILENAME" => Some(Self::Filename),
"FILES_SORT_BY_SIZE" => Some(Self::Size),
_ => None,
}
}
}
/// Which representation of a file to download.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum DownloadFormat {
/// Treated as `DOWNLOAD_FORMAT_ORIGINAL` (the default when `format` is
/// unset).
Unknown = 0,
/// Raw bytes as uploaded.
Original = 1,
/// Text extracted from the file (e.g. PDF/DOCX). Only works for file
/// types with a server-side text-extraction pass; fails otherwise.
Text = 2,
}
impl DownloadFormat {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unknown => "DOWNLOAD_FORMAT_UNKNOWN",
Self::Original => "DOWNLOAD_FORMAT_ORIGINAL",
Self::Text => "DOWNLOAD_FORMAT_TEXT",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"DOWNLOAD_FORMAT_UNKNOWN" => Some(Self::Unknown),
"DOWNLOAD_FORMAT_ORIGINAL" => Some(Self::Original),
"DOWNLOAD_FORMAT_TEXT" => Some(Self::Text),
_ => None,
}
}
}
/// Generated client implementations.
pub mod files_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// Service for uploading, listing, retrieving, and deleting files.
///
/// Files are referenced by the `id` returned on upload (e.g. when attaching
/// to chat completions). Maximum file size is 512 MB.
#[derive(Debug, Clone)]
pub struct FilesClient<T> {
inner: tonic::client::Grpc<T>,
}
impl FilesClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> FilesClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> FilesClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
FilesClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Upload a file. The first stream message MUST set `chunk = init`
/// (filename + optional TTL); subsequent messages MUST set `chunk = data`
/// with file bytes in order. Recommended chunk size up to 5 MB; total
/// size capped at 512 MB. Returns the new file's metadata.
///
/// Errors: INVALID_ARGUMENT (missing/misplaced init, bad filename, bad
/// TTL), RESOURCE_EXHAUSTED (over 512 MB).
pub async fn upload_file(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::UploadFileChunk>,
) -> std::result::Result<tonic::Response<super::File>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/xai_api.Files/UploadFile");
let mut req = request.into_streaming_request();
req.extensions_mut().insert(GrpcMethod::new("xai_api.Files", "UploadFile"));
self.inner.client_streaming(req, path, codec).await
}
/// List file metadata, paginated and sorted. Returns metadata only — use
/// `RetrieveFileContent` to download bytes.
pub async fn list_files(
&mut self,
request: impl tonic::IntoRequest<super::ListFilesRequest>,
) -> std::result::Result<
tonic::Response<super::ListFilesResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/xai_api.Files/ListFiles");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("xai_api.Files", "ListFiles"));
self.inner.unary(req, path, codec).await
}
/// Get metadata for one file. Returns metadata only — use
/// `RetrieveFileContent` to download bytes. Errors NOT_FOUND if no
/// accessible file with that id (including already-deleted).
pub async fn retrieve_file(
&mut self,
request: impl tonic::IntoRequest<super::RetrieveFileRequest>,
) -> std::result::Result<tonic::Response<super::File>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Files/RetrieveFile",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Files", "RetrieveFile"));
self.inner.unary(req, path, codec).await
}
/// Delete a file. After success it stops appearing in `ListFiles` /
/// `RetrieveFile` and is no longer downloadable. Errors NOT_FOUND if no
/// accessible file with that id (including already-deleted).
pub async fn delete_file(
&mut self,
request: impl tonic::IntoRequest<super::DeleteFileRequest>,
) -> std::result::Result<
tonic::Response<super::DeleteFileResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/xai_api.Files/DeleteFile");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("xai_api.Files", "DeleteFile"));
self.inner.unary(req, path, codec).await
}
/// Stream the file's contents in chunks of up to 5 MB, in order.
/// Concatenate `data` from every chunk to reconstruct the file.
pub async fn retrieve_file_content(
&mut self,
request: impl tonic::IntoRequest<super::RetrieveFileContentRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::FileContentChunk>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Files/RetrieveFileContent",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Files", "RetrieveFileContent"));
self.inner.server_streaming(req, path, codec).await
}
}
}
/// Request to get details of a specific model by name.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetModelRequest {
/// The name of the model to retrieve details about.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// Describes a language model available on the platform.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct LanguageModel {
/// The model name used in API requests/responses.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// The aliases of the name, which can also be used in lieu of name in the API
/// requests.
#[prost(string, repeated, tag = "11")]
pub aliases: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// The version number of this model. Used to identify minor updates when
/// the model name is not changed.
#[prost(string, tag = "2")]
pub version: ::prost::alloc::string::String,
/// The supported input modalities of the model.
#[prost(enumeration = "Modality", repeated, tag = "3")]
pub input_modalities: ::prost::alloc::vec::Vec<i32>,
/// The supported output modalities of the model.
#[prost(enumeration = "Modality", repeated, tag = "4")]
pub output_modalities: ::prost::alloc::vec::Vec<i32>,
/// The price (in 1/100 USD cents) per one million text prompt tokens.
#[prost(int64, tag = "5")]
pub prompt_text_token_price: i64,
/// The price (in 1/100 USD cents) per one million image prompt tokens.
#[prost(int64, tag = "6")]
pub prompt_image_token_price: i64,
/// The price (in USD cents) per 100 million cached text prompt tokens.
#[prost(int64, tag = "12")]
pub cached_prompt_token_price: i64,
/// The price (in 1/100 USD cents) per one million text completion token.
#[prost(int64, tag = "7")]
pub completion_text_token_price: i64,
/// The price (in 1/100 USD cents) per one million searches.
#[prost(int64, tag = "13")]
pub search_price: i64,
/// The creation time of the model.
#[prost(message, optional, tag = "8")]
pub created: ::core::option::Option<::prost_types::Timestamp>,
/// Maximum length of the prompt/input (this includes tokens of all kinds).
/// This is typically known as the context length of the model.
#[prost(int32, tag = "9")]
pub max_prompt_length: i32,
/// Fingerprint of the unique configuration of the model.
#[prost(string, tag = "10")]
pub system_fingerprint: ::prost::alloc::string::String,
}
/// Response from ListLanguageModels including a list of language models.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListLanguageModelsResponse {
/// A list of language models.
#[prost(message, repeated, tag = "1")]
pub models: ::prost::alloc::vec::Vec<LanguageModel>,
}
/// Describes an embedding model available on the platform.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct EmbeddingModel {
/// The name under which the model is available in the API.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// The aliases of the name, which can also be used in lieu of name in the API
/// requests.
#[prost(string, repeated, tag = "11")]
pub aliases: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// The version number of this model. Used to identify minor updates when
/// the model name is not changed.
#[prost(string, tag = "2")]
pub version: ::prost::alloc::string::String,
/// The supported input modalities of the model.
#[prost(enumeration = "Modality", repeated, tag = "3")]
pub input_modalities: ::prost::alloc::vec::Vec<i32>,
/// The supported output modalities of the model.
#[prost(enumeration = "Modality", repeated, tag = "4")]
pub output_modalities: ::prost::alloc::vec::Vec<i32>,
/// The price (in 1/100 USD cents) per one million text prompt tokens.
#[prost(int64, tag = "5")]
pub prompt_text_token_price: i64,
/// The price (in 1/100 USD cents) per one million image prompt tokens.
#[prost(int64, tag = "6")]
pub prompt_image_token_price: i64,
/// The creation time of the model.
#[prost(message, optional, tag = "7")]
pub created: ::core::option::Option<::prost_types::Timestamp>,
/// Fingerprint of the unique configuration of the model.
#[prost(string, tag = "8")]
pub system_fingerprint: ::prost::alloc::string::String,
}
/// Response from ListEmbeddingModels including a list of embedding models.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListEmbeddingModelsResponse {
/// A list of embedding model(s).
#[prost(message, repeated, tag = "1")]
pub models: ::prost::alloc::vec::Vec<EmbeddingModel>,
}
/// Describes a language model available on the platform.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ImageGenerationModel {
/// The model name used in API requests/responses.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// The aliases of the name, which can also be used in lieu of name in the API
/// requests.
#[prost(string, repeated, tag = "11")]
pub aliases: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// The version number of this model. Used to identify minor updates when
/// the model name is not changed.
#[prost(string, tag = "2")]
pub version: ::prost::alloc::string::String,
/// The supported input modalities of the model.
#[prost(enumeration = "Modality", repeated, tag = "3")]
pub input_modalities: ::prost::alloc::vec::Vec<i32>,
/// The supported output modalities of the model.
#[prost(enumeration = "Modality", repeated, tag = "6")]
pub output_modalities: ::prost::alloc::vec::Vec<i32>,
/// The price (in USD cents) per image.
#[prost(int64, tag = "12")]
pub image_price: i64,
/// When the language model was created.
#[prost(message, optional, tag = "8")]
pub created: ::core::option::Option<::prost_types::Timestamp>,
/// Maximum length of the prompt/input (this includes tokens of all kinds).
/// This is typically known as the context length of the model.
#[prost(int32, tag = "9")]
pub max_prompt_length: i32,
/// Fingerprint of the unique configuration of the model.
#[prost(string, tag = "10")]
pub system_fingerprint: ::prost::alloc::string::String,
}
/// Response from ListImageGenerationModels including a list of image generation
/// models.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListImageGenerationModelsResponse {
/// A list of image generation models.
#[prost(message, repeated, tag = "1")]
pub models: ::prost::alloc::vec::Vec<ImageGenerationModel>,
}
/// Modalities supported by a model input/output.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Modality {
/// Invalid modality.
InvalidModality = 0,
/// Text input/output.
Text = 1,
/// Image input/output.
Image = 2,
/// Embedding input/output.
Embedding = 3,
}
impl Modality {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::InvalidModality => "INVALID_MODALITY",
Self::Text => "TEXT",
Self::Image => "IMAGE",
Self::Embedding => "EMBEDDING",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"INVALID_MODALITY" => Some(Self::InvalidModality),
"TEXT" => Some(Self::Text),
"IMAGE" => Some(Self::Image),
"EMBEDDING" => Some(Self::Embedding),
_ => None,
}
}
}
/// Generated client implementations.
pub mod models_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// An API service that let users get details of available models on the
/// platform.
#[derive(Debug, Clone)]
pub struct ModelsClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ModelsClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> ModelsClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> ModelsClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
ModelsClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Lists all language models available to your team (based on the API key).
pub async fn list_language_models(
&mut self,
request: impl tonic::IntoRequest<()>,
) -> std::result::Result<
tonic::Response<super::ListLanguageModelsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Models/ListLanguageModels",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Models", "ListLanguageModels"));
self.inner.unary(req, path, codec).await
}
/// Lists all embedding models available to your team (based on the API key).
pub async fn list_embedding_models(
&mut self,
request: impl tonic::IntoRequest<()>,
) -> std::result::Result<
tonic::Response<super::ListEmbeddingModelsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Models/ListEmbeddingModels",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Models", "ListEmbeddingModels"));
self.inner.unary(req, path, codec).await
}
/// Lists all image generation models available to your team (based on the API key).
pub async fn list_image_generation_models(
&mut self,
request: impl tonic::IntoRequest<()>,
) -> std::result::Result<
tonic::Response<super::ListImageGenerationModelsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Models/ListImageGenerationModels",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Models", "ListImageGenerationModels"));
self.inner.unary(req, path, codec).await
}
/// Get details of a specific language model by model name.
pub async fn get_language_model(
&mut self,
request: impl tonic::IntoRequest<super::GetModelRequest>,
) -> std::result::Result<tonic::Response<super::LanguageModel>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Models/GetLanguageModel",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Models", "GetLanguageModel"));
self.inner.unary(req, path, codec).await
}
/// Get details of a specific embedding model by model name.
pub async fn get_embedding_model(
&mut self,
request: impl tonic::IntoRequest<super::GetModelRequest>,
) -> std::result::Result<tonic::Response<super::EmbeddingModel>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Models/GetEmbeddingModel",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Models", "GetEmbeddingModel"));
self.inner.unary(req, path, codec).await
}
/// Get details of a specific image generation model by model name.
pub async fn get_image_generation_model(
&mut self,
request: impl tonic::IntoRequest<super::GetModelRequest>,
) -> std::result::Result<
tonic::Response<super::ImageGenerationModel>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Models/GetImageGenerationModel",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Models", "GetImageGenerationModel"));
self.inner.unary(req, path, codec).await
}
}
}
/// Request to convert text to a sequence of tokens.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct TokenizeTextRequest {
/// Text to tokenize.
#[prost(string, tag = "1")]
pub text: ::prost::alloc::string::String,
/// Name or alias of the model used for tokenization.
#[prost(string, tag = "2")]
pub model: ::prost::alloc::string::String,
/// An opaque string supplied by the API client (customer) to identify a user.
/// The string will be stored in the logs and can be used in customer service
/// requests to identify certain requests.
#[prost(string, tag = "3")]
pub user: ::prost::alloc::string::String,
}
/// Information on a token.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Token {
/// ID of the token.
#[prost(uint32, tag = "1")]
pub token_id: u32,
/// String snippet of the token.
#[prost(string, tag = "2")]
pub string_token: ::prost::alloc::string::String,
/// Bytes representing the token.
#[prost(bytes = "vec", tag = "4")]
pub token_bytes: ::prost::alloc::vec::Vec<u8>,
}
/// Response including the tokenization result.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TokenizeTextResponse {
/// The sequence of tokens. This is the output of the tokenization process.
#[prost(message, repeated, tag = "1")]
pub tokens: ::prost::alloc::vec::Vec<Token>,
/// The name of the model used for the request. This model name contains
/// the actual model name used rather than any aliases.
/// This means the this can be `grok-2-1212` even when the request was
/// specifying `grok-2-latest`.
#[prost(string, tag = "2")]
pub model: ::prost::alloc::string::String,
}
/// Generated client implementations.
pub mod tokenize_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// An API service to tokenize input prompts.
#[derive(Debug, Clone)]
pub struct TokenizeClient<T> {
inner: tonic::client::Grpc<T>,
}
impl TokenizeClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> TokenizeClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> TokenizeClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
TokenizeClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Convert text to a sequence of tokens.
pub async fn tokenize_text(
&mut self,
request: impl tonic::IntoRequest<super::TokenizeTextRequest>,
) -> std::result::Result<
tonic::Response<super::TokenizeTextResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/xai_api.Tokenize/TokenizeText",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("xai_api.Tokenize", "TokenizeText"));
self.inner.unary(req, path, codec).await
}
}
}