-
Notifications
You must be signed in to change notification settings - Fork 0
/
openai_api_spec.json
8659 lines (8659 loc) · 371 KB
/
openai_api_spec.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
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"openapi": "3.0.0",
"info": {
"title": "OpenAI API",
"description": "The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.",
"version": "2.0.0",
"termsOfService": "https://openai.com/policies/terms-of-use",
"contact": {
"name": "OpenAI Support",
"url": "https://help.openai.com/"
},
"license": {
"name": "MIT",
"url": "https://github.com/openai/openai-openapi/blob/master/LICENSE"
}
},
"servers": [
{
"url": "https://api.openai.com/v1"
}
],
"tags": [
{
"name": "Assistants",
"description": "Build Assistants that can call models and use tools."
},
{
"name": "Audio",
"description": "Learn how to turn audio into text or text into audio."
},
{
"name": "Chat",
"description": "Given a list of messages comprising a conversation, the model will return a response."
},
{
"name": "Completions",
"description": "Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position."
},
{
"name": "Embeddings",
"description": "Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms."
},
{
"name": "Fine-tuning",
"description": "Manage fine-tuning jobs to tailor a model to your specific training data."
},
{
"name": "Files",
"description": "Files are used to upload documents that can be used with features like Assistants and Fine-tuning."
},
{
"name": "Images",
"description": "Given a prompt and/or an input image, the model will generate a new image."
},
{
"name": "Models",
"description": "List and describe the various models available in the API."
},
{
"name": "Moderations",
"description": "Given a input text, outputs if the model classifies it as violating OpenAI's content policy."
},
{
"name": "Fine-tunes",
"description": "Manage legacy fine-tuning jobs to tailor a model to your specific training data."
},
{
"name": "Edits",
"description": "Given a prompt and an instruction, the model will return an edited version of the prompt."
}
],
"paths": {
"/chat/completions": {
"post": {
"operationId": "createChatCompletion",
"tags": [
"Chat"
],
"summary": "Creates a model response for the given chat conversation.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateChatCompletionRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateChatCompletionResponse"
}
}
}
}
},
"x-oaiMeta": {
"name": "Create chat completion",
"group": "chat",
"returns": "Returns a [chat completion](/docs/api-reference/chat/object) object, or a streamed sequence of [chat completion chunk](/docs/api-reference/chat/streaming) objects if the request is streamed.\n",
"path": "create",
"examples": [
{
"title": "Default",
"request": {
"curl": "curl https://api.openai.com/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"VAR_model_id\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ]\n }'\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\ncompletion = client.chat.completions.create(\n model=\"VAR_model_id\",\n messages=[\n {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n {\"role\": \"user\", \"content\": \"Hello!\"}\n ]\n)\n\nprint(completion.choices[0].message)\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const completion = await openai.chat.completions.create({\n messages: [{ role: \"system\", content: \"You are a helpful assistant.\" }],\n model: \"VAR_model_id\",\n });\n\n console.log(completion.choices[0]);\n}\n\nmain();"
},
"response": "{\n \"id\": \"chatcmpl-123\",\n \"object\": \"chat.completion\",\n \"created\": 1677652288,\n \"model\": \"gpt-3.5-turbo-0613\",\n \"system_fingerprint\": \"fp_44709d6fcb\",\n \"choices\": [{\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"\\n\\nHello there, how may I assist you today?\",\n },\n \"finish_reason\": \"stop\"\n }],\n \"usage\": {\n \"prompt_tokens\": 9,\n \"completion_tokens\": 12,\n \"total_tokens\": 21\n }\n}\n"
},
{
"title": "Image input",
"request": {
"curl": "curl https://api.openai.com/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"gpt-4-vision-preview\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"What’s in this image?\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg\"\n }\n }\n ]\n }\n ],\n \"max_tokens\": 300\n }'\n",
"python": "from openai import OpenAI\n\nclient = OpenAI()\n\nresponse = client.chat.completions.create(\n model=\"gpt-4-vision-preview\",\n messages=[\n {\n \"role\": \"user\",\n \"content\": [\n {\"type\": \"text\", \"text\": \"What’s in this image?\"},\n {\n \"type\": \"image_url\",\n \"image_url\": \"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg\",\n },\n ],\n }\n ],\n max_tokens=300,\n)\n\nprint(response.choices[0])\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const response = await openai.chat.completions.create({\n model: \"gpt-4-vision-preview\",\n messages: [\n {\n role: \"user\",\n content: [\n { type: \"text\", text: \"What’s in this image?\" },\n {\n type: \"image_url\",\n image_url:\n \"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg\",\n },\n ],\n },\n ],\n });\n console.log(response.choices[0]);\n}\nmain();"
},
"response": "{\n \"id\": \"chatcmpl-123\",\n \"object\": \"chat.completion\",\n \"created\": 1677652288,\n \"model\": \"gpt-3.5-turbo-0613\",\n \"system_fingerprint\": \"fp_44709d6fcb\",\n \"choices\": [{\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"\\n\\nHello there, how may I assist you today?\",\n },\n \"finish_reason\": \"stop\"\n }],\n \"usage\": {\n \"prompt_tokens\": 9,\n \"completion_tokens\": 12,\n \"total_tokens\": 21\n }\n}\n"
},
{
"title": "Streaming",
"request": {
"curl": "curl https://api.openai.com/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"VAR_model_id\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ],\n \"stream\": true\n }'\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\ncompletion = client.chat.completions.create(\n model=\"VAR_model_id\",\n messages=[\n {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n {\"role\": \"user\", \"content\": \"Hello!\"}\n ],\n stream=True\n)\n\nfor chunk in completion:\n print(chunk.choices[0].delta)\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const completion = await openai.chat.completions.create({\n model: \"VAR_model_id\",\n messages: [\n {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n {\"role\": \"user\", \"content\": \"Hello!\"}\n ],\n stream: true,\n });\n\n for await (const chunk of completion) {\n console.log(chunk.choices[0].delta.content);\n }\n}\n\nmain();"
},
"response": "{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"finish_reason\":null}]}\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"content\":\"Hello\"},\"finish_reason\":null}]}\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"content\":\"!\"},\"finish_reason\":null}]}\n\n....\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"content\":\" today\"},\"finish_reason\":null}]}\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"content\":\"?\"},\"finish_reason\":null}]}\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"stop\"}]}\n"
},
{
"title": "Function calling",
"request": {
"curl": "curl https://api.openai.com/v1/chat/completions \\\n-H \"Content-Type: application/json\" \\\n-H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n-d '{\n \"model\": \"gpt-3.5-turbo\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What is the weather like in Boston?\"\n }\n ],\n \"functions\": [\n {\n \"name\": \"get_current_weather\",\n \"description\": \"Get the current weather in a given location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state, e.g. San Francisco, CA\"\n },\n \"unit\": {\n \"type\": \"string\",\n \"enum\": [\"celsius\", \"fahrenheit\"]\n }\n },\n \"required\": [\"location\"]\n }\n }\n ],\n \"function_call\": \"auto\"\n}'\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nfunctions = [\n {\n \"name\": \"get_current_weather\",\n \"description\": \"Get the current weather in a given location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state, e.g. San Francisco, CA\",\n },\n \"unit\": {\"type\": \"string\", \"enum\": [\"celsius\", \"fahrenheit\"]},\n },\n \"required\": [\"location\"],\n },\n }\n]\nmessages = [{\"role\": \"user\", \"content\": \"What's the weather like in Boston today?\"}]\ncompletion = client.chat.completions.create(\n model=\"VAR_model_id\",\n messages=messages,\n functions=functions,\n function_call=\"auto\"\n)\n\nprint(completion)\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const messages = [{\"role\": \"user\", \"content\": \"What's the weather like in Boston today?\"}];\n const functions = [\n {\n \"name\": \"get_current_weather\",\n \"description\": \"Get the current weather in a given location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state, e.g. San Francisco, CA\",\n },\n \"unit\": {\"type\": \"string\", \"enum\": [\"celsius\", \"fahrenheit\"]},\n },\n \"required\": [\"location\"],\n },\n }\n ];\n\n const response = await openai.chat.completions.create({\n model: \"gpt-3.5-turbo\",\n messages: messages,\n functions: functions,\n function_call: \"auto\", // auto is default, but we'll be explicit\n });\n\n console.log(response);\n}\n\nmain();"
},
"response": "{\n \"choices\": [\n {\n \"finish_reason\": \"function_call\",\n \"index\": 0,\n \"message\": {\n \"content\": null,\n \"function_call\": {\n \"arguments\": \"{\\n \\\"location\\\": \\\"Boston, MA\\\"\\n}\",\n \"name\": \"get_current_weather\"\n },\n \"role\": \"assistant\"\n }\n }\n ],\n \"created\": 1694028367,\n \"model\": \"gpt-3.5-turbo-0613\",\n \"system_fingerprint\": \"fp_44709d6fcb\",\n \"object\": \"chat.completion\",\n \"usage\": {\n \"completion_tokens\": 18,\n \"prompt_tokens\": 82,\n \"total_tokens\": 100\n }\n}\n"
}
]
}
}
},
"/completions": {
"post": {
"operationId": "createCompletion",
"tags": [
"Completions"
],
"summary": "Creates a completion for the provided prompt and parameters.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateCompletionRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateCompletionResponse"
}
}
}
}
},
"x-oaiMeta": {
"name": "Create completion",
"returns": "Returns a [completion](/docs/api-reference/completions/object) object, or a sequence of completion objects if the request is streamed.\n",
"legacy": true,
"examples": [
{
"title": "No streaming",
"request": {
"curl": "curl https://api.openai.com/v1/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"VAR_model_id\",\n \"prompt\": \"Say this is a test\",\n \"max_tokens\": 7,\n \"temperature\": 0\n }'\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.completions.create(\n model=\"VAR_model_id\",\n prompt=\"Say this is a test\",\n max_tokens=7,\n temperature=0\n)\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const completion = await openai.completions.create({\n model: \"VAR_model_id\",\n prompt: \"Say this is a test.\",\n max_tokens: 7,\n temperature: 0,\n });\n\n console.log(completion);\n}\nmain();"
},
"response": "{\n \"id\": \"cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7\",\n \"object\": \"text_completion\",\n \"created\": 1589478378,\n \"model\": \"VAR_model_id\",\n \"system_fingerprint\": \"fp_44709d6fcb\",\n \"choices\": [\n {\n \"text\": \"\\n\\nThis is indeed a test\",\n \"index\": 0,\n \"logprobs\": null,\n \"finish_reason\": \"length\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 5,\n \"completion_tokens\": 7,\n \"total_tokens\": 12\n }\n}\n"
},
{
"title": "Streaming",
"request": {
"curl": "curl https://api.openai.com/v1/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"VAR_model_id\",\n \"prompt\": \"Say this is a test\",\n \"max_tokens\": 7,\n \"temperature\": 0,\n \"stream\": true\n }'\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nfor chunk in client.completions.create(\n model=\"VAR_model_id\",\n prompt=\"Say this is a test\",\n max_tokens=7,\n temperature=0,\n stream=True\n):\n print(chunk.choices[0].text)\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const stream = await openai.completions.create({\n model: \"VAR_model_id\",\n prompt: \"Say this is a test.\",\n stream: true,\n });\n\n for await (const chunk of stream) {\n console.log(chunk.choices[0].text)\n }\n}\nmain();"
},
"response": "{\n \"id\": \"cmpl-7iA7iJjj8V2zOkCGvWF2hAkDWBQZe\",\n \"object\": \"text_completion\",\n \"created\": 1690759702,\n \"choices\": [\n {\n \"text\": \"This\",\n \"index\": 0,\n \"logprobs\": null,\n \"finish_reason\": null\n }\n ],\n \"model\": \"gpt-3.5-turbo-instruct\"\n \"system_fingerprint\": \"fp_44709d6fcb\",\n}\n"
}
]
}
}
},
"/edits": {
"post": {
"operationId": "createEdit",
"deprecated": true,
"tags": [
"Edits"
],
"summary": "Creates a new edit for the provided input, instruction, and parameters.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateEditRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateEditResponse"
}
}
}
}
},
"x-oaiMeta": {
"name": "Create edit",
"returns": "Returns an [edit](/docs/api-reference/edits/object) object.\n",
"group": "edits",
"examples": {
"request": {
"curl": "curl https://api.openai.com/v1/edits \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"VAR_model_id\",\n \"input\": \"What day of the wek is it?\",\n \"instruction\": \"Fix the spelling mistakes\"\n }'\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.edits.create(\n model=\"VAR_model_id\",\n input=\"What day of the wek is it?\",\n instruction=\"Fix the spelling mistakes\"\n)\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const edit = await openai.edits.create({\n model: \"VAR_model_id\",\n input: \"What day of the wek is it?\",\n instruction: \"Fix the spelling mistakes.\",\n });\n\n console.log(edit);\n}\n\nmain();"
},
"response": "{\n \"object\": \"edit\",\n \"created\": 1589478378,\n \"choices\": [\n {\n \"text\": \"What day of the week is it?\",\n \"index\": 0,\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 25,\n \"completion_tokens\": 32,\n \"total_tokens\": 57\n }\n}\n"
}
}
}
},
"/images/generations": {
"post": {
"operationId": "createImage",
"tags": [
"Images"
],
"summary": "Creates an image given a prompt.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateImageRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ImagesResponse"
}
}
}
}
},
"x-oaiMeta": {
"name": "Create image",
"returns": "Returns a list of [image](/docs/api-reference/images/object) objects.",
"examples": {
"request": {
"curl": "curl https://api.openai.com/v1/images/generations \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"dall-e-3\",\n \"prompt\": \"A cute baby sea otter\",\n \"n\": 1,\n \"size\": \"1024x1024\"\n }'\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.images.generate(\n model=\"dall-e-3\",\n prompt=\"A cute baby sea otter\",\n n=1,\n size=\"1024x1024\"\n)\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const image = await openai.images.generate({ model: \"dall-e-3\", prompt: \"A cute baby sea otter\" });\n\n console.log(image.data);\n}\nmain();"
},
"response": "{\n \"created\": 1589478378,\n \"data\": [\n {\n \"url\": \"https://...\"\n },\n {\n \"url\": \"https://...\"\n }\n ]\n}\n"
}
}
}
},
"/images/edits": {
"post": {
"operationId": "createImageEdit",
"tags": [
"Images"
],
"summary": "Creates an edited or extended image given an original image and a prompt.",
"requestBody": {
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/CreateImageEditRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ImagesResponse"
}
}
}
}
},
"x-oaiMeta": {
"name": "Create image edit",
"returns": "Returns a list of [image](/docs/api-reference/images/object) objects.",
"examples": {
"request": {
"curl": "curl https://api.openai.com/v1/images/edits \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -F image=\"@otter.png\" \\\n -F mask=\"@mask.png\" \\\n -F prompt=\"A cute baby sea otter wearing a beret\" \\\n -F n=2 \\\n -F size=\"1024x1024\"\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.images.edit(\n image=open(\"otter.png\", \"rb\"),\n mask=open(\"mask.png\", \"rb\"),\n prompt=\"A cute baby sea otter wearing a beret\",\n n=2,\n size=\"1024x1024\"\n)\n",
"node.js": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const image = await openai.images.edit({\n image: fs.createReadStream(\"otter.png\"),\n mask: fs.createReadStream(\"mask.png\"),\n prompt: \"A cute baby sea otter wearing a beret\",\n });\n\n console.log(image.data);\n}\nmain();"
},
"response": "{\n \"created\": 1589478378,\n \"data\": [\n {\n \"url\": \"https://...\"\n },\n {\n \"url\": \"https://...\"\n }\n ]\n}\n"
}
}
}
},
"/images/variations": {
"post": {
"operationId": "createImageVariation",
"tags": [
"Images"
],
"summary": "Creates a variation of a given image.",
"requestBody": {
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/CreateImageVariationRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ImagesResponse"
}
}
}
}
},
"x-oaiMeta": {
"name": "Create image variation",
"returns": "Returns a list of [image](/docs/api-reference/images/object) objects.",
"examples": {
"request": {
"curl": "curl https://api.openai.com/v1/images/variations \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -F image=\"@otter.png\" \\\n -F n=2 \\\n -F size=\"1024x1024\"\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nresponse = client.images.create_variation(\n image=open(\"image_edit_original.png\", \"rb\"),\n n=2,\n size=\"1024x1024\"\n)\n",
"node.js": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const image = await openai.images.createVariation({\n image: fs.createReadStream(\"otter.png\"),\n });\n\n console.log(image.data);\n}\nmain();"
},
"response": "{\n \"created\": 1589478378,\n \"data\": [\n {\n \"url\": \"https://...\"\n },\n {\n \"url\": \"https://...\"\n }\n ]\n}\n"
}
}
}
},
"/embeddings": {
"post": {
"operationId": "createEmbedding",
"tags": [
"Embeddings"
],
"summary": "Creates an embedding vector representing the input text.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateEmbeddingRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateEmbeddingResponse"
}
}
}
}
},
"x-oaiMeta": {
"name": "Create embeddings",
"returns": "A list of [embedding](/docs/api-reference/embeddings/object) objects.",
"examples": {
"request": {
"curl": "curl https://api.openai.com/v1/embeddings \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"input\": \"The food was delicious and the waiter...\",\n \"model\": \"text-embedding-ada-002\",\n \"encoding_format\": \"float\"\n }'\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.embeddings.create(\n model=\"text-embedding-ada-002\",\n input=\"The food was delicious and the waiter...\",\n encoding_format=\"float\"\n)\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const embedding = await openai.embeddings.create({\n model: \"text-embedding-ada-002\",\n input: \"The quick brown fox jumped over the lazy dog\",\n encoding_format: \"float\",\n });\n\n console.log(embedding);\n}\n\nmain();"
},
"response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"embedding\",\n \"embedding\": [\n 0.0023064255,\n -0.009327292,\n .... (1536 floats total for ada-002)\n -0.0028842222,\n ],\n \"index\": 0\n }\n ],\n \"model\": \"text-embedding-ada-002\",\n \"usage\": {\n \"prompt_tokens\": 8,\n \"total_tokens\": 8\n }\n}\n"
}
}
}
},
"/audio/speech": {
"post": {
"operationId": "createSpeech",
"tags": [
"Audio"
],
"summary": "Generates audio from the input text.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateSpeechRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"headers": {
"Transfer-Encoding": {
"schema": {
"type": "string"
},
"description": "chunked"
}
},
"content": {
"application/octet-stream": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
}
},
"x-oaiMeta": {
"name": "Create speech",
"returns": "The audio file content.",
"examples": {
"request": {
"curl": "curl https://api.openai.com/v1/audio/speech \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"model\": \"tts-1\",\n \"input\": \"The quick brown fox jumped over the lazy dog.\",\n \"voice\": \"alloy\"\n }' \\\n --output speech.mp3\n",
"python": "from pathlib import Path\nimport openai\n\nspeech_file_path = Path(__file__).parent / \"speech.mp3\"\nresponse = openai.audio.speech.create(\n model=\"tts-1\",\n voice=\"alloy\",\n input=\"The quick brown fox jumped over the lazy dog.\"\n)\nresponse.stream_to_file(speech_file_path)\n",
"node": "import fs from \"fs\";\nimport path from \"path\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst speechFile = path.resolve(\"./speech.mp3\");\n\nasync function main() {\n const mp3 = await openai.audio.speech.create({\n model: \"tts-1\",\n voice: \"alloy\",\n input: \"Today is a wonderful day to build something people love!\",\n });\n console.log(speechFile);\n const buffer = Buffer.from(await mp3.arrayBuffer());\n await fs.promises.writeFile(speechFile, buffer);\n}\nmain();\n"
}
}
}
}
},
"/audio/transcriptions": {
"post": {
"operationId": "createTranscription",
"tags": [
"Audio"
],
"summary": "Transcribes audio into the input language.",
"requestBody": {
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/CreateTranscriptionRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateTranscriptionResponse"
}
}
}
}
},
"x-oaiMeta": {
"name": "Create transcription",
"returns": "The transcribed text.",
"examples": {
"request": {
"curl": "curl https://api.openai.com/v1/audio/transcriptions \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: multipart/form-data\" \\\n -F file=\"@/path/to/file/audio.mp3\" \\\n -F model=\"whisper-1\"\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\naudio_file = open(\"speech.mp3\", \"rb\")\ntranscript = client.audio.transcriptions.create(\n model=\"whisper-1\", \n file=audio_file\n)\n",
"node": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const transcription = await openai.audio.transcriptions.create({\n file: fs.createReadStream(\"audio.mp3\"),\n model: \"whisper-1\",\n });\n\n console.log(transcription.text);\n}\nmain();\n"
},
"response": "{\n \"text\": \"Imagine the wildest idea that you've ever had, and you're curious about how it might scale to something that's a 100, a 1,000 times bigger. This is a place where you can get to do that.\"\n}\n"
}
}
}
},
"/audio/translations": {
"post": {
"operationId": "createTranslation",
"tags": [
"Audio"
],
"summary": "Translates audio into English.",
"requestBody": {
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/CreateTranslationRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateTranslationResponse"
}
}
}
}
},
"x-oaiMeta": {
"name": "Create translation",
"returns": "The translated text.",
"examples": {
"request": {
"curl": "curl https://api.openai.com/v1/audio/translations \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: multipart/form-data\" \\\n -F file=\"@/path/to/file/german.m4a\" \\\n -F model=\"whisper-1\"\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\naudio_file = open(\"speech.mp3\", \"rb\")\ntranscript = client.audio.translations.create(\n model=\"whisper-1\", \n file=audio_file\n)\n",
"node": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst resp = await openai.createTranslation(\n fs.createReadStream(\"audio.mp3\"),\n \"whisper-1\"\n);\n"
},
"response": "{\n \"text\": \"Hello, my name is Wolfgang and I come from Germany. Where are you heading today?\"\n}\n"
}
}
}
},
"/files": {
"get": {
"operationId": "listFiles",
"tags": [
"Files"
],
"summary": "Returns a list of files that belong to the user's organization.",
"parameters": [
{
"in": "query",
"name": "purpose",
"required": false,
"schema": {
"type": "string"
},
"description": "Only return files with the given purpose."
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ListFilesResponse"
}
}
}
}
},
"x-oaiMeta": {
"name": "List files",
"returns": "A list of [File](/docs/api-reference/files/object) objects.",
"examples": {
"request": {
"curl": "curl https://api.openai.com/v1/files \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.files.list()\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const list = await openai.files.list();\n\n for await (const file of list) {\n console.log(file);\n }\n}\n\nmain();"
},
"response": "{\n \"data\": [\n {\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"bytes\": 175,\n \"created_at\": 1613677385,\n \"filename\": \"salesOverview.pdf\",\n \"purpose\": \"assistants\",\n },\n {\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"bytes\": 140,\n \"created_at\": 1613779121,\n \"filename\": \"puppy.jsonl\",\n \"purpose\": \"fine-tune\",\n }\n ],\n \"object\": \"list\"\n}\n"
}
}
},
"post": {
"operationId": "createFile",
"tags": [
"Files"
],
"summary": "Upload a file that can be used across various endpoints/features. The size of all the files uploaded by one organization can be up to 100 GB.\n\nThe size of individual files for can be a maximum of 512MB. See the [Assistants Tools guide](/docs/assistants/tools) to learn more about the types of files supported. The Fine-tuning API only supports `.jsonl` files.\n\nPlease [contact us](https://help.openai.com/) if you need to increase these storage limits.\n",
"requestBody": {
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/CreateFileRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OpenAIFile"
}
}
}
}
},
"x-oaiMeta": {
"name": "Upload file",
"returns": "The uploaded [File](/docs/api-reference/files/object) object.",
"examples": {
"request": {
"curl": "curl https://api.openai.com/v1/files \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -F purpose=\"fine-tune\" \\\n -F file=\"@mydata.jsonl\"\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.files.create(\n file=open(\"mydata.jsonl\", \"rb\"),\n purpose=\"fine-tune\"\n)\n",
"node.js": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const file = await openai.files.create({\n file: fs.createReadStream(\"mydata.jsonl\"),\n purpose: \"fine-tune\",\n });\n\n console.log(file);\n}\n\nmain();"
},
"response": "{\n \"id\": \"file-BK7bzQj3FfZFXr7DbL6xJwfo\",\n \"object\": \"file\",\n \"bytes\": 120000,\n \"created_at\": 1677610602,\n \"filename\": \"mydata.jsonl\",\n \"purpose\": \"fine-tune\",\n}\n"
}
}
}
},
"/files/{file_id}": {
"delete": {
"operationId": "deleteFile",
"tags": [
"Files"
],
"summary": "Delete a file.",
"parameters": [
{
"in": "path",
"name": "file_id",
"required": true,
"schema": {
"type": "string"
},
"description": "The ID of the file to use for this request."
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DeleteFileResponse"
}
}
}
}
},
"x-oaiMeta": {
"name": "Delete file",
"returns": "Deletion status.",
"examples": {
"request": {
"curl": "curl https://api.openai.com/v1/files/file-abc123 \\\n -X DELETE \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.files.delete(\"file-oaG6vwLtV3v3mWpvxexWDKxq\")\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const file = await openai.files.del(\"file-abc123\");\n\n console.log(file);\n}\n\nmain();"
},
"response": "{\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"deleted\": true\n}\n"
}
}
},
"get": {
"operationId": "retrieveFile",
"tags": [
"Files"
],
"summary": "Returns information about a specific file.",
"parameters": [
{
"in": "path",
"name": "file_id",
"required": true,
"schema": {
"type": "string"
},
"description": "The ID of the file to use for this request."
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OpenAIFile"
}
}
}
}
},
"x-oaiMeta": {
"name": "Retrieve file",
"returns": "The [File](/docs/api-reference/files/object) object matching the specified ID.",
"examples": {
"request": {
"curl": "curl https://api.openai.com/v1/files/file-BK7bzQj3FfZFXr7DbL6xJwfo \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.files.retrieve(\"file-BK7bzQj3FfZFXr7DbL6xJwfo\")\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const file = await openai.files.retrieve(\"file-BK7bzQj3FfZFXr7DbL6xJwfo\");\n\n console.log(file);\n}\n\nmain();"
},
"response": "{\n \"id\": \"file-BK7bzQj3FfZFXr7DbL6xJwfo\",\n \"object\": \"file\",\n \"bytes\": 120000,\n \"created_at\": 1677610602,\n \"filename\": \"mydata.jsonl\",\n \"purpose\": \"fine-tune\",\n}\n"
}
}
}
},
"/files/{file_id}/content": {
"get": {
"operationId": "downloadFile",
"tags": [
"Files"
],
"summary": "Returns the contents of the specified file.",
"parameters": [
{
"in": "path",
"name": "file_id",
"required": true,
"schema": {
"type": "string"
},
"description": "The ID of the file to use for this request."
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "string"
}
}
}
}
},
"x-oaiMeta": {
"name": "Retrieve file content",
"returns": "The file content.",
"examples": {
"request": {
"curl": "curl https://api.openai.com/v1/files/file-BK7bzQj3FfZFXr7DbL6xJwfo/content \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" > file.jsonl\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\ncontent = client.files.retrieve_content(\"file-BK7bzQj3FfZFXr7DbL6xJwfo\")\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const file = await openai.files.retrieveContent(\"file-BK7bzQj3FfZFXr7DbL6xJwfo\");\n\n console.log(file);\n}\n\nmain();\n"
}
}
}
}
},
"/fine_tuning/jobs": {
"post": {
"operationId": "createFineTuningJob",
"tags": [
"Fine-tuning"
],
"summary": "Creates a job that fine-tunes a specified model from a given dataset.\n\nResponse includes details of the enqueued job including job status and the name of the fine-tuned models once complete.\n\n[Learn more about fine-tuning](/docs/guides/fine-tuning)\n",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateFineTuningJobRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/FineTuningJob"
}
}
}
}
},
"x-oaiMeta": {
"name": "Create fine-tuning job",
"returns": "A [fine-tuning.job](/docs/api-reference/fine-tuning/object) object.",
"examples": [
{
"title": "No hyperparameters",
"request": {
"curl": "curl https://api.openai.com/v1/fine_tuning/jobs \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"training_file\": \"file-BK7bzQj3FfZFXr7DbL6xJwfo\",\n \"model\": \"gpt-3.5-turbo\"\n }'\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.fine_tuning.jobs.create(\n training_file=\"file-abc123\", \n model=\"gpt-3.5-turbo\"\n)\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTuning.jobs.create({\n training_file: \"file-abc123\"\n });\n\n console.log(fineTune);\n}\n\nmain();\n"
},
"response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"gpt-3.5-turbo-0613\",\n \"created_at\": 1614807352,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"queued\",\n \"validation_file\": null,\n \"training_file\": \"file-abc123\",\n}\n"
},
{
"title": "Hyperparameters",
"request": {
"curl": "curl https://api.openai.com/v1/fine_tuning/jobs \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"training_file\": \"file-abc123\",\n \"model\": \"gpt-3.5-turbo\",\n \"hyperparameters\": {\n \"n_epochs\": 2\n }\n }'\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.fine_tuning.jobs.create(\n training_file=\"file-abc123\", \n model=\"gpt-3.5-turbo\", \n hyperparameters={\n \"n_epochs\":2\n }\n)\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTuning.jobs.create({\n training_file: \"file-abc123\",\n model: \"gpt-3.5-turbo\",\n hyperparameters: { n_epochs: 2 }\n });\n\n console.log(fineTune);\n}\n\nmain();\n"
},
"response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"gpt-3.5-turbo-0613\",\n \"created_at\": 1614807352,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"queued\",\n \"validation_file\": null,\n \"training_file\": \"file-abc123\",\n \"hyperparameters\": {\"n_epochs\": 2},\n}\n"
},
{
"title": "Validation file",
"request": {
"curl": "curl https://api.openai.com/v1/fine_tuning/jobs \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"training_file\": \"file-abc123\",\n \"validation_file\": \"file-abc123\",\n \"model\": \"gpt-3.5-turbo\"\n }'\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.fine_tuning.jobs.create(\n training_file=\"file-abc123\", \n validation_file=\"file-def456\", \n model=\"gpt-3.5-turbo\"\n)\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTuning.jobs.create({\n training_file: \"file-abc123\",\n validation_file: \"file-abc123\"\n });\n\n console.log(fineTune);\n}\n\nmain();\n"
},
"response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"gpt-3.5-turbo-0613\",\n \"created_at\": 1614807352,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"queued\",\n \"validation_file\": \"file-abc123\",\n \"training_file\": \"file-abc123\",\n}\n"
}
]
}
},
"get": {
"operationId": "listPaginatedFineTuningJobs",
"tags": [
"Fine-tuning"
],
"summary": "List your organization's fine-tuning jobs\n",
"parameters": [
{
"name": "after",
"in": "query",
"description": "Identifier for the last job from the previous pagination request.",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "limit",
"in": "query",
"description": "Number of fine-tuning jobs to retrieve.",
"required": false,
"schema": {
"type": "integer",
"default": 20
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ListPaginatedFineTuningJobsResponse"
}
}
}
}
},
"x-oaiMeta": {
"name": "List fine-tuning jobs",
"returns": "A list of paginated [fine-tuning job](/docs/api-reference/fine-tuning/object) objects.",
"examples": {
"request": {
"curl": "curl https://api.openai.com/v1/fine_tuning/jobs?limit=2 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.fine_tuning.jobs.list()\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const list = await openai.fineTuning.jobs.list();\n\n for await (const fineTune of list) {\n console.log(fineTune);\n }\n}\n\nmain();"
},
"response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"fine_tuning.job.event\",\n \"id\": \"ft-event-TjX0lMfOniCZX64t9PUQT5hn\",\n \"created_at\": 1689813489,\n \"level\": \"warn\",\n \"message\": \"Fine tuning process stopping due to job cancellation\",\n \"data\": null,\n \"type\": \"message\"\n },\n { ... },\n { ... }\n ], \"has_more\": true\n}\n"
}
}
}
},
"/fine_tuning/jobs/{fine_tuning_job_id}": {
"get": {
"operationId": "retrieveFineTuningJob",
"tags": [
"Fine-tuning"
],
"summary": "Get info about a fine-tuning job.\n\n[Learn more about fine-tuning](/docs/guides/fine-tuning)\n",
"parameters": [
{
"in": "path",
"name": "fine_tuning_job_id",
"required": true,
"schema": {
"type": "string",
"example": "ft-AF1WoRqd3aJAHsqc9NY7iL8F"
},
"description": "The ID of the fine-tuning job.\n"
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/FineTuningJob"
}
}
}
}
},
"x-oaiMeta": {
"name": "Retrieve fine-tuning job",
"returns": "The [fine-tuning](/docs/api-reference/fine-tunes/object) object with the given ID.",
"examples": {
"request": {
"curl": "curl https://api.openai.com/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.fine_tuning.jobs.retrieve(\"ftjob-abc123\")\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTuning.jobs.retrieve(\"ftjob-abc123\");\n\n console.log(fineTune);\n}\n\nmain();\n"
},
"response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"davinci-002\",\n \"created_at\": 1692661014,\n \"finished_at\": 1692661190,\n \"fine_tuned_model\": \"ft:davinci-002:my-org:custom_suffix:7q8mpxmy\",\n \"organization_id\": \"org-123\",\n \"result_files\": [\n \"file-abc123\"\n ],\n \"status\": \"succeeded\",\n \"validation_file\": null,\n \"training_file\": \"file-abc123\",\n \"hyperparameters\": {\n \"n_epochs\": 4,\n },\n \"trained_tokens\": 5768\n}\n"
}
}
}
},
"/fine_tuning/jobs/{fine_tuning_job_id}/events": {
"get": {
"operationId": "listFineTuningEvents",
"tags": [
"Fine-tuning"
],
"summary": "Get status updates for a fine-tuning job.\n",
"parameters": [
{
"in": "path",
"name": "fine_tuning_job_id",
"required": true,
"schema": {
"type": "string",
"example": "ft-AF1WoRqd3aJAHsqc9NY7iL8F"
},
"description": "The ID of the fine-tuning job to get events for.\n"
},
{
"name": "after",
"in": "query",
"description": "Identifier for the last event from the previous pagination request.",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "limit",
"in": "query",
"description": "Number of events to retrieve.",
"required": false,
"schema": {
"type": "integer",
"default": 20
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ListFineTuningJobEventsResponse"
}
}
}
}
},
"x-oaiMeta": {
"name": "List fine-tuning events",
"returns": "A list of fine-tuning event objects.",
"examples": {
"request": {
"curl": "curl https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/events \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n",
"python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.fine_tuning.jobs.list_events(\n fine_tuning_job_id=\"ftjob-abc123\", \n limit=2\n)\n",
"node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const list = await openai.fineTuning.list_events(id=\"ftjob-abc123\", limit=2);\n\n for await (const fineTune of list) {\n console.log(fineTune);\n }\n}\n\nmain();"
},
"response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"fine_tuning.job.event\",\n \"id\": \"ft-event-ddTJfwuMVpfLXseO0Am0Gqjm\",\n \"created_at\": 1692407401,\n \"level\": \"info\",\n \"message\": \"Fine tuning job successfully completed\",\n \"data\": null,\n \"type\": \"message\"\n },\n {\n \"object\": \"fine_tuning.job.event\",\n \"id\": \"ft-event-tyiGuB72evQncpH87xe505Sv\",\n \"created_at\": 1692407400,\n \"level\": \"info\",\n \"message\": \"New fine-tuned model created: ft:gpt-3.5-turbo:openai::7p4lURel\",\n \"data\": null,\n \"type\": \"message\"\n }\n ],\n \"has_more\": true\n}\n"
}
}
}
},
"/fine_tuning/jobs/{fine_tuning_job_id}/cancel": {
"post": {
"operationId": "cancelFineTuningJob",
"tags": [