openapi.json 20.9 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
v0.8.2  
OlivierDehaene committed
13
    "version": "0.8.2"
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
        }
      }
    },
    "/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"
                }
              }
            }
          }
        }
293
      }
OlivierDehaene's avatar
OlivierDehaene committed
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
    },
    "/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"
                }
              }
            }
          }
314
        }
OlivierDehaene's avatar
OlivierDehaene committed
315
      }
316
317
318
319
    }
  },
  "components": {
    "schemas": {
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
      "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",
340
341
            "example": 1,
            "minimum": 0.0
342
343
344
345
346
347
348
349
350
351
352
          },
          "prefill": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PrefillToken"
            }
          },
          "seed": {
            "type": "integer",
            "format": "int64",
            "example": 42,
353
354
            "nullable": true,
            "minimum": 0.0
355
356
357
358
359
360
361
362
363
          },
          "tokens": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Token"
            }
          }
        }
      },
364
365
366
367
368
369
370
371
372
373
374
375
376
377
      "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
378
379
            "type": "boolean",
            "default": "false"
380
381
382
          }
        }
      },
383
384
385
386
      "Details": {
        "type": "object",
        "required": [
          "finish_reason",
387
388
389
          "generated_tokens",
          "prefill",
          "tokens"
390
391
        ],
        "properties": {
392
393
394
395
          "best_of_sequences": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BestOfSequence"
396
397
            },
            "nullable": true
398
          },
399
400
401
402
403
404
          "finish_reason": {
            "$ref": "#/components/schemas/FinishReason"
          },
          "generated_tokens": {
            "type": "integer",
            "format": "int32",
405
406
            "example": 1,
            "minimum": 0.0
407
408
409
410
          },
          "prefill": {
            "type": "array",
            "items": {
411
              "$ref": "#/components/schemas/PrefillToken"
412
413
414
415
416
            }
          },
          "seed": {
            "type": "integer",
            "format": "int64",
417
            "example": 42,
418
419
            "nullable": true,
            "minimum": 0.0
420
421
422
423
424
425
426
427
428
429
430
431
          },
          "tokens": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Token"
            }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
432
433
          "error",
          "error_type"
434
435
436
437
        ],
        "properties": {
          "error": {
            "type": "string"
438
439
440
          },
          "error_type": {
            "type": "string"
441
442
443
444
445
446
447
448
449
450
451
452
453
454
          }
        }
      },
      "FinishReason": {
        "type": "string",
        "enum": [
          "length",
          "eos_token",
          "stop_sequence"
        ]
      },
      "GenerateParameters": {
        "type": "object",
        "properties": {
455
456
457
458
459
          "best_of": {
            "type": "integer",
            "default": "null",
            "example": 1,
            "nullable": true,
460
            "minimum": 0.0,
461
462
            "exclusiveMinimum": 0.0
          },
OlivierDehaene's avatar
OlivierDehaene committed
463
464
465
466
          "decoder_input_details": {
            "type": "boolean",
            "default": "true"
          },
467
468
469
470
471
472
473
474
475
476
477
478
479
          "details": {
            "type": "boolean",
            "default": "true"
          },
          "do_sample": {
            "type": "boolean",
            "default": "false",
            "example": true
          },
          "max_new_tokens": {
            "type": "integer",
            "format": "int32",
            "default": "20",
480
            "minimum": 0.0,
481
482
483
484
485
486
487
488
489
490
491
            "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
492
493
          "return_full_text": {
            "type": "boolean",
494
495
496
            "default": "null",
            "example": false,
            "nullable": true
OlivierDehaene's avatar
OlivierDehaene committed
497
          },
498
499
          "seed": {
            "type": "integer",
500
501
502
503
            "format": "int64",
            "default": "null",
            "example": "null",
            "nullable": true,
504
            "minimum": 0.0,
505
            "exclusiveMinimum": 0.0
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
          },
          "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
541
          },
542
543
544
545
          "truncate": {
            "type": "integer",
            "default": "null",
            "example": "null",
546
547
            "nullable": true,
            "minimum": 0.0
548
549
550
551
552
553
554
555
556
557
          },
          "typical_p": {
            "type": "number",
            "format": "float",
            "default": "null",
            "example": 0.95,
            "nullable": true,
            "maximum": 1.0,
            "exclusiveMinimum": 0.0
          },
OlivierDehaene's avatar
OlivierDehaene committed
558
559
560
561
          "watermark": {
            "type": "boolean",
            "default": "false",
            "example": true
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
          }
        }
      },
      "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": {
587
588
589
590
591
592
            "allOf": [
              {
                "$ref": "#/components/schemas/Details"
              }
            ],
            "nullable": true
593
594
595
596
597
598
599
          },
          "generated_text": {
            "type": "string",
            "example": "test"
          }
        }
      },
600
601
602
603
      "Info": {
        "type": "object",
        "required": [
          "model_id",
604
605
606
607
608
609
610
611
612
613
614
          "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",
615
616
617
          "version"
        ],
        "properties": {
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
          "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"
          },
668
669
          "model_id": {
            "type": "string",
670
            "description": "Model info",
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
            "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
          },
688
689
690
691
692
          "validation_workers": {
            "type": "integer",
            "example": "2",
            "minimum": 0.0
          },
693
694
          "version": {
            "type": "string",
695
            "description": "Router Info",
696
            "example": "0.5.0"
697
698
699
700
701
          },
          "waiting_served_ratio": {
            "type": "number",
            "format": "float",
            "example": "1.2"
702
703
704
          }
        }
      },
705
706
707
708
709
710
711
712
713
714
715
      "PrefillToken": {
        "type": "object",
        "required": [
          "id",
          "text",
          "logprob"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
716
717
            "example": 0,
            "minimum": 0.0
718
719
720
721
722
723
724
725
726
727
728
729
730
          },
          "logprob": {
            "type": "number",
            "format": "float",
            "example": -0.34,
            "nullable": true
          },
          "text": {
            "type": "string",
            "example": "test"
          }
        }
      },
731
732
733
734
735
736
737
738
739
740
741
742
743
      "StreamDetails": {
        "type": "object",
        "required": [
          "finish_reason",
          "generated_tokens"
        ],
        "properties": {
          "finish_reason": {
            "$ref": "#/components/schemas/FinishReason"
          },
          "generated_tokens": {
            "type": "integer",
            "format": "int32",
744
745
            "example": 1,
            "minimum": 0.0
746
747
748
749
          },
          "seed": {
            "type": "integer",
            "format": "int64",
750
            "example": 42,
751
752
            "nullable": true,
            "minimum": 0.0
753
754
755
756
757
758
759
760
761
762
          }
        }
      },
      "StreamResponse": {
        "type": "object",
        "required": [
          "token"
        ],
        "properties": {
          "details": {
763
764
765
766
767
768
            "allOf": [
              {
                "$ref": "#/components/schemas/StreamDetails"
              }
            ],
            "nullable": true
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
          },
          "generated_text": {
            "type": "string",
            "default": "null",
            "example": "test",
            "nullable": true
          },
          "token": {
            "$ref": "#/components/schemas/Token"
          }
        }
      },
      "Token": {
        "type": "object",
        "required": [
          "id",
          "text",
786
787
          "logprob",
          "special"
788
789
790
791
792
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
793
794
            "example": 0,
            "minimum": 0.0
795
796
797
798
799
800
801
          },
          "logprob": {
            "type": "number",
            "format": "float",
            "example": -0.34,
            "nullable": true
          },
802
803
804
805
          "special": {
            "type": "boolean",
            "example": "false"
          },
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
          "text": {
            "type": "string",
            "example": "test"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Text Generation Inference",
      "description": "Hugging Face Text Generation Inference API"
    }
  ]
}