forked from openai/openai-openapi
-
Notifications
You must be signed in to change notification settings - Fork 2
/
openapi.yaml
3650 lines (3517 loc) · 120 KB
/
openapi.yaml
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: APIs for sampling from and fine-tuning language models
version: '1.2.0'
servers:
- url: https://api.openai.com/v1
tags:
- name: OpenAI
description: The OpenAI REST API
paths:
/engines:
get:
operationId: listEngines
deprecated: true
tags:
- OpenAI
summary: Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability.
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ListEnginesResponse'
x-oaiMeta:
name: List engines
group: engines
path: list
examples:
curl: |
curl https://api.openai.com/v1/engines \
-H 'Authorization: Bearer YOUR_API_KEY'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Engine.list()
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.listEngines();
response: |
{
"data": [
{
"id": "engine-id-0",
"object": "engine",
"owner": "organization-owner",
"ready": true
},
{
"id": "engine-id-2",
"object": "engine",
"owner": "organization-owner",
"ready": true
},
{
"id": "engine-id-3",
"object": "engine",
"owner": "openai",
"ready": false
},
],
"object": "list"
}
/engines/{engine_id}:
get:
operationId: retrieveEngine
deprecated: true
tags:
- OpenAI
summary: Retrieves a model instance, providing basic information about it such as the owner and availability.
parameters:
- in: path
name: engine_id
required: true
schema:
type: string
# ideally this will be an actual ID, so this will always work from browser
example:
davinci
description: &engine_id_description >
The ID of the engine to use for this request
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Engine'
x-oaiMeta:
name: Retrieve engine
group: engines
path: retrieve
examples:
curl: |
curl https://api.openai.com/v1/engines/VAR_model_id \
-H 'Authorization: Bearer YOUR_API_KEY'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Engine.retrieve("VAR_model_id")
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.retrieveEngine("VAR_model_id");
response: |
{
"id": "VAR_model_id",
"object": "engine",
"owner": "openai",
"ready": true
}
/completions:
post:
operationId: createCompletion
tags:
- OpenAI
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
group: completions
path: create
examples:
curl: |
curl https://api.openai.com/v1/completions \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
"model": "VAR_model_id",
"prompt": "Say this is a test",
"max_tokens": 7,
"temperature": 0
}'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Completion.create(
model="VAR_model_id",
prompt="Say this is a test",
max_tokens=7,
temperature=0
)
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createCompletion({
model: "VAR_model_id",
prompt: "Say this is a test",
max_tokens: 7,
temperature: 0,
});
parameters: |
{
"model": "VAR_model_id",
"prompt": "Say this is a test",
"max_tokens": 7,
"temperature": 0,
"top_p": 1,
"n": 1,
"stream": false,
"logprobs": null,
"stop": "\n"
}
response: |
{
"id": "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7",
"object": "text_completion",
"created": 1589478378,
"model": "VAR_model_id",
"choices": [
{
"text": "\n\nThis is indeed a test",
"index": 0,
"logprobs": null,
"finish_reason": "length"
}
],
"usage": {
"prompt_tokens": 5,
"completion_tokens": 7,
"total_tokens": 12
}
}
/chat/completions:
post:
operationId: createChatCompletion
tags:
- OpenAI
summary: Creates a completion for the chat message
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
path: create
beta: true
examples:
curl: |
curl https://api.openai.com/v1/chat/completions \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "Hello!"}]
}'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(completion.choices[0].message)
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const completion = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: [{role: "user", content: "Hello world"}],
});
console.log(completion.data.choices[0].message);
parameters: |
{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "Hello!"}]
}
response: |
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "\n\nHello there, how may I assist you today?",
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}
/edits:
post:
operationId: createEdit
tags:
- OpenAI
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
group: edits
path: create
examples:
curl: |
curl https://api.openai.com/v1/edits \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
"model": "VAR_model_id",
"input": "What day of the wek is it?",
"instruction": "Fix the spelling mistakes"
}'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Edit.create(
model="VAR_model_id",
input="What day of the wek is it?",
instruction="Fix the spelling mistakes"
)
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createEdit({
model: "VAR_model_id",
input: "What day of the wek is it?",
instruction: "Fix the spelling mistakes",
});
parameters: |
{
"model": "VAR_model_id",
"input": "What day of the wek is it?",
"instruction": "Fix the spelling mistakes",
}
response: |
{
"object": "edit",
"created": 1589478378,
"choices": [
{
"text": "What day of the week is it?",
"index": 0,
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 32,
"total_tokens": 57
}
}
/images/generations:
post:
operationId: createImage
tags:
- OpenAI
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
group: images
path: create
beta: true
examples:
curl: |
curl https://api.openai.com/v1/images/generations \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
"prompt": "A cute baby sea otter",
"n": 2,
"size": "1024x1024"
}'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Image.create(
prompt="A cute baby sea otter",
n=2,
size="1024x1024"
)
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createImage({
prompt: "A cute baby sea otter",
n: 2,
size: "1024x1024",
});
parameters: |
{
"prompt": "A cute baby sea otter",
"n": 2,
"size": "1024x1024"
}
response: |
{
"created": 1589478378,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}
/images/edits:
post:
operationId: createImageEdit
tags:
- OpenAI
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
group: images
path: create-edit
beta: true
examples:
curl: |
curl https://api.openai.com/v1/images/edits \
-H 'Authorization: Bearer YOUR_API_KEY' \
-F image='@otter.png' \
-F mask='@mask.png' \
-F prompt="A cute baby sea otter wearing a beret" \
-F n=2 \
-F size="1024x1024"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Image.create_edit(
image=open("otter.png", "rb"),
mask=open("mask.png", "rb"),
prompt="A cute baby sea otter wearing a beret",
n=2,
size="1024x1024"
)
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createImageEdit(
fs.createReadStream("otter.png"),
fs.createReadStream("mask.png"),
"A cute baby sea otter wearing a beret",
2,
"1024x1024"
);
response: |
{
"created": 1589478378,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}
/images/variations:
post:
operationId: createImageVariation
tags:
- OpenAI
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
group: images
path: create-variation
beta: true
examples:
curl: |
curl https://api.openai.com/v1/images/variations \
-H 'Authorization: Bearer YOUR_API_KEY' \
-F image='@otter.png' \
-F n=2 \
-F size="1024x1024"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Image.create_variation(
image=open("otter.png", "rb"),
n=2,
size="1024x1024"
)
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createImageVariation(
fs.createReadStream("otter.png"),
2,
"1024x1024"
);
response: |
{
"created": 1589478378,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}
/embeddings:
post:
operationId: createEmbedding
tags:
- OpenAI
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
group: embeddings
path: create
examples:
curl: |
curl https://api.openai.com/v1/embeddings \
-X POST \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"input": "The food was delicious and the waiter...",
"model": "text-embedding-ada-002"}'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Embedding.create(
model="text-embedding-ada-002",
input="The food was delicious and the waiter..."
)
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createEmbedding({
model: "text-embedding-ada-002",
input: "The food was delicious and the waiter...",
});
parameters: |
{
"model": "text-embedding-ada-002",
"input": "The food was delicious and the waiter..."
}
response: |
{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [
0.0023064255,
-0.009327292,
.... (1536 floats total for ada-002)
-0.0028842222,
],
"index": 0
}
],
"model": "text-embedding-ada-002",
"usage": {
"prompt_tokens": 8,
"total_tokens": 8
}
}
/audio/transcriptions:
post:
operationId: createTranscription
tags:
- OpenAI
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
group: audio
path: create
beta: true
examples:
curl: |
curl https://api.openai.com/v1/audio/transcriptions \
-X POST \
-H 'Authorization: Bearer TOKEN' \
-H 'Content-Type: multipart/form-data' \
-F file=@/path/to/file/audio.mp3 \
-F model=whisper-1
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
audio_file = open("audio.mp3", "rb")
transcript = openai.Audio.transcribe("whisper-1", audio_file)
node: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const resp = await openai.createTranscription(
fs.createReadStream("audio.mp3"),
"whisper-1"
);
parameters: |
{
"file": "audio.mp3",
"model": "whisper-1"
}
response: |
{
"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."
}
/audio/translations:
post:
operationId: createTranslation
tags:
- OpenAI
summary: Translates audio into 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
group: audio
path: create
beta: true
examples:
curl: |
curl https://api.openai.com/v1/audio/translations \
-X POST \
-H 'Authorization: Bearer TOKEN' \
-H 'Content-Type: multipart/form-data' \
-F file=@/path/to/file/german.m4a \
-F model=whisper-1
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
audio_file = open("german.m4a", "rb")
transcript = openai.Audio.translate("whisper-1", audio_file)
node: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const resp = await openai.createTranslation(
fs.createReadStream("audio.mp3"),
"whisper-1"
);
parameters: |
{
"file": "german.m4a",
"model": "whisper-1"
}
response: |
{
"text": "Hello, my name is Wolfgang and I come from Germany. Where are you heading today?"
}
/engines/{engine_id}/search:
post:
operationId: createSearch
deprecated: true
tags:
- OpenAI
summary: |
The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 of them.
To go beyond the 200 document limit, documents can be processed offline and then used for efficient retrieval at query time. When `file` is set, the search endpoint searches over all the documents in the given file and returns up to the `max_rerank` number of documents. These documents will be returned along with their search scores.
The similarity score is a positive score that usually ranges from 0 to 300 (but can sometimes go higher), where a score above 200 usually means the document is semantically similar to the query.
parameters:
- in: path
name: engine_id
required: true
schema:
type: string
example: davinci
description: The ID of the engine to use for this request. You can select one of `ada`, `babbage`, `curie`, or `davinci`.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateSearchRequest'
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CreateSearchResponse'
x-oaiMeta:
name: Create search
group: searches
path: create
examples:
curl: |
curl https://api.openai.com/v1/engines/davinci/search \
-H "Content-Type: application/json" \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
"documents": ["White House", "hospital", "school"],
"query": "the president"
}'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Engine("davinci").search(
documents=["White House", "hospital", "school"],
query="the president"
)
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createSearch("davinci", {
documents: ["White House", "hospital", "school"],
query: "the president",
});
parameters: |
{
"documents": [
"White House",
"hospital",
"school"
],
"query": "the president"
}
response: |
{
"data": [
{
"document": 0,
"object": "search_result",
"score": 215.412
},
{
"document": 1,
"object": "search_result",
"score": 40.316
},
{
"document": 2,
"object": "search_result",
"score": 55.226
}
],
"object": "list"
}
/files:
get:
operationId: listFiles
tags:
- OpenAI
summary: Returns a list of files that belong to the user's organization.
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ListFilesResponse'
x-oaiMeta:
name: List files
group: files
path: list
examples:
curl: |
curl https://api.openai.com/v1/files \
-H 'Authorization: Bearer YOUR_API_KEY'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.File.list()
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.listFiles();
response: |
{
"data": [
{
"id": "file-ccdDZrC3iZVNiQVeEA6Z66wf",
"object": "file",
"bytes": 175,
"created_at": 1613677385,
"filename": "train.jsonl",
"purpose": "search"
},
{
"id": "file-XjGxS3KTG0uNmNOK362iJua3",
"object": "file",
"bytes": 140,
"created_at": 1613779121,
"filename": "puppy.jsonl",
"purpose": "search"
}
],
"object": "list"
}
post:
operationId: createFile
tags:
- OpenAI
summary: |
Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.
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
group: files
path: upload
examples:
curl: |
curl https://api.openai.com/v1/files \
-H "Authorization: Bearer YOUR_API_KEY" \
-F purpose="fine-tune" \
-F file='@mydata.jsonl'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.File.create(
file=open("mydata.jsonl", "rb"),
purpose='fine-tune'
)
node.js: |
const fs = require("fs");
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createFile(
fs.createReadStream("mydata.jsonl"),
"fine-tune"
);
response: |
{
"id": "file-XjGxS3KTG0uNmNOK362iJua3",
"object": "file",
"bytes": 140,
"created_at": 1613779121,
"filename": "mydata.jsonl",
"purpose": "fine-tune"
}
/files/{file_id}:
delete:
operationId: deleteFile
tags:
- OpenAI
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: