-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapi.json
828 lines (828 loc) · 24.5 KB
/
api.json
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
{
"openapi": "3.0.0",
"paths": {
"/api/v1/images/models/{modelId}/inferences": {
"post": {
"operationId": "InferencesController_generate",
"summary": "Generate an Image",
"description": "Generate an image by providing a text description. Generations usually take bettween 4-20 seconds per image. Total generation time depends on the number of `steps` and `noOfImages` you select. This endpoint will submit the generation job and return immediately. To retrieve the results you must provide a webhook URL or query/poll the [Get a Single Image Job](https://reference.tryleap.ai/reference/inferencescontroller_findone-1) endpoint.",
"parameters": [
{
"name": "modelId",
"required": true,
"in": "path",
"description": "The ID of the model to use to generate images. This can be a custom model, or a public model. To view the list of public models, visit: https://docs.tryleap.ai/public-models",
"example": "26a1a203-3a46-42cb-8cfa-f4de075907d8",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"description": "The parameters to use to generate the image.",
"content": {
"application/json": {
"schema": {
"example": {
"prompt": "A photo of an astronaut riding a horse",
"steps": 50,
"height": 1024,
"width": 1024,
"numberOfImages": 1
},
"$ref": "#/components/schemas/CreateInferenceDto"
},
"examples": {
"Create a new inference": {
"value": {
"prompt": "A photo of an astronaut riding a horse",
"steps": 50,
"height": 1024,
"width": 1024,
"numberOfImages": 1
}
}
}
}
}
},
"responses": {
"201": {
"description": "Successfully submitted image generation job.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/InferenceEntity"
}
}
}
}
},
"tags": [
"Images"
],
"security": [
{
"bearer": []
}
]
},
"get": {
"operationId": "InferencesController_listAll",
"summary": "List All Image Jobs",
"description": "Fetch a list of inference jobs for a specific model.",
"parameters": [
{
"name": "modelId",
"required": true,
"in": "path",
"description": "The ID of the model to generate images. This can be a custom model or a public model. Visit: https://docs.tryleap.ai/public-models to view the list of public models.",
"example": "26a1a203-3a46-42cb-8cfa-f4de075907d8",
"schema": {
"type": "string"
}
},
{
"name": "onlyFinished",
"required": false,
"in": "query",
"description": "If set to true, only finished inferences will be returned. If set to false or not set, all inference jobs will be returned.",
"schema": {
"type": "boolean"
}
},
{
"name": "page",
"required": false,
"in": "query",
"description": "The page to request.",
"allowEmptyValue": true,
"schema": {
"type": "number"
}
},
{
"name": "pageSize",
"required": false,
"in": "query",
"description": "The number of items to return per page.",
"allowEmptyValue": true,
"schema": {
"type": "number"
}
}
],
"responses": {
"200": {
"description": "Successfully retrieved list of image generation jobs.",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/InferenceEntity"
}
}
}
}
}
},
"tags": [
"Images"
],
"security": [
{
"bearer": []
}
]
}
},
"/api/v1/images/models/{modelId}/inferences/{inferenceId}": {
"get": {
"operationId": "InferencesController_findOne",
"summary": "Get Single Image Job",
"description": "Retrieve a single image generation job, including the urls for the images generated.",
"parameters": [
{
"name": "modelId",
"required": true,
"in": "path",
"description": "The ID of the model to use to generate images. This can be a custom model, or a public model. To view the list of public models, visit: https://docs.tryleap.ai/public-models",
"example": "26a1a203-3a46-42cb-8cfa-f4de075907d8",
"schema": {
"type": "string"
}
},
{
"name": "inferenceId",
"required": true,
"in": "path",
"description": "The ID of the image generation job to retrieve. This is the same ID that is returned when you submit a new image generation job.",
"example": "a047df00-8bdd-4d57-a9bd-6eebef36ecaa",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successfully retrieved image generation job.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/InferenceEntity"
}
}
}
}
},
"tags": [
"Images"
],
"security": [
{
"bearer": []
}
]
},
"delete": {
"operationId": "InferencesController_delete",
"summary": "Delete Image Job",
"description": "Delete the image job and all related images.",
"parameters": [
{
"name": "modelId",
"required": true,
"in": "path",
"description": "The ID of the model to use to generate images. This can be a custom model, or a public model. To view the list of public models, visit: https://docs.tryleap.ai/public-models",
"example": "26a1a203-3a46-42cb-8cfa-f4de075907d8",
"schema": {
"type": "string"
}
},
{
"name": "inferenceId",
"required": true,
"in": "path",
"description": "The ID of the image generation job to retrieve. This is the same ID that is returned when you submit a new image generation job.",
"example": "a047df00-8bdd-4d57-a9bd-6eebef36ecaa",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successfully deleted image generation job."
}
},
"tags": [
"Images"
],
"security": [
{
"bearer": []
}
]
}
},
"/api/v2/images/models/new": {
"post": {
"operationId": "train",
"summary": "Train Model",
"description": "Upload a few image samples, and train a new model. Training usually takes 20-40 minutes. To be notified when the model completes training you must provide a `webhookUrl` in the training request, or check for completion by calling [Get a Single Model](https://reference.tryleap.ai/reference/get-model-1). After training completes, you can use the model to generate images with [Generate Images](https://reference.tryleap.ai/reference/inferencescontroller_create-1).",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/CreateAndTrainModelDto"
}
}
}
},
"responses": {
"201": {
"description": "Successfully submitted training job.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ModelV2Entity"
}
}
}
}
},
"tags": [
"Image Models"
],
"security": [
{
"bearer": []
}
]
}
},
"/api/v2/images/models": {
"get": {
"operationId": "list-all",
"summary": "List All Models",
"description": "This endpoint will return a list of all models for the workspace.",
"parameters": [],
"responses": {
"200": {
"description": "Successfully retrieved models.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ListModelsV2Response"
}
}
}
}
},
"tags": [
"Image Models"
],
"security": [
{
"bearer": []
},
{
"bearer": []
}
]
}
},
"/api/v2/images/models/{modelId}": {
"get": {
"operationId": "find-one",
"summary": "Get a Single Model",
"description": "This endpoint will return a single model.",
"parameters": [
{
"name": "modelId",
"required": true,
"in": "path",
"description": "The ID of the model to retrieve.",
"example": "5f9b9c0e-7c1f-4b5c-9c0e-7c1f4b5c9c0e",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successfully retrieved the model.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ModelV2Entity"
}
}
}
},
"404": {
"description": "Model does not exist"
}
},
"tags": [
"Image Models"
],
"security": [
{
"bearer": []
}
]
},
"delete": {
"operationId": "delete",
"summary": "Delete a Model",
"description": "This endpoint will delete a model. This is not reversible.",
"parameters": [
{
"name": "modelId",
"required": true,
"in": "path",
"description": "The ID of the model to delete.",
"example": "5f9b9c0e-7c1f-4b5c-9c0e-7c1f4b5c9c0e",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successfully deleted the model",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ModelV2Entity"
}
}
}
}
},
"tags": [
"Image Models"
],
"security": [
{
"bearer": []
}
]
}
},
"/api/v1/music": {
"post": {
"operationId": "MusicController_generate",
"summary": "Generate Music",
"description": "Generate music by providing a text description. Generations usually take bettween 1-3 minutes. Total generation time depends on the `duration` you select. This endpoint will submit the generation job and return immediately. To retrieve the results you must provide a webhook URL or query/poll the [Get a Music Generation Job](https://reference.tryleap.ai/reference/musiccontroller_findoneaudio) endpoint.",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateMusicgenInferenceDto"
}
}
}
},
"responses": {
"200": {
"description": "Successfully submitted music generation job.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MusicgenInferenceEntity"
}
}
}
}
},
"tags": [
"Music"
],
"security": [
{
"bearer": []
}
]
},
"get": {
"operationId": "MusicController_listAll",
"summary": "List Music Generation Jobs",
"description": "List all music generation jobs for a workspace.",
"parameters": [],
"responses": {
"200": {
"description": "Successfully retrieved music generation jobs.",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MusicgenInferenceEntity"
}
}
}
}
}
},
"tags": [
"Music"
],
"security": [
{
"bearer": []
}
]
}
},
"/api/v1/music/{inferenceId}": {
"get": {
"operationId": "MusicController_findOne",
"summary": "Get a Music Generation Job",
"description": "Get a specific music generation job.",
"parameters": [
{
"name": "inferenceId",
"required": true,
"in": "path",
"description": "The ID of the music generation job to retrieve. This is the same ID returned when you submit a job.",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successfully retrieved music generation job.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MusicgenInferenceEntity"
}
}
}
}
},
"tags": [
"Music"
]
}
}
},
"info": {
"title": "Leap",
"description": "The Official Leap API",
"version": "1.0",
"contact": {}
},
"tags": [],
"servers": [
{
"url": "https://api.tryleap.ai",
"description": "Production"
}
],
"components": {
"securitySchemes": {
"bearer": {
"scheme": "bearer",
"bearerFormat": "JWT",
"type": "http"
}
},
"schemas": {
"CreateInferenceDto": {
"type": "object",
"properties": {
"prompt": {
"type": "string",
"description": "A text description of the image you what you want to generate.",
"example": "A photo of an astronaut riding a horse",
"default": "A photo of an astronaut riding a horse"
},
"negativePrompt": {
"type": "string",
"description": "A text description of what the image should try to avoid generating.",
"example": "asymmetric, bad hands, bad hair",
"default": "asymmetric, watermarks"
},
"steps": {
"type": "number",
"description": "How many steps the AI will take to generate the image. Lower is faster but less detailed, higher is slower more detailed.",
"example": 50,
"default": 50
},
"width": {
"type": "number",
"description": "The width of the image to use for the inference. Must be a multiple of 8. For best results use 1024x1024 for SDXL, and 512x512 for other models.",
"example": 1024,
"default": 1024
},
"height": {
"type": "number",
"description": "The height of the image to use for the inference. Must be a multiple of 8. For best results use 1024x1024 for SDXL, and 512x512 for other models.",
"example": 1024,
"default": 1024
},
"numberOfImages": {
"type": "number",
"description": "The number of images to generate, up to 4.",
"example": 1,
"default": 1
},
"promptStrength": {
"type": "number",
"description": "The higher the prompt strength, the closer the generated image will be to the prompt. Must be between 0 and 30.",
"example": 7,
"default": 7
},
"seed": {
"type": "number",
"description": "A random number to use as a seed when generating the image. This is helpful if you want to generate the same image multiple times. If you want to generate different images, keep this empty or provide a random number.",
"example": 4523184,
"default": 4523184
},
"webhookUrl": {
"type": "string",
"description": "An optional webhook URL that will be called with a POST request when the image generation request completes."
}
},
"required": [
"prompt"
]
},
"InferenceImageEntity": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"uri": {
"type": "string"
}
},
"required": [
"id",
"createdAt",
"uri"
]
},
"InferenceEntity": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"createdAt": {
"format": "date-time",
"type": "string"
},
"prompt": {
"type": "string"
},
"negativePrompt": {
"type": "string"
},
"seed": {
"type": "number"
},
"width": {
"type": "number"
},
"height": {
"type": "number"
},
"promptStrength": {
"type": "number"
},
"numberOfImages": {
"type": "number"
},
"state": {
"type": "string",
"enum": [
"failed",
"finished",
"processing",
"queued"
]
},
"status": {
"type": "string",
"enum": [
"failed",
"finished",
"processing",
"queued"
]
},
"steps": {
"type": "number"
},
"images": {
"type": "array",
"items": {
"$ref": "#/components/schemas/InferenceImageEntity"
}
},
"modelId": {
"type": "string"
},
"upscalingOption": {
"type": "string",
"enum": [
"x1",
"x2",
"x4"
]
}
},
"required": [
"id",
"createdAt",
"prompt",
"negativePrompt",
"seed",
"width",
"height",
"promptStrength",
"numberOfImages",
"state",
"status",
"steps",
"images",
"modelId",
"upscalingOption"
]
},
"CreateAndTrainModelDto": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Provide a name so you can more easily identify the model.",
"example": "Alex Avatar Model"
},
"subjectKeyword": {
"type": "string",
"description": "This is the keyword you will use during image generation to trigger your custom subject. For example \"a photo of @me\".",
"example": "@me"
},
"subjectType": {
"type": "string",
"description": "The subject type - a short description, usually a noun, that describes what the underlying model is learning. For example: person, man, woman, cat, dog, icon, style. Defaults to \"person\".",
"default": "person"
},
"webhookUrl": {
"type": "string",
"description": "An optional webhook URL that will be called with a POST request when the model completes training or fails.",
"example": "https://example.com/api/webhook"
},
"imageSampleUrls": {
"type": "array",
"description": "An array of strings containing the URLs of the images to upload. Either this or imageSampleFiles is required, but not both.",
"format": "string",
"items": {
"type": "string",
"format": "string"
}
},
"imageSampleFiles": {
"type": "array",
"description": "An array of files containing the images to upload. Either this or imageSampleUrls is required, but not both.",
"format": "binary",
"items": {
"type": "string",
"format": "binary"
}
}
}
},
"ModelV2Entity": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"subjectKeyword": {
"type": "string"
},
"subjectType": {
"type": "string"
},
"status": {
"type": "string"
},
"imageSamples": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"id",
"name",
"createdAt",
"subjectKeyword",
"subjectType",
"status",
"imageSamples"
]
},
"ListModelsV2Response": {
"type": "object",
"properties": {
"models": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ModelV2Entity"
}
}
},
"required": [
"models"
]
},
"CreateMusicgenInferenceDto": {
"type": "object",
"properties": {
"prompt": {
"type": "string",
"description": "A description of the music you want to generate.",
"example": "An electronic music soundtrack with a trumpet solo",
"default": "An electronic music soundtrack with a trumpet solo"
},
"mode": {
"type": "string",
"description": "Select a mode, each option generates different results. Melody is best for melody, music is best for full songs",
"default": "melody",
"enum": [
"melody",
"music"
]
},
"duration": {
"type": "number",
"description": "Duration of the generated audio in seconds. Max 30 seconds.",
"default": 28
}
},
"required": [
"prompt",
"mode",
"duration"
]
},
"MusicgenInferenceEntity": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"createdAt": {
"format": "date-time",
"type": "string"
},
"prompt": {
"type": "string"
},
"state": {
"type": "string",
"enum": [
"failed",
"finished",
"processing",
"queued"
]
},
"media_uri": {
"type": "string"
}
},
"required": [
"id",
"createdAt",
"prompt",
"state"
]
}
}
}
}