openapi.json 22.5 KB
Newer Older
1
2
3
4
5
6
{
  "openapi": "3.0.3",
  "info": {
    "title": "Text Generation Inference",
    "description": "Text Generation Webserver",
    "contact": {
7
      "name": "Olivier Dehaene"
8
9
10
11
12
    },
    "license": {
      "name": "Apache 2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0"
    },
OlivierDehaene's avatar
v1.3.4  
OlivierDehaene committed
13
    "version": "1.3.4"
14
15
  },
  "paths": {
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
    "/": {
      "post": {
        "tags": [
          "Text Generation Inference"
        ],
        "summary": "Generate tokens if `stream == false` or a stream of token if `stream == true`",
        "description": "Generate tokens if `stream == false` or a stream of token if `stream == true`",
        "operationId": "compat_generate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompatGenerateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
36
37
38
39
40
41
42
43
44
45
46
47
48
            "description": "Generated Text",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "$ref": "#/components/schemas/StreamResponse"
                }
              }
            }
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
          },
          "422": {
            "description": "Input validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Input validation error"
                }
              }
            }
          },
          "424": {
            "description": "Generation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Request failed during generation"
                }
              }
            }
          },
          "429": {
            "description": "Model is overloaded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Model is overloaded"
                }
              }
            }
          },
          "500": {
            "description": "Incomplete generation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Incomplete generation"
                }
              }
            }
          }
        }
      }
    },
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
    "/generate": {
      "post": {
        "tags": [
          "Text Generation Inference"
        ],
        "summary": "Generate tokens",
        "description": "Generate tokens",
        "operationId": "generate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Generated Text",
            "content": {
              "application/json": {
                "schema": {
OlivierDehaene's avatar
OlivierDehaene committed
129
                  "$ref": "#/components/schemas/GenerateResponse"
130
131
132
133
134
135
136
137
138
                }
              }
            }
          },
          "422": {
            "description": "Input validation error",
            "content": {
              "application/json": {
                "schema": {
OlivierDehaene's avatar
OlivierDehaene committed
139
                  "$ref": "#/components/schemas/ErrorResponse"
140
141
142
143
144
145
146
147
148
149
150
151
                },
                "example": {
                  "error": "Input validation error"
                }
              }
            }
          },
          "424": {
            "description": "Generation Error",
            "content": {
              "application/json": {
                "schema": {
OlivierDehaene's avatar
OlivierDehaene committed
152
                  "$ref": "#/components/schemas/ErrorResponse"
153
154
155
156
157
158
159
160
161
162
163
164
                },
                "example": {
                  "error": "Request failed during generation"
                }
              }
            }
          },
          "429": {
            "description": "Model is overloaded",
            "content": {
              "application/json": {
                "schema": {
OlivierDehaene's avatar
OlivierDehaene committed
165
                  "$ref": "#/components/schemas/ErrorResponse"
166
167
168
169
170
171
172
173
174
175
176
177
                },
                "example": {
                  "error": "Model is overloaded"
                }
              }
            }
          },
          "500": {
            "description": "Incomplete generation",
            "content": {
              "application/json": {
                "schema": {
OlivierDehaene's avatar
OlivierDehaene committed
178
                  "$ref": "#/components/schemas/ErrorResponse"
179
180
181
182
183
184
185
                },
                "example": {
                  "error": "Incomplete generation"
                }
              }
            }
          }
186
        }
187
188
189
190
191
192
193
      }
    },
    "/generate_stream": {
      "post": {
        "tags": [
          "Text Generation Inference"
        ],
Yannic Kilcher's avatar
Yannic Kilcher committed
194
195
        "summary": "Generate a stream of token using Server-Sent Events",
        "description": "Generate a stream of token using Server-Sent Events",
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
        "operationId": "generate_stream",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Generated Text",
            "content": {
OlivierDehaene's avatar
OlivierDehaene committed
211
              "text/event-stream": {
212
                "schema": {
OlivierDehaene's avatar
OlivierDehaene committed
213
                  "$ref": "#/components/schemas/StreamResponse"
214
215
216
217
218
219
220
                }
              }
            }
          },
          "422": {
            "description": "Input validation error",
            "content": {
OlivierDehaene's avatar
OlivierDehaene committed
221
              "text/event-stream": {
222
                "schema": {
OlivierDehaene's avatar
OlivierDehaene committed
223
                  "$ref": "#/components/schemas/ErrorResponse"
224
225
226
227
228
229
230
231
232
233
                },
                "example": {
                  "error": "Input validation error"
                }
              }
            }
          },
          "424": {
            "description": "Generation Error",
            "content": {
OlivierDehaene's avatar
OlivierDehaene committed
234
              "text/event-stream": {
235
                "schema": {
OlivierDehaene's avatar
OlivierDehaene committed
236
                  "$ref": "#/components/schemas/ErrorResponse"
237
238
239
240
241
242
243
244
245
246
                },
                "example": {
                  "error": "Request failed during generation"
                }
              }
            }
          },
          "429": {
            "description": "Model is overloaded",
            "content": {
OlivierDehaene's avatar
OlivierDehaene committed
247
              "text/event-stream": {
248
                "schema": {
OlivierDehaene's avatar
OlivierDehaene committed
249
                  "$ref": "#/components/schemas/ErrorResponse"
250
251
252
253
254
255
256
257
258
259
                },
                "example": {
                  "error": "Model is overloaded"
                }
              }
            }
          },
          "500": {
            "description": "Incomplete generation",
            "content": {
OlivierDehaene's avatar
OlivierDehaene committed
260
              "text/event-stream": {
261
                "schema": {
OlivierDehaene's avatar
OlivierDehaene committed
262
                  "$ref": "#/components/schemas/ErrorResponse"
263
264
265
266
267
268
269
                },
                "example": {
                  "error": "Incomplete generation"
                }
              }
            }
          }
270
271
272
        }
      }
    },
OlivierDehaene's avatar
OlivierDehaene committed
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
    "/health": {
      "get": {
        "tags": [
          "Text Generation Inference"
        ],
        "summary": "Health check method",
        "description": "Health check method",
        "operationId": "health",
        "responses": {
          "200": {
            "description": "Everything is working fine"
          },
          "503": {
            "description": "Text generation inference is down",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "unhealthy",
                  "error_type": "healthcheck"
                }
              }
            }
          }
        }
      }
    },
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
    "/info": {
      "get": {
        "tags": [
          "Text Generation Inference"
        ],
        "summary": "Text Generation Inference endpoint info",
        "description": "Text Generation Inference endpoint info",
        "operationId": "get_model_info",
        "responses": {
          "200": {
            "description": "Served model info",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Info"
                }
              }
            }
          }
        }
322
      }
OlivierDehaene's avatar
OlivierDehaene committed
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
    },
    "/metrics": {
      "get": {
        "tags": [
          "Text Generation Inference"
        ],
        "summary": "Prometheus metrics scrape endpoint",
        "description": "Prometheus metrics scrape endpoint",
        "operationId": "metrics",
        "responses": {
          "200": {
            "description": "Prometheus Metrics",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
343
        }
OlivierDehaene's avatar
OlivierDehaene committed
344
      }
345
346
347
348
    }
  },
  "components": {
    "schemas": {
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
      "BestOfSequence": {
        "type": "object",
        "required": [
          "generated_text",
          "finish_reason",
          "generated_tokens",
          "prefill",
          "tokens"
        ],
        "properties": {
          "finish_reason": {
            "$ref": "#/components/schemas/FinishReason"
          },
          "generated_text": {
            "type": "string",
            "example": "test"
          },
          "generated_tokens": {
            "type": "integer",
            "format": "int32",
369
            "example": 1,
370
            "minimum": 0
371
372
373
374
375
376
377
378
379
380
381
          },
          "prefill": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PrefillToken"
            }
          },
          "seed": {
            "type": "integer",
            "format": "int64",
            "example": 42,
382
            "nullable": true,
383
            "minimum": 0
384
385
386
387
388
389
          },
          "tokens": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Token"
            }
390
391
392
393
394
395
396
397
398
          },
          "top_tokens": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/Token"
              }
            }
399
400
401
          }
        }
      },
402
403
404
405
406
407
408
409
410
411
412
413
414
415
      "CompatGenerateRequest": {
        "type": "object",
        "required": [
          "inputs"
        ],
        "properties": {
          "inputs": {
            "type": "string",
            "example": "My name is Olivier and I"
          },
          "parameters": {
            "$ref": "#/components/schemas/GenerateParameters"
          },
          "stream": {
OlivierDehaene's avatar
OlivierDehaene committed
416
417
            "type": "boolean",
            "default": "false"
418
419
420
          }
        }
      },
421
422
423
424
      "Details": {
        "type": "object",
        "required": [
          "finish_reason",
425
426
427
          "generated_tokens",
          "prefill",
          "tokens"
428
429
        ],
        "properties": {
430
431
432
433
          "best_of_sequences": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BestOfSequence"
434
435
            },
            "nullable": true
436
          },
437
438
439
440
441
442
          "finish_reason": {
            "$ref": "#/components/schemas/FinishReason"
          },
          "generated_tokens": {
            "type": "integer",
            "format": "int32",
443
            "example": 1,
444
            "minimum": 0
445
446
447
448
          },
          "prefill": {
            "type": "array",
            "items": {
449
              "$ref": "#/components/schemas/PrefillToken"
450
451
452
453
454
            }
          },
          "seed": {
            "type": "integer",
            "format": "int64",
455
            "example": 42,
456
            "nullable": true,
457
            "minimum": 0
458
459
460
461
462
463
          },
          "tokens": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Token"
            }
464
465
466
467
468
469
470
471
472
          },
          "top_tokens": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/Token"
              }
            }
473
474
475
476
477
478
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
479
480
          "error",
          "error_type"
481
482
483
484
        ],
        "properties": {
          "error": {
            "type": "string"
485
486
487
          },
          "error_type": {
            "type": "string"
488
489
490
491
492
493
494
495
496
497
498
499
500
501
          }
        }
      },
      "FinishReason": {
        "type": "string",
        "enum": [
          "length",
          "eos_token",
          "stop_sequence"
        ]
      },
      "GenerateParameters": {
        "type": "object",
        "properties": {
502
503
504
505
506
          "best_of": {
            "type": "integer",
            "default": "null",
            "example": 1,
            "nullable": true,
507
508
            "minimum": 0,
            "exclusiveMinimum": 0
509
          },
OlivierDehaene's avatar
OlivierDehaene committed
510
511
512
513
          "decoder_input_details": {
            "type": "boolean",
            "default": "true"
          },
514
515
516
517
518
519
520
521
522
523
524
525
          "details": {
            "type": "boolean",
            "default": "true"
          },
          "do_sample": {
            "type": "boolean",
            "default": "false",
            "example": true
          },
          "max_new_tokens": {
            "type": "integer",
            "format": "int32",
526
            "default": "20",
527
528
529
            "example": "20",
            "nullable": true,
            "minimum": 0
530
531
532
533
534
535
536
          },
          "repetition_penalty": {
            "type": "number",
            "format": "float",
            "default": "null",
            "example": 1.03,
            "nullable": true,
537
            "exclusiveMinimum": 0
538
          },
OlivierDehaene's avatar
OlivierDehaene committed
539
540
          "return_full_text": {
            "type": "boolean",
541
542
543
            "default": "null",
            "example": false,
            "nullable": true
OlivierDehaene's avatar
OlivierDehaene committed
544
          },
545
546
          "seed": {
            "type": "integer",
547
548
549
550
            "format": "int64",
            "default": "null",
            "example": "null",
            "nullable": true,
551
552
            "minimum": 0,
            "exclusiveMinimum": 0
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
          },
          "stop": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "photographer"
            ],
            "maxItems": 4
          },
          "temperature": {
            "type": "number",
            "format": "float",
            "default": "null",
            "example": 0.5,
            "nullable": true,
570
            "exclusiveMinimum": 0
571
572
573
574
575
576
577
          },
          "top_k": {
            "type": "integer",
            "format": "int32",
            "default": "null",
            "example": 10,
            "nullable": true,
578
579
580
581
582
583
584
585
586
587
            "exclusiveMinimum": 0
          },
          "top_n_tokens": {
            "type": "integer",
            "format": "int32",
            "default": "null",
            "example": 5,
            "nullable": true,
            "minimum": 0,
            "exclusiveMinimum": 0
588
589
590
591
592
593
594
          },
          "top_p": {
            "type": "number",
            "format": "float",
            "default": "null",
            "example": 0.95,
            "nullable": true,
595
596
            "maximum": 1,
            "exclusiveMinimum": 0
OlivierDehaene's avatar
OlivierDehaene committed
597
          },
598
599
600
601
          "truncate": {
            "type": "integer",
            "default": "null",
            "example": "null",
602
            "nullable": true,
603
            "minimum": 0
604
605
606
607
608
609
610
          },
          "typical_p": {
            "type": "number",
            "format": "float",
            "default": "null",
            "example": 0.95,
            "nullable": true,
611
612
            "maximum": 1,
            "exclusiveMinimum": 0
613
          },
OlivierDehaene's avatar
OlivierDehaene committed
614
615
616
617
          "watermark": {
            "type": "boolean",
            "default": "false",
            "example": true
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
          }
        }
      },
      "GenerateRequest": {
        "type": "object",
        "required": [
          "inputs"
        ],
        "properties": {
          "inputs": {
            "type": "string",
            "example": "My name is Olivier and I"
          },
          "parameters": {
            "$ref": "#/components/schemas/GenerateParameters"
          }
        }
      },
      "GenerateResponse": {
        "type": "object",
        "required": [
          "generated_text"
        ],
        "properties": {
          "details": {
643
644
645
646
647
648
            "allOf": [
              {
                "$ref": "#/components/schemas/Details"
              }
            ],
            "nullable": true
649
650
651
652
653
654
655
          },
          "generated_text": {
            "type": "string",
            "example": "test"
          }
        }
      },
656
657
658
659
      "Info": {
        "type": "object",
        "required": [
          "model_id",
660
661
662
663
664
665
666
667
668
669
670
          "model_dtype",
          "model_device_type",
          "max_concurrent_requests",
          "max_best_of",
          "max_stop_sequences",
          "max_input_length",
          "max_total_tokens",
          "waiting_served_ratio",
          "max_batch_total_tokens",
          "max_waiting_tokens",
          "validation_workers",
671
672
673
          "version"
        ],
        "properties": {
674
675
676
677
678
679
680
681
682
          "docker_label": {
            "type": "string",
            "example": "null",
            "nullable": true
          },
          "max_batch_total_tokens": {
            "type": "integer",
            "format": "int32",
            "example": "32000",
683
            "minimum": 0
684
685
686
687
          },
          "max_best_of": {
            "type": "integer",
            "example": "2",
688
            "minimum": 0
689
690
691
692
693
          },
          "max_concurrent_requests": {
            "type": "integer",
            "description": "Router Parameters",
            "example": "128",
694
            "minimum": 0
695
696
697
698
          },
          "max_input_length": {
            "type": "integer",
            "example": "1024",
699
            "minimum": 0
700
701
702
703
          },
          "max_stop_sequences": {
            "type": "integer",
            "example": "4",
704
            "minimum": 0
705
706
707
708
          },
          "max_total_tokens": {
            "type": "integer",
            "example": "2048",
709
            "minimum": 0
710
711
712
713
          },
          "max_waiting_tokens": {
            "type": "integer",
            "example": "20",
714
            "minimum": 0
715
716
717
718
719
720
721
722
723
          },
          "model_device_type": {
            "type": "string",
            "example": "cuda"
          },
          "model_dtype": {
            "type": "string",
            "example": "torch.float16"
          },
724
725
          "model_id": {
            "type": "string",
726
            "description": "Model info",
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
            "example": "bigscience/blomm-560m"
          },
          "model_pipeline_tag": {
            "type": "string",
            "example": "text-generation",
            "nullable": true
          },
          "model_sha": {
            "type": "string",
            "example": "e985a63cdc139290c5f700ff1929f0b5942cced2",
            "nullable": true
          },
          "sha": {
            "type": "string",
            "example": "null",
            "nullable": true
          },
744
745
746
          "validation_workers": {
            "type": "integer",
            "example": "2",
747
            "minimum": 0
748
          },
749
750
          "version": {
            "type": "string",
751
            "description": "Router Info",
752
            "example": "0.5.0"
753
754
755
756
757
          },
          "waiting_served_ratio": {
            "type": "number",
            "format": "float",
            "example": "1.2"
758
759
760
          }
        }
      },
761
762
763
764
765
766
767
768
769
770
771
      "PrefillToken": {
        "type": "object",
        "required": [
          "id",
          "text",
          "logprob"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
772
            "example": 0,
773
            "minimum": 0
774
775
776
777
778
779
780
781
782
783
784
785
786
          },
          "logprob": {
            "type": "number",
            "format": "float",
            "example": -0.34,
            "nullable": true
          },
          "text": {
            "type": "string",
            "example": "test"
          }
        }
      },
787
788
789
790
791
792
793
794
795
796
797
798
799
      "StreamDetails": {
        "type": "object",
        "required": [
          "finish_reason",
          "generated_tokens"
        ],
        "properties": {
          "finish_reason": {
            "$ref": "#/components/schemas/FinishReason"
          },
          "generated_tokens": {
            "type": "integer",
            "format": "int32",
800
            "example": 1,
801
            "minimum": 0
802
803
804
805
          },
          "seed": {
            "type": "integer",
            "format": "int64",
806
            "example": 42,
807
            "nullable": true,
808
            "minimum": 0
809
810
811
812
813
814
815
816
817
818
          }
        }
      },
      "StreamResponse": {
        "type": "object",
        "required": [
          "token"
        ],
        "properties": {
          "details": {
819
820
821
822
823
            "allOf": [
              {
                "$ref": "#/components/schemas/StreamDetails"
              }
            ],
824
            "default": "null",
825
            "nullable": true
826
827
828
829
830
831
832
833
834
          },
          "generated_text": {
            "type": "string",
            "default": "null",
            "example": "test",
            "nullable": true
          },
          "token": {
            "$ref": "#/components/schemas/Token"
835
836
837
838
839
840
          },
          "top_tokens": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Token"
            }
841
842
843
844
845
846
847
848
          }
        }
      },
      "Token": {
        "type": "object",
        "required": [
          "id",
          "text",
849
850
          "logprob",
          "special"
851
852
853
854
855
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
856
            "example": 0,
857
            "minimum": 0
858
859
860
861
862
863
864
          },
          "logprob": {
            "type": "number",
            "format": "float",
            "example": -0.34,
            "nullable": true
          },
865
866
867
868
          "special": {
            "type": "boolean",
            "example": "false"
          },
869
870
871
872
873
874
875
876
877
878
879
880
881
882
          "text": {
            "type": "string",
            "example": "test"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Text Generation Inference",
      "description": "Hugging Face Text Generation Inference API"
    }
  ]
Nicolas Patry's avatar
Nicolas Patry committed
883
}