openapi.json 21.7 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"
    },
Nicolas Patry's avatar
Nicolas Patry committed
13
    "version": "1.0.1"
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
370
            "example": 1,
            "minimum": 0.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
383
            "nullable": true,
            "minimum": 0.0
384
385
386
387
388
389
390
391
392
          },
          "tokens": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Token"
            }
          }
        }
      },
393
394
395
396
397
398
399
400
401
402
403
404
405
406
      "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
407
408
            "type": "boolean",
            "default": "false"
409
410
411
          }
        }
      },
412
413
414
415
      "Details": {
        "type": "object",
        "required": [
          "finish_reason",
416
417
418
          "generated_tokens",
          "prefill",
          "tokens"
419
420
        ],
        "properties": {
421
422
423
424
          "best_of_sequences": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BestOfSequence"
425
426
            },
            "nullable": true
427
          },
428
429
430
431
432
433
          "finish_reason": {
            "$ref": "#/components/schemas/FinishReason"
          },
          "generated_tokens": {
            "type": "integer",
            "format": "int32",
434
435
            "example": 1,
            "minimum": 0.0
436
437
438
439
          },
          "prefill": {
            "type": "array",
            "items": {
440
              "$ref": "#/components/schemas/PrefillToken"
441
442
443
444
445
            }
          },
          "seed": {
            "type": "integer",
            "format": "int64",
446
            "example": 42,
447
448
            "nullable": true,
            "minimum": 0.0
449
450
451
452
453
454
455
456
457
458
459
460
          },
          "tokens": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Token"
            }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
461
462
          "error",
          "error_type"
463
464
465
466
        ],
        "properties": {
          "error": {
            "type": "string"
467
468
469
          },
          "error_type": {
            "type": "string"
470
471
472
473
474
475
476
477
478
479
480
481
482
483
          }
        }
      },
      "FinishReason": {
        "type": "string",
        "enum": [
          "length",
          "eos_token",
          "stop_sequence"
        ]
      },
      "GenerateParameters": {
        "type": "object",
        "properties": {
484
485
486
487
488
          "best_of": {
            "type": "integer",
            "default": "null",
            "example": 1,
            "nullable": true,
489
            "minimum": 0.0,
490
491
            "exclusiveMinimum": 0.0
          },
OlivierDehaene's avatar
OlivierDehaene committed
492
493
494
495
          "decoder_input_details": {
            "type": "boolean",
            "default": "true"
          },
496
497
498
499
500
501
502
503
504
505
506
507
508
          "details": {
            "type": "boolean",
            "default": "true"
          },
          "do_sample": {
            "type": "boolean",
            "default": "false",
            "example": true
          },
          "max_new_tokens": {
            "type": "integer",
            "format": "int32",
            "default": "20",
509
            "minimum": 0.0,
510
511
512
513
514
515
516
517
518
519
520
            "exclusiveMaximum": 512.0,
            "exclusiveMinimum": 0.0
          },
          "repetition_penalty": {
            "type": "number",
            "format": "float",
            "default": "null",
            "example": 1.03,
            "nullable": true,
            "exclusiveMinimum": 0.0
          },
OlivierDehaene's avatar
OlivierDehaene committed
521
522
          "return_full_text": {
            "type": "boolean",
523
524
525
            "default": "null",
            "example": false,
            "nullable": true
OlivierDehaene's avatar
OlivierDehaene committed
526
          },
527
528
          "seed": {
            "type": "integer",
529
530
531
532
            "format": "int64",
            "default": "null",
            "example": "null",
            "nullable": true,
533
            "minimum": 0.0,
534
            "exclusiveMinimum": 0.0
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
          },
          "stop": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "photographer"
            ],
            "maxItems": 4
          },
          "temperature": {
            "type": "number",
            "format": "float",
            "default": "null",
            "example": 0.5,
            "nullable": true,
            "exclusiveMinimum": 0.0
          },
          "top_k": {
            "type": "integer",
            "format": "int32",
            "default": "null",
            "example": 10,
            "nullable": true,
            "exclusiveMinimum": 0.0
          },
          "top_p": {
            "type": "number",
            "format": "float",
            "default": "null",
            "example": 0.95,
            "nullable": true,
            "maximum": 1.0,
            "exclusiveMinimum": 0.0
OlivierDehaene's avatar
OlivierDehaene committed
570
          },
571
572
573
574
          "truncate": {
            "type": "integer",
            "default": "null",
            "example": "null",
575
576
            "nullable": true,
            "minimum": 0.0
577
578
579
580
581
582
583
584
585
586
          },
          "typical_p": {
            "type": "number",
            "format": "float",
            "default": "null",
            "example": 0.95,
            "nullable": true,
            "maximum": 1.0,
            "exclusiveMinimum": 0.0
          },
OlivierDehaene's avatar
OlivierDehaene committed
587
588
589
590
          "watermark": {
            "type": "boolean",
            "default": "false",
            "example": true
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
          }
        }
      },
      "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": {
616
617
618
619
620
621
            "allOf": [
              {
                "$ref": "#/components/schemas/Details"
              }
            ],
            "nullable": true
622
623
624
625
626
627
628
          },
          "generated_text": {
            "type": "string",
            "example": "test"
          }
        }
      },
629
630
631
632
      "Info": {
        "type": "object",
        "required": [
          "model_id",
633
634
635
636
637
638
639
640
641
642
643
          "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",
644
645
646
          "version"
        ],
        "properties": {
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
          "docker_label": {
            "type": "string",
            "example": "null",
            "nullable": true
          },
          "max_batch_total_tokens": {
            "type": "integer",
            "format": "int32",
            "example": "32000",
            "minimum": 0.0
          },
          "max_best_of": {
            "type": "integer",
            "example": "2",
            "minimum": 0.0
          },
          "max_concurrent_requests": {
            "type": "integer",
            "description": "Router Parameters",
            "example": "128",
            "minimum": 0.0
          },
          "max_input_length": {
            "type": "integer",
            "example": "1024",
            "minimum": 0.0
          },
          "max_stop_sequences": {
            "type": "integer",
            "example": "4",
            "minimum": 0.0
          },
          "max_total_tokens": {
            "type": "integer",
            "example": "2048",
            "minimum": 0.0
          },
          "max_waiting_tokens": {
            "type": "integer",
            "example": "20",
            "minimum": 0.0
          },
          "model_device_type": {
            "type": "string",
            "example": "cuda"
          },
          "model_dtype": {
            "type": "string",
            "example": "torch.float16"
          },
697
698
          "model_id": {
            "type": "string",
699
            "description": "Model info",
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
            "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
          },
717
718
719
720
721
          "validation_workers": {
            "type": "integer",
            "example": "2",
            "minimum": 0.0
          },
722
723
          "version": {
            "type": "string",
724
            "description": "Router Info",
725
            "example": "0.5.0"
726
727
728
729
730
          },
          "waiting_served_ratio": {
            "type": "number",
            "format": "float",
            "example": "1.2"
731
732
733
          }
        }
      },
734
735
736
737
738
739
740
741
742
743
744
      "PrefillToken": {
        "type": "object",
        "required": [
          "id",
          "text",
          "logprob"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
745
746
            "example": 0,
            "minimum": 0.0
747
748
749
750
751
752
753
754
755
756
757
758
759
          },
          "logprob": {
            "type": "number",
            "format": "float",
            "example": -0.34,
            "nullable": true
          },
          "text": {
            "type": "string",
            "example": "test"
          }
        }
      },
760
761
762
763
764
765
766
767
768
769
770
771
772
      "StreamDetails": {
        "type": "object",
        "required": [
          "finish_reason",
          "generated_tokens"
        ],
        "properties": {
          "finish_reason": {
            "$ref": "#/components/schemas/FinishReason"
          },
          "generated_tokens": {
            "type": "integer",
            "format": "int32",
773
774
            "example": 1,
            "minimum": 0.0
775
776
777
778
          },
          "seed": {
            "type": "integer",
            "format": "int64",
779
            "example": 42,
780
781
            "nullable": true,
            "minimum": 0.0
782
783
784
785
786
787
788
789
790
791
          }
        }
      },
      "StreamResponse": {
        "type": "object",
        "required": [
          "token"
        ],
        "properties": {
          "details": {
792
793
794
795
796
797
            "allOf": [
              {
                "$ref": "#/components/schemas/StreamDetails"
              }
            ],
            "nullable": true
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
          },
          "generated_text": {
            "type": "string",
            "default": "null",
            "example": "test",
            "nullable": true
          },
          "token": {
            "$ref": "#/components/schemas/Token"
          }
        }
      },
      "Token": {
        "type": "object",
        "required": [
          "id",
          "text",
815
816
          "logprob",
          "special"
817
818
819
820
821
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
822
823
            "example": 0,
            "minimum": 0.0
824
825
826
827
828
829
830
          },
          "logprob": {
            "type": "number",
            "format": "float",
            "example": -0.34,
            "nullable": true
          },
831
832
833
834
          "special": {
            "type": "boolean",
            "example": "false"
          },
835
836
837
838
839
840
841
842
843
844
845
846
847
848
          "text": {
            "type": "string",
            "example": "test"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Text Generation Inference",
      "description": "Hugging Face Text Generation Inference API"
    }
  ]
Nicolas Patry's avatar
Nicolas Patry committed
849
}