openai/openai-dotnet

Public

mirrored from https://github.com/openai/openai-dotnetAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/modify-responsesclient-default-model

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

specification/base/external-specs/latest.yaml

14646lines · modecode

1# MSFT: Spec sourced from export-api pipeline
2# commit 0804cb67c18879e9f7766cc56dd6cd4dc0a6bd17
3# Date: Wed Jun 11 16:35:51 2025 +0000
4# [Amendments made in sources for OAS3 compliance]
5
6openapi: 3.0.0
7info:
8 title: OpenAI API
9 description: The OpenAI REST API. Please see
10 https://platform.openai.com/docs/api-reference for more details.
11 version: 2.3.0
12 termsOfService: https://openai.com/policies/terms-of-use
13 contact:
14 name: OpenAI Support
15 url: https://help.openai.com/
16 license:
17 name: MIT
18 url: https://github.com/openai/openai-openapi/blob/master/LICENSE
19servers:
20 - url: https://api.openai.com/v1
21security:
22 - ApiKeyAuth: []
23tags:
24 - name: Assistants
25 description: Build Assistants that can call models and use tools.
26 - name: Audio
27 description: Turn audio into text or text into audio.
28 - name: Chat
29 description: Given a list of messages comprising a conversation, the model will
30 return a response.
31 - name: Completions
32 description: Given a prompt, the model will return one or more predicted
33 completions, and can also return the probabilities of alternative tokens
34 at each position.
35 - name: Embeddings
36 description: Get a vector representation of a given input that can be easily
37 consumed by machine learning models and algorithms.
38 - name: Evals
39 description: Manage and run evals in the OpenAI platform.
40 - name: Fine-tuning
41 description: Manage fine-tuning jobs to tailor a model to your specific training data.
42 - name: Graders
43 description: Manage and run graders in the OpenAI platform.
44 - name: Batch
45 description: Create large batches of API requests to run asynchronously.
46 - name: Files
47 description: Files are used to upload documents that can be used with features
48 like Assistants and Fine-tuning.
49 - name: Uploads
50 description: Use Uploads to upload large files in multiple parts.
51 - name: Images
52 description: Given a prompt and/or an input image, the model will generate a new image.
53 - name: Models
54 description: List and describe the various models available in the API.
55 - name: Moderations
56 description: Given text and/or image inputs, classifies if those inputs are
57 potentially harmful.
58 - name: Audit Logs
59 description: List user actions and configuration changes within this organization.
60paths:
61 /assistants:
62 get:
63 operationId: listAssistants
64 tags:
65 - Assistants
66 summary: Returns a list of assistants.
67 parameters:
68 - name: limit
69 in: query
70 description: >
71 A limit on the number of objects to be returned. Limit can range
72 between 1 and 100, and the default is 20.
73 required: false
74 schema:
75 type: integer
76 default: 20
77 - name: order
78 in: query
79 description: >
80 Sort order by the `created_at` timestamp of the objects. `asc` for
81 ascending order and `desc` for descending order.
82 schema:
83 type: string
84 default: desc
85 enum:
86 - asc
87 - desc
88 - name: after
89 in: query
90 description: >
91 A cursor for use in pagination. `after` is an object ID that defines
92 your place in the list. For instance, if you make a list request and
93 receive 100 objects, ending with obj_foo, your subsequent call can
94 include after=obj_foo in order to fetch the next page of the list.
95 schema:
96 type: string
97 - name: before
98 in: query
99 description: >
100 A cursor for use in pagination. `before` is an object ID that
101 defines your place in the list. For instance, if you make a list
102 request and receive 100 objects, starting with obj_foo, your
103 subsequent call can include before=obj_foo in order to fetch the
104 previous page of the list.
105 schema:
106 type: string
107 responses:
108 "200":
109 description: OK
110 content:
111 application/json:
112 schema:
113 $ref: "#/components/schemas/ListAssistantsResponse"
114 x-oaiMeta:
115 name: List assistants
116 group: assistants
117 beta: true
118 returns: A list of [assistant](/docs/api-reference/assistants/object) objects.
119 examples:
120 request:
121 curl: |
122 curl "https://api.openai.com/v1/assistants?order=desc&limit=20" \
123 -H "Content-Type: application/json" \
124 -H "Authorization: Bearer $OPENAI_API_KEY" \
125 -H "OpenAI-Beta: assistants=v2"
126 python: |
127 from openai import OpenAI
128 client = OpenAI()
129
130 my_assistants = client.beta.assistants.list(
131 order="desc",
132 limit="20",
133 )
134 print(my_assistants.data)
135 node.js: |-
136 import OpenAI from "openai";
137
138 const openai = new OpenAI();
139
140 async function main() {
141 const myAssistants = await openai.beta.assistants.list({
142 order: "desc",
143 limit: "20",
144 });
145
146 console.log(myAssistants.data);
147 }
148
149 main();
150 response: >
151 {
152 "object": "list",
153 "data": [
154 {
155 "id": "asst_abc123",
156 "object": "assistant",
157 "created_at": 1698982736,
158 "name": "Coding Tutor",
159 "description": null,
160 "model": "gpt-4o",
161 "instructions": "You are a helpful assistant designed to make me better at coding!",
162 "tools": [],
163 "tool_resources": {},
164 "metadata": {},
165 "top_p": 1.0,
166 "temperature": 1.0,
167 "response_format": "auto"
168 },
169 {
170 "id": "asst_abc456",
171 "object": "assistant",
172 "created_at": 1698982718,
173 "name": "My Assistant",
174 "description": null,
175 "model": "gpt-4o",
176 "instructions": "You are a helpful assistant designed to make me better at coding!",
177 "tools": [],
178 "tool_resources": {},
179 "metadata": {},
180 "top_p": 1.0,
181 "temperature": 1.0,
182 "response_format": "auto"
183 },
184 {
185 "id": "asst_abc789",
186 "object": "assistant",
187 "created_at": 1698982643,
188 "name": null,
189 "description": null,
190 "model": "gpt-4o",
191 "instructions": null,
192 "tools": [],
193 "tool_resources": {},
194 "metadata": {},
195 "top_p": 1.0,
196 "temperature": 1.0,
197 "response_format": "auto"
198 }
199 ],
200 "first_id": "asst_abc123",
201 "last_id": "asst_abc789",
202 "has_more": false
203 }
204 post:
205 operationId: createAssistant
206 tags:
207 - Assistants
208 summary: Create an assistant with a model and instructions.
209 requestBody:
210 required: true
211 content:
212 application/json:
213 schema:
214 $ref: "#/components/schemas/CreateAssistantRequest"
215 responses:
216 "200":
217 description: OK
218 content:
219 application/json:
220 schema:
221 $ref: "#/components/schemas/AssistantObject"
222 x-oaiMeta:
223 name: Create assistant
224 group: assistants
225 beta: true
226 returns: An [assistant](/docs/api-reference/assistants/object) object.
227 examples:
228 - title: Code Interpreter
229 request:
230 curl: >
231 curl "https://api.openai.com/v1/assistants" \
232 -H "Content-Type: application/json" \
233 -H "Authorization: Bearer $OPENAI_API_KEY" \
234 -H "OpenAI-Beta: assistants=v2" \
235 -d '{
236 "instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
237 "name": "Math Tutor",
238 "tools": [{"type": "code_interpreter"}],
239 "model": "gpt-4o"
240 }'
241 python: >
242 from openai import OpenAI
243
244 client = OpenAI()
245
246
247 my_assistant = client.beta.assistants.create(
248 instructions="You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
249 name="Math Tutor",
250 tools=[{"type": "code_interpreter"}],
251 model="gpt-4o",
252 )
253
254 print(my_assistant)
255 node.js: >-
256 import OpenAI from "openai";
257
258
259 const openai = new OpenAI();
260
261
262 async function main() {
263 const myAssistant = await openai.beta.assistants.create({
264 instructions:
265 "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
266 name: "Math Tutor",
267 tools: [{ type: "code_interpreter" }],
268 model: "gpt-4o",
269 });
270
271 console.log(myAssistant);
272 }
273
274
275 main();
276 response: >
277 {
278 "id": "asst_abc123",
279 "object": "assistant",
280 "created_at": 1698984975,
281 "name": "Math Tutor",
282 "description": null,
283 "model": "gpt-4o",
284 "instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
285 "tools": [
286 {
287 "type": "code_interpreter"
288 }
289 ],
290 "metadata": {},
291 "top_p": 1.0,
292 "temperature": 1.0,
293 "response_format": "auto"
294 }
295 - title: Files
296 request:
297 curl: >
298 curl https://api.openai.com/v1/assistants \
299 -H "Content-Type: application/json" \
300 -H "Authorization: Bearer $OPENAI_API_KEY" \
301 -H "OpenAI-Beta: assistants=v2" \
302 -d '{
303 "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies.",
304 "tools": [{"type": "file_search"}],
305 "tool_resources": {"file_search": {"vector_store_ids": ["vs_123"]}},
306 "model": "gpt-4o"
307 }'
308 python: >
309 from openai import OpenAI
310
311 client = OpenAI()
312
313
314 my_assistant = client.beta.assistants.create(
315 instructions="You are an HR bot, and you have access to files to answer employee questions about company policies.",
316 name="HR Helper",
317 tools=[{"type": "file_search"}],
318 tool_resources={"file_search": {"vector_store_ids": ["vs_123"]}},
319 model="gpt-4o"
320 )
321
322 print(my_assistant)
323 node.js: >-
324 import OpenAI from "openai";
325
326
327 const openai = new OpenAI();
328
329
330 async function main() {
331 const myAssistant = await openai.beta.assistants.create({
332 instructions:
333 "You are an HR bot, and you have access to files to answer employee questions about company policies.",
334 name: "HR Helper",
335 tools: [{ type: "file_search" }],
336 tool_resources: {
337 file_search: {
338 vector_store_ids: ["vs_123"]
339 }
340 },
341 model: "gpt-4o"
342 });
343
344 console.log(myAssistant);
345 }
346
347
348 main();
349 response: >
350 {
351 "id": "asst_abc123",
352 "object": "assistant",
353 "created_at": 1699009403,
354 "name": "HR Helper",
355 "description": null,
356 "model": "gpt-4o",
357 "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies.",
358 "tools": [
359 {
360 "type": "file_search"
361 }
362 ],
363 "tool_resources": {
364 "file_search": {
365 "vector_store_ids": ["vs_123"]
366 }
367 },
368 "metadata": {},
369 "top_p": 1.0,
370 "temperature": 1.0,
371 "response_format": "auto"
372 }
373 /assistants/{assistant_id}:
374 get:
375 operationId: getAssistant
376 tags:
377 - Assistants
378 summary: Retrieves an assistant.
379 parameters:
380 - in: path
381 name: assistant_id
382 required: true
383 schema:
384 type: string
385 description: The ID of the assistant to retrieve.
386 responses:
387 "200":
388 description: OK
389 content:
390 application/json:
391 schema:
392 $ref: "#/components/schemas/AssistantObject"
393 x-oaiMeta:
394 name: Retrieve assistant
395 group: assistants
396 beta: true
397 returns: The [assistant](/docs/api-reference/assistants/object) object matching
398 the specified ID.
399 examples:
400 request:
401 curl: |
402 curl https://api.openai.com/v1/assistants/asst_abc123 \
403 -H "Content-Type: application/json" \
404 -H "Authorization: Bearer $OPENAI_API_KEY" \
405 -H "OpenAI-Beta: assistants=v2"
406 python: |
407 from openai import OpenAI
408 client = OpenAI()
409
410 my_assistant = client.beta.assistants.retrieve("asst_abc123")
411 print(my_assistant)
412 node.js: |-
413 import OpenAI from "openai";
414
415 const openai = new OpenAI();
416
417 async function main() {
418 const myAssistant = await openai.beta.assistants.retrieve(
419 "asst_abc123"
420 );
421
422 console.log(myAssistant);
423 }
424
425 main();
426 response: >
427 {
428 "id": "asst_abc123",
429 "object": "assistant",
430 "created_at": 1699009709,
431 "name": "HR Helper",
432 "description": null,
433 "model": "gpt-4o",
434 "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies.",
435 "tools": [
436 {
437 "type": "file_search"
438 }
439 ],
440 "metadata": {},
441 "top_p": 1.0,
442 "temperature": 1.0,
443 "response_format": "auto"
444 }
445 post:
446 operationId: modifyAssistant
447 tags:
448 - Assistants
449 summary: Modifies an assistant.
450 parameters:
451 - in: path
452 name: assistant_id
453 required: true
454 schema:
455 type: string
456 description: The ID of the assistant to modify.
457 requestBody:
458 required: true
459 content:
460 application/json:
461 schema:
462 $ref: "#/components/schemas/ModifyAssistantRequest"
463 responses:
464 "200":
465 description: OK
466 content:
467 application/json:
468 schema:
469 $ref: "#/components/schemas/AssistantObject"
470 x-oaiMeta:
471 name: Modify assistant
472 group: assistants
473 beta: true
474 returns: The modified [assistant](/docs/api-reference/assistants/object) object.
475 examples:
476 request:
477 curl: >
478 curl https://api.openai.com/v1/assistants/asst_abc123 \
479 -H "Content-Type: application/json" \
480 -H "Authorization: Bearer $OPENAI_API_KEY" \
481 -H "OpenAI-Beta: assistants=v2" \
482 -d '{
483 "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.",
484 "tools": [{"type": "file_search"}],
485 "model": "gpt-4o"
486 }'
487 python: >
488 from openai import OpenAI
489
490 client = OpenAI()
491
492
493 my_updated_assistant = client.beta.assistants.update(
494 "asst_abc123",
495 instructions="You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.",
496 name="HR Helper",
497 tools=[{"type": "file_search"}],
498 model="gpt-4o"
499 )
500
501
502 print(my_updated_assistant)
503 node.js: >-
504 import OpenAI from "openai";
505
506
507 const openai = new OpenAI();
508
509
510 async function main() {
511 const myUpdatedAssistant = await openai.beta.assistants.update(
512 "asst_abc123",
513 {
514 instructions:
515 "You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.",
516 name: "HR Helper",
517 tools: [{ type: "file_search" }],
518 model: "gpt-4o"
519 }
520 );
521
522 console.log(myUpdatedAssistant);
523 }
524
525
526 main();
527 response: >
528 {
529 "id": "asst_123",
530 "object": "assistant",
531 "created_at": 1699009709,
532 "name": "HR Helper",
533 "description": null,
534 "model": "gpt-4o",
535 "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.",
536 "tools": [
537 {
538 "type": "file_search"
539 }
540 ],
541 "tool_resources": {
542 "file_search": {
543 "vector_store_ids": []
544 }
545 },
546 "metadata": {},
547 "top_p": 1.0,
548 "temperature": 1.0,
549 "response_format": "auto"
550 }
551 delete:
552 operationId: deleteAssistant
553 tags:
554 - Assistants
555 summary: Delete an assistant.
556 parameters:
557 - in: path
558 name: assistant_id
559 required: true
560 schema:
561 type: string
562 description: The ID of the assistant to delete.
563 responses:
564 "200":
565 description: OK
566 content:
567 application/json:
568 schema:
569 $ref: "#/components/schemas/DeleteAssistantResponse"
570 x-oaiMeta:
571 name: Delete assistant
572 group: assistants
573 beta: true
574 returns: Deletion status
575 examples:
576 request:
577 curl: |
578 curl https://api.openai.com/v1/assistants/asst_abc123 \
579 -H "Content-Type: application/json" \
580 -H "Authorization: Bearer $OPENAI_API_KEY" \
581 -H "OpenAI-Beta: assistants=v2" \
582 -X DELETE
583 python: |
584 from openai import OpenAI
585 client = OpenAI()
586
587 response = client.beta.assistants.delete("asst_abc123")
588 print(response)
589 node.js: >-
590 import OpenAI from "openai";
591
592
593 const openai = new OpenAI();
594
595
596 async function main() {
597 const response = await openai.beta.assistants.del("asst_abc123");
598
599 console.log(response);
600 }
601
602 main();
603 response: |
604 {
605 "id": "asst_abc123",
606 "object": "assistant.deleted",
607 "deleted": true
608 }
609 /audio/speech:
610 post:
611 operationId: createSpeech
612 tags:
613 - Audio
614 summary: Generates audio from the input text.
615 requestBody:
616 required: true
617 content:
618 application/json:
619 schema:
620 $ref: "#/components/schemas/CreateSpeechRequest"
621 responses:
622 "200":
623 description: OK
624 headers:
625 Transfer-Encoding:
626 schema:
627 type: string
628 description: chunked
629 content:
630 application/octet-stream:
631 schema:
632 type: string
633 format: binary
634 x-oaiMeta:
635 name: Create speech
636 group: audio
637 returns: The audio file content.
638 examples:
639 request:
640 curl: |
641 curl https://api.openai.com/v1/audio/speech \
642 -H "Authorization: Bearer $OPENAI_API_KEY" \
643 -H "Content-Type: application/json" \
644 -d '{
645 "model": "gpt-4o-mini-tts",
646 "input": "The quick brown fox jumped over the lazy dog.",
647 "voice": "alloy"
648 }' \
649 --output speech.mp3
650 python: |
651 from pathlib import Path
652 import openai
653
654 speech_file_path = Path(__file__).parent / "speech.mp3"
655 with openai.audio.speech.with_streaming_response.create(
656 model="gpt-4o-mini-tts",
657 voice="alloy",
658 input="The quick brown fox jumped over the lazy dog."
659 ) as response:
660 response.stream_to_file(speech_file_path)
661 javascript: >
662 import fs from "fs";
663
664 import path from "path";
665
666 import OpenAI from "openai";
667
668
669 const openai = new OpenAI();
670
671
672 const speechFile = path.resolve("./speech.mp3");
673
674
675 async function main() {
676 const mp3 = await openai.audio.speech.create({
677 model: "gpt-4o-mini-tts",
678 voice: "alloy",
679 input: "Today is a wonderful day to build something people love!",
680 });
681 console.log(speechFile);
682 const buffer = Buffer.from(await mp3.arrayBuffer());
683 await fs.promises.writeFile(speechFile, buffer);
684 }
685
686 main();
687 csharp: |
688 using System;
689 using System.IO;
690
691 using OpenAI.Audio;
692
693 AudioClient client = new(
694 model: "gpt-4o-mini-tts",
695 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
696 );
697
698 BinaryData speech = client.GenerateSpeech(
699 text: "The quick brown fox jumped over the lazy dog.",
700 voice: GeneratedSpeechVoice.Alloy
701 );
702
703 using FileStream stream = File.OpenWrite("speech.mp3");
704 speech.ToStream().CopyTo(stream);
705 /audio/transcriptions:
706 post:
707 operationId: createTranscription
708 tags:
709 - Audio
710 summary: Transcribes audio into the input language.
711 requestBody:
712 required: true
713 content:
714 multipart/form-data:
715 schema:
716 $ref: "#/components/schemas/CreateTranscriptionRequest"
717 responses:
718 "200":
719 description: OK
720 content:
721 application/json:
722 schema:
723 oneOf:
724 - $ref: "#/components/schemas/CreateTranscriptionResponseJson"
725 - $ref: "#/components/schemas/CreateTranscriptionResponseVerboseJson"
726 text/event-stream:
727 schema:
728 $ref: "#/components/schemas/CreateTranscriptionResponseStreamEvent"
729 x-oaiMeta:
730 name: Create transcription
731 group: audio
732 returns: The [transcription object](/docs/api-reference/audio/json-object), a
733 [verbose transcription
734 object](/docs/api-reference/audio/verbose-json-object) or a [stream of
735 transcript
736 events](/docs/api-reference/audio/transcript-text-delta-event).
737 examples:
738 - title: Default
739 request:
740 curl: |
741 curl https://api.openai.com/v1/audio/transcriptions \
742 -H "Authorization: Bearer $OPENAI_API_KEY" \
743 -H "Content-Type: multipart/form-data" \
744 -F file="@/path/to/file/audio.mp3" \
745 -F model="gpt-4o-transcribe"
746 python: |
747 from openai import OpenAI
748 client = OpenAI()
749
750 audio_file = open("speech.mp3", "rb")
751 transcript = client.audio.transcriptions.create(
752 model="gpt-4o-transcribe",
753 file=audio_file
754 )
755 javascript: >
756 import fs from "fs";
757
758 import OpenAI from "openai";
759
760
761 const openai = new OpenAI();
762
763
764 async function main() {
765 const transcription = await openai.audio.transcriptions.create({
766 file: fs.createReadStream("audio.mp3"),
767 model: "gpt-4o-transcribe",
768 });
769
770 console.log(transcription.text);
771 }
772
773 main();
774 csharp: >
775 using System;
776
777
778 using OpenAI.Audio;
779
780 string audioFilePath = "audio.mp3";
781
782
783 AudioClient client = new(
784 model: "gpt-4o-transcribe",
785 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
786 );
787
788
789 AudioTranscription transcription =
790 client.TranscribeAudio(audioFilePath);
791
792
793 Console.WriteLine($"{transcription.Text}");
794 response: >
795 {
796 "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."
797 }
798 - title: Streaming
799 request:
800 curl: |
801 curl https://api.openai.com/v1/audio/transcriptions \
802 -H "Authorization: Bearer $OPENAI_API_KEY" \
803 -H "Content-Type: multipart/form-data" \
804 -F file="@/path/to/file/audio.mp3" \
805 -F model="gpt-4o-mini-transcribe" \
806 -F stream=true
807 python: |
808 from openai import OpenAI
809 client = OpenAI()
810
811 audio_file = open("speech.mp3", "rb")
812 stream = client.audio.transcriptions.create(
813 file=audio_file,
814 model="gpt-4o-mini-transcribe",
815 stream=True
816 )
817
818 for event in stream:
819 print(event)
820 javascript: |
821 import fs from "fs";
822 import OpenAI from "openai";
823
824 const openai = new OpenAI();
825
826 const stream = await openai.audio.transcriptions.create({
827 file: fs.createReadStream("audio.mp3"),
828 model: "gpt-4o-mini-transcribe",
829 stream: true,
830 });
831
832 for await (const event of stream) {
833 console.log(event);
834 }
835 response: |
836 data: {"type":"transcript.text.delta","delta":"I","logprobs":[{"token":"I","logprob":-0.00007588794,"bytes":[73]}]}
837
838 data: {"type":"transcript.text.delta","delta":" see","logprobs":[{"token":" see","logprob":-3.1281633e-7,"bytes":[32,115,101,101]}]}
839
840 data: {"type":"transcript.text.delta","delta":" skies","logprobs":[{"token":" skies","logprob":-2.3392786e-6,"bytes":[32,115,107,105,101,115]}]}
841
842 data: {"type":"transcript.text.delta","delta":" of","logprobs":[{"token":" of","logprob":-3.1281633e-7,"bytes":[32,111,102]}]}
843
844 data: {"type":"transcript.text.delta","delta":" blue","logprobs":[{"token":" blue","logprob":-1.0280384e-6,"bytes":[32,98,108,117,101]}]}
845
846 data: {"type":"transcript.text.delta","delta":" and","logprobs":[{"token":" and","logprob":-0.0005108566,"bytes":[32,97,110,100]}]}
847
848 data: {"type":"transcript.text.delta","delta":" clouds","logprobs":[{"token":" clouds","logprob":-1.9361265e-7,"bytes":[32,99,108,111,117,100,115]}]}
849
850 data: {"type":"transcript.text.delta","delta":" of","logprobs":[{"token":" of","logprob":-1.9361265e-7,"bytes":[32,111,102]}]}
851
852 data: {"type":"transcript.text.delta","delta":" white","logprobs":[{"token":" white","logprob":-7.89631e-7,"bytes":[32,119,104,105,116,101]}]}
853
854 data: {"type":"transcript.text.delta","delta":",","logprobs":[{"token":",","logprob":-0.0014890312,"bytes":[44]}]}
855
856 data: {"type":"transcript.text.delta","delta":" the","logprobs":[{"token":" the","logprob":-0.0110956915,"bytes":[32,116,104,101]}]}
857
858 data: {"type":"transcript.text.delta","delta":" bright","logprobs":[{"token":" bright","logprob":0.0,"bytes":[32,98,114,105,103,104,116]}]}
859
860 data: {"type":"transcript.text.delta","delta":" blessed","logprobs":[{"token":" blessed","logprob":-0.000045848617,"bytes":[32,98,108,101,115,115,101,100]}]}
861
862 data: {"type":"transcript.text.delta","delta":" days","logprobs":[{"token":" days","logprob":-0.000010802739,"bytes":[32,100,97,121,115]}]}
863
864 data: {"type":"transcript.text.delta","delta":",","logprobs":[{"token":",","logprob":-0.00001700133,"bytes":[44]}]}
865
866 data: {"type":"transcript.text.delta","delta":" the","logprobs":[{"token":" the","logprob":-0.0000118755715,"bytes":[32,116,104,101]}]}
867
868 data: {"type":"transcript.text.delta","delta":" dark","logprobs":[{"token":" dark","logprob":-5.5122365e-7,"bytes":[32,100,97,114,107]}]}
869
870 data: {"type":"transcript.text.delta","delta":" sacred","logprobs":[{"token":" sacred","logprob":-5.4385737e-6,"bytes":[32,115,97,99,114,101,100]}]}
871
872 data: {"type":"transcript.text.delta","delta":" nights","logprobs":[{"token":" nights","logprob":-4.00813e-6,"bytes":[32,110,105,103,104,116,115]}]}
873
874 data: {"type":"transcript.text.delta","delta":",","logprobs":[{"token":",","logprob":-0.0036910512,"bytes":[44]}]}
875
876 data: {"type":"transcript.text.delta","delta":" and","logprobs":[{"token":" and","logprob":-0.0031903093,"bytes":[32,97,110,100]}]}
877
878 data: {"type":"transcript.text.delta","delta":" I","logprobs":[{"token":" I","logprob":-1.504853e-6,"bytes":[32,73]}]}
879
880 data: {"type":"transcript.text.delta","delta":" think","logprobs":[{"token":" think","logprob":-4.3202e-7,"bytes":[32,116,104,105,110,107]}]}
881
882 data: {"type":"transcript.text.delta","delta":" to","logprobs":[{"token":" to","logprob":-1.9361265e-7,"bytes":[32,116,111]}]}
883
884 data: {"type":"transcript.text.delta","delta":" myself","logprobs":[{"token":" myself","logprob":-1.7432603e-6,"bytes":[32,109,121,115,101,108,102]}]}
885
886 data: {"type":"transcript.text.delta","delta":",","logprobs":[{"token":",","logprob":-0.29254505,"bytes":[44]}]}
887
888 data: {"type":"transcript.text.delta","delta":" what","logprobs":[{"token":" what","logprob":-0.016815351,"bytes":[32,119,104,97,116]}]}
889
890 data: {"type":"transcript.text.delta","delta":" a","logprobs":[{"token":" a","logprob":-3.1281633e-7,"bytes":[32,97]}]}
891
892 data: {"type":"transcript.text.delta","delta":" wonderful","logprobs":[{"token":" wonderful","logprob":-2.1008714e-6,"bytes":[32,119,111,110,100,101,114,102,117,108]}]}
893
894 data: {"type":"transcript.text.delta","delta":" world","logprobs":[{"token":" world","logprob":-8.180258e-6,"bytes":[32,119,111,114,108,100]}]}
895
896 data: {"type":"transcript.text.delta","delta":".","logprobs":[{"token":".","logprob":-0.014231676,"bytes":[46]}]}
897
898 data: {"type":"transcript.text.done","text":"I see skies of blue and clouds of white, the bright blessed days, the dark sacred nights, and I think to myself, what a wonderful world.","logprobs":[{"token":"I","logprob":-0.00007588794,"bytes":[73]},{"token":" see","logprob":-3.1281633e-7,"bytes":[32,115,101,101]},{"token":" skies","logprob":-2.3392786e-6,"bytes":[32,115,107,105,101,115]},{"token":" of","logprob":-3.1281633e-7,"bytes":[32,111,102]},{"token":" blue","logprob":-1.0280384e-6,"bytes":[32,98,108,117,101]},{"token":" and","logprob":-0.0005108566,"bytes":[32,97,110,100]},{"token":" clouds","logprob":-1.9361265e-7,"bytes":[32,99,108,111,117,100,115]},{"token":" of","logprob":-1.9361265e-7,"bytes":[32,111,102]},{"token":" white","logprob":-7.89631e-7,"bytes":[32,119,104,105,116,101]},{"token":",","logprob":-0.0014890312,"bytes":[44]},{"token":" the","logprob":-0.0110956915,"bytes":[32,116,104,101]},{"token":" bright","logprob":0.0,"bytes":[32,98,114,105,103,104,116]},{"token":" blessed","logprob":-0.000045848617,"bytes":[32,98,108,101,115,115,101,100]},{"token":" days","logprob":-0.000010802739,"bytes":[32,100,97,121,115]},{"token":",","logprob":-0.00001700133,"bytes":[44]},{"token":" the","logprob":-0.0000118755715,"bytes":[32,116,104,101]},{"token":" dark","logprob":-5.5122365e-7,"bytes":[32,100,97,114,107]},{"token":" sacred","logprob":-5.4385737e-6,"bytes":[32,115,97,99,114,101,100]},{"token":" nights","logprob":-4.00813e-6,"bytes":[32,110,105,103,104,116,115]},{"token":",","logprob":-0.0036910512,"bytes":[44]},{"token":" and","logprob":-0.0031903093,"bytes":[32,97,110,100]},{"token":" I","logprob":-1.504853e-6,"bytes":[32,73]},{"token":" think","logprob":-4.3202e-7,"bytes":[32,116,104,105,110,107]},{"token":" to","logprob":-1.9361265e-7,"bytes":[32,116,111]},{"token":" myself","logprob":-1.7432603e-6,"bytes":[32,109,121,115,101,108,102]},{"token":",","logprob":-0.29254505,"bytes":[44]},{"token":" what","logprob":-0.016815351,"bytes":[32,119,104,97,116]},{"token":" a","logprob":-3.1281633e-7,"bytes":[32,97]},{"token":" wonderful","logprob":-2.1008714e-6,"bytes":[32,119,111,110,100,101,114,102,117,108]},{"token":" world","logprob":-8.180258e-6,"bytes":[32,119,111,114,108,100]},{"token":".","logprob":-0.014231676,"bytes":[46]}]}
899 - title: Logprobs
900 request:
901 curl: |
902 curl https://api.openai.com/v1/audio/transcriptions \
903 -H "Authorization: Bearer $OPENAI_API_KEY" \
904 -H "Content-Type: multipart/form-data" \
905 -F file="@/path/to/file/audio.mp3" \
906 -F "include[]=logprobs" \
907 -F model="gpt-4o-transcribe" \
908 -F response_format="json"
909 python: |
910 from openai import OpenAI
911 client = OpenAI()
912
913 audio_file = open("speech.mp3", "rb")
914 transcript = client.audio.transcriptions.create(
915 file=audio_file,
916 model="gpt-4o-transcribe",
917 response_format="json",
918 include=["logprobs"]
919 )
920
921 print(transcript)
922 javascript: >
923 import fs from "fs";
924
925 import OpenAI from "openai";
926
927
928 const openai = new OpenAI();
929
930
931 async function main() {
932 const transcription = await openai.audio.transcriptions.create({
933 file: fs.createReadStream("audio.mp3"),
934 model: "gpt-4o-transcribe",
935 response_format: "json",
936 include: ["logprobs"]
937 });
938
939 console.log(transcription);
940 }
941
942 main();
943 response: >
944 {
945 "text": "Hey, my knee is hurting and I want to see the doctor tomorrow ideally.",
946 "logprobs": [
947 { "token": "Hey", "logprob": -1.0415299, "bytes": [72, 101, 121] },
948 { "token": ",", "logprob": -9.805982e-5, "bytes": [44] },
949 { "token": " my", "logprob": -0.00229799, "bytes": [32, 109, 121] },
950 {
951 "token": " knee",
952 "logprob": -4.7159858e-5,
953 "bytes": [32, 107, 110, 101, 101]
954 },
955 { "token": " is", "logprob": -0.043909557, "bytes": [32, 105, 115] },
956 {
957 "token": " hurting",
958 "logprob": -1.1041146e-5,
959 "bytes": [32, 104, 117, 114, 116, 105, 110, 103]
960 },
961 { "token": " and", "logprob": -0.011076359, "bytes": [32, 97, 110, 100] },
962 { "token": " I", "logprob": -5.3193703e-6, "bytes": [32, 73] },
963 {
964 "token": " want",
965 "logprob": -0.0017156356,
966 "bytes": [32, 119, 97, 110, 116]
967 },
968 { "token": " to", "logprob": -7.89631e-7, "bytes": [32, 116, 111] },
969 { "token": " see", "logprob": -5.5122365e-7, "bytes": [32, 115, 101, 101] },
970 { "token": " the", "logprob": -0.0040786397, "bytes": [32, 116, 104, 101] },
971 {
972 "token": " doctor",
973 "logprob": -2.3392786e-6,
974 "bytes": [32, 100, 111, 99, 116, 111, 114]
975 },
976 {
977 "token": " tomorrow",
978 "logprob": -7.89631e-7,
979 "bytes": [32, 116, 111, 109, 111, 114, 114, 111, 119]
980 },
981 {
982 "token": " ideally",
983 "logprob": -0.5800861,
984 "bytes": [32, 105, 100, 101, 97, 108, 108, 121]
985 },
986 { "token": ".", "logprob": -0.00011093382, "bytes": [46] }
987 ]
988 }
989 - title: Word timestamps
990 request:
991 curl: |
992 curl https://api.openai.com/v1/audio/transcriptions \
993 -H "Authorization: Bearer $OPENAI_API_KEY" \
994 -H "Content-Type: multipart/form-data" \
995 -F file="@/path/to/file/audio.mp3" \
996 -F "timestamp_granularities[]=word" \
997 -F model="whisper-1" \
998 -F response_format="verbose_json"
999 python: |
1000 from openai import OpenAI
1001 client = OpenAI()
1002
1003 audio_file = open("speech.mp3", "rb")
1004 transcript = client.audio.transcriptions.create(
1005 file=audio_file,
1006 model="whisper-1",
1007 response_format="verbose_json",
1008 timestamp_granularities=["word"]
1009 )
1010
1011 print(transcript.words)
1012 javascript: >
1013 import fs from "fs";
1014
1015 import OpenAI from "openai";
1016
1017
1018 const openai = new OpenAI();
1019
1020
1021 async function main() {
1022 const transcription = await openai.audio.transcriptions.create({
1023 file: fs.createReadStream("audio.mp3"),
1024 model: "whisper-1",
1025 response_format: "verbose_json",
1026 timestamp_granularities: ["word"]
1027 });
1028
1029 console.log(transcription.text);
1030 }
1031
1032 main();
1033 csharp: >
1034 using System;
1035
1036
1037 using OpenAI.Audio;
1038
1039
1040 string audioFilePath = "audio.mp3";
1041
1042
1043 AudioClient client = new(
1044 model: "whisper-1",
1045 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
1046 );
1047
1048
1049 AudioTranscriptionOptions options = new()
1050
1051 {
1052 ResponseFormat = AudioTranscriptionFormat.Verbose,
1053 TimestampGranularities = AudioTimestampGranularities.Word,
1054 };
1055
1056
1057 AudioTranscription transcription =
1058 client.TranscribeAudio(audioFilePath, options);
1059
1060
1061 Console.WriteLine($"{transcription.Text}");
1062 response: >
1063 {
1064 "task": "transcribe",
1065 "language": "english",
1066 "duration": 8.470000267028809,
1067 "text": "The beach was a popular spot on a hot summer day. People were swimming in the ocean, building sandcastles, and playing beach volleyball.",
1068 "words": [
1069 {
1070 "word": "The",
1071 "start": 0.0,
1072 "end": 0.23999999463558197
1073 },
1074 ...
1075 {
1076 "word": "volleyball",
1077 "start": 7.400000095367432,
1078 "end": 7.900000095367432
1079 }
1080 ]
1081 }
1082 - title: Segment timestamps
1083 request:
1084 curl: |
1085 curl https://api.openai.com/v1/audio/transcriptions \
1086 -H "Authorization: Bearer $OPENAI_API_KEY" \
1087 -H "Content-Type: multipart/form-data" \
1088 -F file="@/path/to/file/audio.mp3" \
1089 -F "timestamp_granularities[]=segment" \
1090 -F model="whisper-1" \
1091 -F response_format="verbose_json"
1092 python: |
1093 from openai import OpenAI
1094 client = OpenAI()
1095
1096 audio_file = open("speech.mp3", "rb")
1097 transcript = client.audio.transcriptions.create(
1098 file=audio_file,
1099 model="whisper-1",
1100 response_format="verbose_json",
1101 timestamp_granularities=["segment"]
1102 )
1103
1104 print(transcript.words)
1105 javascript: >
1106 import fs from "fs";
1107
1108 import OpenAI from "openai";
1109
1110
1111 const openai = new OpenAI();
1112
1113
1114 async function main() {
1115 const transcription = await openai.audio.transcriptions.create({
1116 file: fs.createReadStream("audio.mp3"),
1117 model: "whisper-1",
1118 response_format: "verbose_json",
1119 timestamp_granularities: ["segment"]
1120 });
1121
1122 console.log(transcription.text);
1123 }
1124
1125 main();
1126 csharp: >
1127 using System;
1128
1129
1130 using OpenAI.Audio;
1131
1132
1133 string audioFilePath = "audio.mp3";
1134
1135
1136 AudioClient client = new(
1137 model: "whisper-1",
1138 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
1139 );
1140
1141
1142 AudioTranscriptionOptions options = new()
1143
1144 {
1145 ResponseFormat = AudioTranscriptionFormat.Verbose,
1146 TimestampGranularities = AudioTimestampGranularities.Segment,
1147 };
1148
1149
1150 AudioTranscription transcription =
1151 client.TranscribeAudio(audioFilePath, options);
1152
1153
1154 Console.WriteLine($"{transcription.Text}");
1155 response: >
1156 {
1157 "task": "transcribe",
1158 "language": "english",
1159 "duration": 8.470000267028809,
1160 "text": "The beach was a popular spot on a hot summer day. People were swimming in the ocean, building sandcastles, and playing beach volleyball.",
1161 "segments": [
1162 {
1163 "id": 0,
1164 "seek": 0,
1165 "start": 0.0,
1166 "end": 3.319999933242798,
1167 "text": " The beach was a popular spot on a hot summer day.",
1168 "tokens": [
1169 50364, 440, 7534, 390, 257, 3743, 4008, 322, 257, 2368, 4266, 786, 13, 50530
1170 ],
1171 "temperature": 0.0,
1172 "avg_logprob": -0.2860786020755768,
1173 "compression_ratio": 1.2363636493682861,
1174 "no_speech_prob": 0.00985979475080967
1175 },
1176 ...
1177 ]
1178 }
1179 /audio/translations:
1180 post:
1181 operationId: createTranslation
1182 tags:
1183 - Audio
1184 summary: Translates audio into English.
1185 requestBody:
1186 required: true
1187 content:
1188 multipart/form-data:
1189 schema:
1190 $ref: "#/components/schemas/CreateTranslationRequest"
1191 responses:
1192 "200":
1193 description: OK
1194 content:
1195 application/json:
1196 schema:
1197 oneOf:
1198 - $ref: "#/components/schemas/CreateTranslationResponseJson"
1199 - $ref: "#/components/schemas/CreateTranslationResponseVerboseJson"
1200 x-oaiMeta:
1201 name: Create translation
1202 group: audio
1203 returns: The translated text.
1204 examples:
1205 request:
1206 curl: |
1207 curl https://api.openai.com/v1/audio/translations \
1208 -H "Authorization: Bearer $OPENAI_API_KEY" \
1209 -H "Content-Type: multipart/form-data" \
1210 -F file="@/path/to/file/german.m4a" \
1211 -F model="whisper-1"
1212 python: |
1213 from openai import OpenAI
1214 client = OpenAI()
1215
1216 audio_file = open("speech.mp3", "rb")
1217 transcript = client.audio.translations.create(
1218 model="whisper-1",
1219 file=audio_file
1220 )
1221 javascript: |
1222 import fs from "fs";
1223 import OpenAI from "openai";
1224
1225 const openai = new OpenAI();
1226
1227 async function main() {
1228 const translation = await openai.audio.translations.create({
1229 file: fs.createReadStream("speech.mp3"),
1230 model: "whisper-1",
1231 });
1232
1233 console.log(translation.text);
1234 }
1235 main();
1236 csharp: >
1237 using System;
1238
1239
1240 using OpenAI.Audio;
1241
1242
1243 string audioFilePath = "audio.mp3";
1244
1245
1246 AudioClient client = new(
1247 model: "whisper-1",
1248 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
1249 );
1250
1251
1252 AudioTranscription transcription =
1253 client.TranscribeAudio(audioFilePath);
1254
1255
1256 Console.WriteLine($"{transcription.Text}");
1257 response: >
1258 {
1259 "text": "Hello, my name is Wolfgang and I come from Germany. Where are you heading today?"
1260 }
1261 /batches:
1262 post:
1263 summary: Creates and executes a batch from an uploaded file of requests
1264 operationId: createBatch
1265 tags:
1266 - Batch
1267 requestBody:
1268 required: true
1269 content:
1270 application/json:
1271 schema:
1272 type: object
1273 required:
1274 - input_file_id
1275 - endpoint
1276 - completion_window
1277 properties:
1278 input_file_id:
1279 type: string
1280 description: >
1281 The ID of an uploaded file that contains requests for the
1282 new batch.
1283
1284
1285 See [upload file](/docs/api-reference/files/create) for how
1286 to upload a file.
1287
1288
1289 Your input file must be formatted as a [JSONL
1290 file](/docs/api-reference/batch/request-input), and must be
1291 uploaded with the purpose `batch`. The file can contain up
1292 to 50,000 requests, and can be up to 200 MB in size.
1293 endpoint:
1294 type: string
1295 enum:
1296 - /v1/responses
1297 - /v1/chat/completions
1298 - /v1/embeddings
1299 - /v1/completions
1300 description: The endpoint to be used for all requests in the batch. Currently
1301 `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`,
1302 and `/v1/completions` are supported. Note that
1303 `/v1/embeddings` batches are also restricted to a maximum of
1304 50,000 embedding inputs across all requests in the batch.
1305 completion_window:
1306 type: string
1307 enum:
1308 - 24h
1309 description: The time frame within which the batch should be processed.
1310 Currently only `24h` is supported.
1311 metadata:
1312 $ref: "#/components/schemas/Metadata"
1313 responses:
1314 "200":
1315 description: Batch created successfully.
1316 content:
1317 application/json:
1318 schema:
1319 $ref: "#/components/schemas/Batch"
1320 x-oaiMeta:
1321 name: Create batch
1322 group: batch
1323 returns: The created [Batch](/docs/api-reference/batch/object) object.
1324 examples:
1325 request:
1326 curl: |
1327 curl https://api.openai.com/v1/batches \
1328 -H "Authorization: Bearer $OPENAI_API_KEY" \
1329 -H "Content-Type: application/json" \
1330 -d '{
1331 "input_file_id": "file-abc123",
1332 "endpoint": "/v1/chat/completions",
1333 "completion_window": "24h"
1334 }'
1335 python: |
1336 from openai import OpenAI
1337 client = OpenAI()
1338
1339 client.batches.create(
1340 input_file_id="file-abc123",
1341 endpoint="/v1/chat/completions",
1342 completion_window="24h"
1343 )
1344 node: |
1345 import OpenAI from "openai";
1346
1347 const openai = new OpenAI();
1348
1349 async function main() {
1350 const batch = await openai.batches.create({
1351 input_file_id: "file-abc123",
1352 endpoint: "/v1/chat/completions",
1353 completion_window: "24h"
1354 });
1355
1356 console.log(batch);
1357 }
1358
1359 main();
1360 response: |
1361 {
1362 "id": "batch_abc123",
1363 "object": "batch",
1364 "endpoint": "/v1/chat/completions",
1365 "errors": null,
1366 "input_file_id": "file-abc123",
1367 "completion_window": "24h",
1368 "status": "validating",
1369 "output_file_id": null,
1370 "error_file_id": null,
1371 "created_at": 1711471533,
1372 "in_progress_at": null,
1373 "expires_at": null,
1374 "finalizing_at": null,
1375 "completed_at": null,
1376 "failed_at": null,
1377 "expired_at": null,
1378 "cancelling_at": null,
1379 "cancelled_at": null,
1380 "request_counts": {
1381 "total": 0,
1382 "completed": 0,
1383 "failed": 0
1384 },
1385 "metadata": {
1386 "customer_id": "user_123456789",
1387 "batch_description": "Nightly eval job",
1388 }
1389 }
1390 get:
1391 operationId: listBatches
1392 tags:
1393 - Batch
1394 summary: List your organization's batches.
1395 parameters:
1396 - in: query
1397 name: after
1398 required: false
1399 schema:
1400 type: string
1401 description: >
1402 A cursor for use in pagination. `after` is an object ID that defines
1403 your place in the list. For instance, if you make a list request and
1404 receive 100 objects, ending with obj_foo, your subsequent call can
1405 include after=obj_foo in order to fetch the next page of the list.
1406 - name: limit
1407 in: query
1408 description: >
1409 A limit on the number of objects to be returned. Limit can range
1410 between 1 and 100, and the default is 20.
1411 required: false
1412 schema:
1413 type: integer
1414 default: 20
1415 responses:
1416 "200":
1417 description: Batch listed successfully.
1418 content:
1419 application/json:
1420 schema:
1421 $ref: "#/components/schemas/ListBatchesResponse"
1422 x-oaiMeta:
1423 name: List batch
1424 group: batch
1425 returns: A list of paginated [Batch](/docs/api-reference/batch/object) objects.
1426 examples:
1427 request:
1428 curl: |
1429 curl https://api.openai.com/v1/batches?limit=2 \
1430 -H "Authorization: Bearer $OPENAI_API_KEY" \
1431 -H "Content-Type: application/json"
1432 python: |
1433 from openai import OpenAI
1434 client = OpenAI()
1435
1436 client.batches.list()
1437 node: |
1438 import OpenAI from "openai";
1439
1440 const openai = new OpenAI();
1441
1442 async function main() {
1443 const list = await openai.batches.list();
1444
1445 for await (const batch of list) {
1446 console.log(batch);
1447 }
1448 }
1449
1450 main();
1451 response: |
1452 {
1453 "object": "list",
1454 "data": [
1455 {
1456 "id": "batch_abc123",
1457 "object": "batch",
1458 "endpoint": "/v1/chat/completions",
1459 "errors": null,
1460 "input_file_id": "file-abc123",
1461 "completion_window": "24h",
1462 "status": "completed",
1463 "output_file_id": "file-cvaTdG",
1464 "error_file_id": "file-HOWS94",
1465 "created_at": 1711471533,
1466 "in_progress_at": 1711471538,
1467 "expires_at": 1711557933,
1468 "finalizing_at": 1711493133,
1469 "completed_at": 1711493163,
1470 "failed_at": null,
1471 "expired_at": null,
1472 "cancelling_at": null,
1473 "cancelled_at": null,
1474 "request_counts": {
1475 "total": 100,
1476 "completed": 95,
1477 "failed": 5
1478 },
1479 "metadata": {
1480 "customer_id": "user_123456789",
1481 "batch_description": "Nightly job",
1482 }
1483 },
1484 { ... },
1485 ],
1486 "first_id": "batch_abc123",
1487 "last_id": "batch_abc456",
1488 "has_more": true
1489 }
1490 /batches/{batch_id}:
1491 get:
1492 operationId: retrieveBatch
1493 tags:
1494 - Batch
1495 summary: Retrieves a batch.
1496 parameters:
1497 - in: path
1498 name: batch_id
1499 required: true
1500 schema:
1501 type: string
1502 description: The ID of the batch to retrieve.
1503 responses:
1504 "200":
1505 description: Batch retrieved successfully.
1506 content:
1507 application/json:
1508 schema:
1509 $ref: "#/components/schemas/Batch"
1510 x-oaiMeta:
1511 name: Retrieve batch
1512 group: batch
1513 returns: The [Batch](/docs/api-reference/batch/object) object matching the
1514 specified ID.
1515 examples:
1516 request:
1517 curl: |
1518 curl https://api.openai.com/v1/batches/batch_abc123 \
1519 -H "Authorization: Bearer $OPENAI_API_KEY" \
1520 -H "Content-Type: application/json" \
1521 python: |
1522 from openai import OpenAI
1523 client = OpenAI()
1524
1525 client.batches.retrieve("batch_abc123")
1526 node: |
1527 import OpenAI from "openai";
1528
1529 const openai = new OpenAI();
1530
1531 async function main() {
1532 const batch = await openai.batches.retrieve("batch_abc123");
1533
1534 console.log(batch);
1535 }
1536
1537 main();
1538 response: |
1539 {
1540 "id": "batch_abc123",
1541 "object": "batch",
1542 "endpoint": "/v1/completions",
1543 "errors": null,
1544 "input_file_id": "file-abc123",
1545 "completion_window": "24h",
1546 "status": "completed",
1547 "output_file_id": "file-cvaTdG",
1548 "error_file_id": "file-HOWS94",
1549 "created_at": 1711471533,
1550 "in_progress_at": 1711471538,
1551 "expires_at": 1711557933,
1552 "finalizing_at": 1711493133,
1553 "completed_at": 1711493163,
1554 "failed_at": null,
1555 "expired_at": null,
1556 "cancelling_at": null,
1557 "cancelled_at": null,
1558 "request_counts": {
1559 "total": 100,
1560 "completed": 95,
1561 "failed": 5
1562 },
1563 "metadata": {
1564 "customer_id": "user_123456789",
1565 "batch_description": "Nightly eval job",
1566 }
1567 }
1568 /batches/{batch_id}/cancel:
1569 post:
1570 operationId: cancelBatch
1571 tags:
1572 - Batch
1573 summary: Cancels an in-progress batch. The batch will be in status `cancelling`
1574 for up to 10 minutes, before changing to `cancelled`, where it will have
1575 partial results (if any) available in the output file.
1576 parameters:
1577 - in: path
1578 name: batch_id
1579 required: true
1580 schema:
1581 type: string
1582 description: The ID of the batch to cancel.
1583 responses:
1584 "200":
1585 description: Batch is cancelling. Returns the cancelling batch's details.
1586 content:
1587 application/json:
1588 schema:
1589 $ref: "#/components/schemas/Batch"
1590 x-oaiMeta:
1591 name: Cancel batch
1592 group: batch
1593 returns: The [Batch](/docs/api-reference/batch/object) object matching the
1594 specified ID.
1595 examples:
1596 request:
1597 curl: |
1598 curl https://api.openai.com/v1/batches/batch_abc123/cancel \
1599 -H "Authorization: Bearer $OPENAI_API_KEY" \
1600 -H "Content-Type: application/json" \
1601 -X POST
1602 python: |
1603 from openai import OpenAI
1604 client = OpenAI()
1605
1606 client.batches.cancel("batch_abc123")
1607 node: |
1608 import OpenAI from "openai";
1609
1610 const openai = new OpenAI();
1611
1612 async function main() {
1613 const batch = await openai.batches.cancel("batch_abc123");
1614
1615 console.log(batch);
1616 }
1617
1618 main();
1619 response: |
1620 {
1621 "id": "batch_abc123",
1622 "object": "batch",
1623 "endpoint": "/v1/chat/completions",
1624 "errors": null,
1625 "input_file_id": "file-abc123",
1626 "completion_window": "24h",
1627 "status": "cancelling",
1628 "output_file_id": null,
1629 "error_file_id": null,
1630 "created_at": 1711471533,
1631 "in_progress_at": 1711471538,
1632 "expires_at": 1711557933,
1633 "finalizing_at": null,
1634 "completed_at": null,
1635 "failed_at": null,
1636 "expired_at": null,
1637 "cancelling_at": 1711475133,
1638 "cancelled_at": null,
1639 "request_counts": {
1640 "total": 100,
1641 "completed": 23,
1642 "failed": 1
1643 },
1644 "metadata": {
1645 "customer_id": "user_123456789",
1646 "batch_description": "Nightly eval job",
1647 }
1648 }
1649 /chat/completions:
1650 get:
1651 operationId: listChatCompletions
1652 tags:
1653 - Chat
1654 summary: >
1655 List stored Chat Completions. Only Chat Completions that have been
1656 stored
1657
1658 with the `store` parameter set to `true` will be returned.
1659 parameters:
1660 - name: model
1661 in: query
1662 description: The model used to generate the Chat Completions.
1663 required: false
1664 schema:
1665 type: string
1666 - name: metadata
1667 in: query
1668 description: |
1669 A list of metadata keys to filter the Chat Completions by. Example:
1670
1671 `metadata[key1]=value1&metadata[key2]=value2`
1672 required: false
1673 schema:
1674 $ref: "#/components/schemas/Metadata"
1675 - name: after
1676 in: query
1677 description: Identifier for the last chat completion from the previous
1678 pagination request.
1679 required: false
1680 schema:
1681 type: string
1682 - name: limit
1683 in: query
1684 description: Number of Chat Completions to retrieve.
1685 required: false
1686 schema:
1687 type: integer
1688 default: 20
1689 - name: order
1690 in: query
1691 description: Sort order for Chat Completions by timestamp. Use `asc` for
1692 ascending order or `desc` for descending order. Defaults to `asc`.
1693 required: false
1694 schema:
1695 type: string
1696 enum:
1697 - asc
1698 - desc
1699 default: asc
1700 responses:
1701 "200":
1702 description: A list of Chat Completions
1703 content:
1704 application/json:
1705 schema:
1706 $ref: "#/components/schemas/ChatCompletionList"
1707 x-oaiMeta:
1708 name: List Chat Completions
1709 group: chat
1710 returns: A list of [Chat Completions](/docs/api-reference/chat/list-object)
1711 matching the specified filters.
1712 path: list
1713 examples:
1714 request:
1715 curl: |
1716 curl https://api.openai.com/v1/chat/completions \
1717 -H "Authorization: Bearer $OPENAI_API_KEY" \
1718 -H "Content-Type: application/json"
1719 python: |
1720 from openai import OpenAI
1721 client = OpenAI()
1722
1723 completions = client.chat.completions.list()
1724 print(completions)
1725 response: >
1726 {
1727 "object": "list",
1728 "data": [
1729 {
1730 "object": "chat.completion",
1731 "id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2",
1732 "model": "gpt-4.1-2025-04-14",
1733 "created": 1738960610,
1734 "request_id": "req_ded8ab984ec4bf840f37566c1011c417",
1735 "tool_choice": null,
1736 "usage": {
1737 "total_tokens": 31,
1738 "completion_tokens": 18,
1739 "prompt_tokens": 13
1740 },
1741 "seed": 4944116822809979520,
1742 "top_p": 1.0,
1743 "temperature": 1.0,
1744 "presence_penalty": 0.0,
1745 "frequency_penalty": 0.0,
1746 "system_fingerprint": "fp_50cad350e4",
1747 "input_user": null,
1748 "service_tier": "default",
1749 "tools": null,
1750 "metadata": {},
1751 "choices": [
1752 {
1753 "index": 0,
1754 "message": {
1755 "content": "Mind of circuits hum, \nLearning patterns in silence— \nFuture's quiet spark.",
1756 "role": "assistant",
1757 "tool_calls": null,
1758 "function_call": null
1759 },
1760 "finish_reason": "stop",
1761 "logprobs": null
1762 }
1763 ],
1764 "response_format": null
1765 }
1766 ],
1767 "first_id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2",
1768 "last_id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2",
1769 "has_more": false
1770 }
1771 post:
1772 operationId: createChatCompletion
1773 tags:
1774 - Chat
1775 summary: |
1776 **Starting a new project?** We recommend trying [Responses](/docs/api-reference/responses)
1777 to take advantage of the latest OpenAI platform features. Compare
1778 [Chat Completions with Responses](/docs/guides/responses-vs-chat-completions?api-mode=responses).
1779
1780 ---
1781
1782 Creates a model response for the given chat conversation. Learn more in the
1783 [text generation](/docs/guides/text-generation), [vision](/docs/guides/vision),
1784 and [audio](/docs/guides/audio) guides.
1785
1786 Parameter support can differ depending on the model used to generate the
1787 response, particularly for newer reasoning models. Parameters that are only
1788 supported for reasoning models are noted below. For the current state of
1789 unsupported parameters in reasoning models,
1790 [refer to the reasoning guide](/docs/guides/reasoning).
1791 requestBody:
1792 required: true
1793 content:
1794 application/json:
1795 schema:
1796 $ref: "#/components/schemas/CreateChatCompletionRequest"
1797 responses:
1798 "200":
1799 description: OK
1800 content:
1801 application/json:
1802 schema:
1803 $ref: "#/components/schemas/CreateChatCompletionResponse"
1804 text/event-stream:
1805 schema:
1806 $ref: "#/components/schemas/CreateChatCompletionStreamResponse"
1807 x-oaiMeta:
1808 name: Create chat completion
1809 group: chat
1810 returns: >
1811 Returns a [chat completion](/docs/api-reference/chat/object) object,
1812 or a streamed sequence of [chat completion
1813 chunk](/docs/api-reference/chat/streaming) objects if the request is
1814 streamed.
1815 path: create
1816 examples:
1817 - title: Default
1818 request:
1819 curl: |
1820 curl https://api.openai.com/v1/chat/completions \
1821 -H "Content-Type: application/json" \
1822 -H "Authorization: Bearer $OPENAI_API_KEY" \
1823 -d '{
1824 "model": "VAR_chat_model_id",
1825 "messages": [
1826 {
1827 "role": "developer",
1828 "content": "You are a helpful assistant."
1829 },
1830 {
1831 "role": "user",
1832 "content": "Hello!"
1833 }
1834 ]
1835 }'
1836 python: >
1837 from openai import OpenAI
1838
1839 client = OpenAI()
1840
1841
1842 completion = client.chat.completions.create(
1843 model="VAR_chat_model_id",
1844 messages=[
1845 {"role": "developer", "content": "You are a helpful assistant."},
1846 {"role": "user", "content": "Hello!"}
1847 ]
1848 )
1849
1850
1851 print(completion.choices[0].message)
1852 node.js: >
1853 import OpenAI from "openai";
1854
1855
1856 const openai = new OpenAI();
1857
1858
1859 async function main() {
1860 const completion = await openai.chat.completions.create({
1861 messages: [{ role: "developer", content: "You are a helpful assistant." }],
1862 model: "VAR_chat_model_id",
1863 store: true,
1864 });
1865
1866 console.log(completion.choices[0]);
1867 }
1868
1869
1870 main();
1871 csharp: |
1872 using System;
1873 using System.Collections.Generic;
1874
1875 using OpenAI.Chat;
1876
1877 ChatClient client = new(
1878 model: "gpt-4.1",
1879 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
1880 );
1881
1882 List<ChatMessage> messages =
1883 [
1884 new SystemChatMessage("You are a helpful assistant."),
1885 new UserChatMessage("Hello!")
1886 ];
1887
1888 ChatCompletion completion = client.CompleteChat(messages);
1889
1890 Console.WriteLine(completion.Content[0].Text);
1891 response: |
1892 {
1893 "id": "chatcmpl-B9MBs8CjcvOU2jLn4n570S5qMJKcT",
1894 "object": "chat.completion",
1895 "created": 1741569952,
1896 "model": "gpt-4.1-2025-04-14",
1897 "choices": [
1898 {
1899 "index": 0,
1900 "message": {
1901 "role": "assistant",
1902 "content": "Hello! How can I assist you today?",
1903 "refusal": null,
1904 "annotations": []
1905 },
1906 "logprobs": null,
1907 "finish_reason": "stop"
1908 }
1909 ],
1910 "usage": {
1911 "prompt_tokens": 19,
1912 "completion_tokens": 10,
1913 "total_tokens": 29,
1914 "prompt_tokens_details": {
1915 "cached_tokens": 0,
1916 "audio_tokens": 0
1917 },
1918 "completion_tokens_details": {
1919 "reasoning_tokens": 0,
1920 "audio_tokens": 0,
1921 "accepted_prediction_tokens": 0,
1922 "rejected_prediction_tokens": 0
1923 }
1924 },
1925 "service_tier": "default"
1926 }
1927 - title: Image input
1928 request:
1929 curl: >
1930 curl https://api.openai.com/v1/chat/completions \
1931 -H "Content-Type: application/json" \
1932 -H "Authorization: Bearer $OPENAI_API_KEY" \
1933 -d '{
1934 "model": "gpt-4.1",
1935 "messages": [
1936 {
1937 "role": "user",
1938 "content": [
1939 {
1940 "type": "text",
1941 "text": "What is in this image?"
1942 },
1943 {
1944 "type": "image_url",
1945 "image_url": {
1946 "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"
1947 }
1948 }
1949 ]
1950 }
1951 ],
1952 "max_tokens": 300
1953 }'
1954 python: >
1955 from openai import OpenAI
1956
1957
1958 client = OpenAI()
1959
1960
1961 response = client.chat.completions.create(
1962 model="gpt-4.1",
1963 messages=[
1964 {
1965 "role": "user",
1966 "content": [
1967 {"type": "text", "text": "What's in this image?"},
1968 {
1969 "type": "image_url",
1970 "image_url": {
1971 "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",
1972 }
1973 },
1974 ],
1975 }
1976 ],
1977 max_tokens=300,
1978 )
1979
1980
1981 print(response.choices[0])
1982 node.js: >
1983 import OpenAI from "openai";
1984
1985
1986 const openai = new OpenAI();
1987
1988
1989 async function main() {
1990 const response = await openai.chat.completions.create({
1991 model: "gpt-4.1",
1992 messages: [
1993 {
1994 role: "user",
1995 content: [
1996 { type: "text", text: "What's in this image?" },
1997 {
1998 type: "image_url",
1999 image_url: {
2000 "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",
2001 },
2002 }
2003 ],
2004 },
2005 ],
2006 });
2007 console.log(response.choices[0]);
2008 }
2009
2010 main();
2011 csharp: >
2012 using System;
2013
2014 using System.Collections.Generic;
2015
2016
2017 using OpenAI.Chat;
2018
2019
2020 ChatClient client = new(
2021 model: "gpt-4.1",
2022 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
2023 );
2024
2025
2026 List<ChatMessage> messages =
2027
2028 [
2029 new UserChatMessage(
2030 [
2031 ChatMessageContentPart.CreateTextPart("What's in this image?"),
2032 ChatMessageContentPart.CreateImagePart(new Uri("https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"))
2033 ])
2034 ];
2035
2036
2037 ChatCompletion completion = client.CompleteChat(messages);
2038
2039
2040 Console.WriteLine(completion.Content[0].Text);
2041 response: >
2042 {
2043 "id": "chatcmpl-B9MHDbslfkBeAs8l4bebGdFOJ6PeG",
2044 "object": "chat.completion",
2045 "created": 1741570283,
2046 "model": "gpt-4.1-2025-04-14",
2047 "choices": [
2048 {
2049 "index": 0,
2050 "message": {
2051 "role": "assistant",
2052 "content": "The image shows a wooden boardwalk path running through a lush green field or meadow. The sky is bright blue with some scattered clouds, giving the scene a serene and peaceful atmosphere. Trees and shrubs are visible in the background.",
2053 "refusal": null,
2054 "annotations": []
2055 },
2056 "logprobs": null,
2057 "finish_reason": "stop"
2058 }
2059 ],
2060 "usage": {
2061 "prompt_tokens": 1117,
2062 "completion_tokens": 46,
2063 "total_tokens": 1163,
2064 "prompt_tokens_details": {
2065 "cached_tokens": 0,
2066 "audio_tokens": 0
2067 },
2068 "completion_tokens_details": {
2069 "reasoning_tokens": 0,
2070 "audio_tokens": 0,
2071 "accepted_prediction_tokens": 0,
2072 "rejected_prediction_tokens": 0
2073 }
2074 },
2075 "service_tier": "default"
2076 }
2077 - title: Streaming
2078 request:
2079 curl: |
2080 curl https://api.openai.com/v1/chat/completions \
2081 -H "Content-Type: application/json" \
2082 -H "Authorization: Bearer $OPENAI_API_KEY" \
2083 -d '{
2084 "model": "VAR_chat_model_id",
2085 "messages": [
2086 {
2087 "role": "developer",
2088 "content": "You are a helpful assistant."
2089 },
2090 {
2091 "role": "user",
2092 "content": "Hello!"
2093 }
2094 ],
2095 "stream": true
2096 }'
2097 python: >
2098 from openai import OpenAI
2099
2100 client = OpenAI()
2101
2102
2103 completion = client.chat.completions.create(
2104 model="VAR_chat_model_id",
2105 messages=[
2106 {"role": "developer", "content": "You are a helpful assistant."},
2107 {"role": "user", "content": "Hello!"}
2108 ],
2109 stream=True
2110 )
2111
2112
2113 for chunk in completion:
2114 print(chunk.choices[0].delta)
2115 node.js: >
2116 import OpenAI from "openai";
2117
2118
2119 const openai = new OpenAI();
2120
2121
2122 async function main() {
2123 const completion = await openai.chat.completions.create({
2124 model: "VAR_chat_model_id",
2125 messages: [
2126 {"role": "developer", "content": "You are a helpful assistant."},
2127 {"role": "user", "content": "Hello!"}
2128 ],
2129 stream: true,
2130 });
2131
2132 for await (const chunk of completion) {
2133 console.log(chunk.choices[0].delta.content);
2134 }
2135 }
2136
2137
2138 main();
2139 csharp: >
2140 using System;
2141
2142 using System.ClientModel;
2143
2144 using System.Collections.Generic;
2145
2146 using System.Threading.Tasks;
2147
2148
2149 using OpenAI.Chat;
2150
2151
2152 ChatClient client = new(
2153 model: "gpt-4.1",
2154 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
2155 );
2156
2157
2158 List<ChatMessage> messages =
2159
2160 [
2161 new SystemChatMessage("You are a helpful assistant."),
2162 new UserChatMessage("Hello!")
2163 ];
2164
2165
2166 AsyncCollectionResult<StreamingChatCompletionUpdate>
2167 completionUpdates = client.CompleteChatStreamingAsync(messages);
2168
2169
2170 await foreach (StreamingChatCompletionUpdate completionUpdate in
2171 completionUpdates)
2172
2173 {
2174 if (completionUpdate.ContentUpdate.Count > 0)
2175 {
2176 Console.Write(completionUpdate.ContentUpdate[0].Text);
2177 }
2178 }
2179 response: |
2180 {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}]}
2181
2182 {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}]}
2183
2184 ....
2185
2186 {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]}
2187 - title: Functions
2188 request:
2189 curl: >
2190 curl https://api.openai.com/v1/chat/completions \
2191
2192 -H "Content-Type: application/json" \
2193
2194 -H "Authorization: Bearer $OPENAI_API_KEY" \
2195
2196 -d '{
2197 "model": "gpt-4.1",
2198 "messages": [
2199 {
2200 "role": "user",
2201 "content": "What is the weather like in Boston today?"
2202 }
2203 ],
2204 "tools": [
2205 {
2206 "type": "function",
2207 "function": {
2208 "name": "get_current_weather",
2209 "description": "Get the current weather in a given location",
2210 "parameters": {
2211 "type": "object",
2212 "properties": {
2213 "location": {
2214 "type": "string",
2215 "description": "The city and state, e.g. San Francisco, CA"
2216 },
2217 "unit": {
2218 "type": "string",
2219 "enum": ["celsius", "fahrenheit"]
2220 }
2221 },
2222 "required": ["location"]
2223 }
2224 }
2225 }
2226 ],
2227 "tool_choice": "auto"
2228 }'
2229 python: >
2230 from openai import OpenAI
2231
2232 client = OpenAI()
2233
2234
2235 tools = [
2236 {
2237 "type": "function",
2238 "function": {
2239 "name": "get_current_weather",
2240 "description": "Get the current weather in a given location",
2241 "parameters": {
2242 "type": "object",
2243 "properties": {
2244 "location": {
2245 "type": "string",
2246 "description": "The city and state, e.g. San Francisco, CA",
2247 },
2248 "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
2249 },
2250 "required": ["location"],
2251 },
2252 }
2253 }
2254 ]
2255
2256 messages = [{"role": "user", "content": "What's the weather like
2257 in Boston today?"}]
2258
2259 completion = client.chat.completions.create(
2260 model="VAR_chat_model_id",
2261 messages=messages,
2262 tools=tools,
2263 tool_choice="auto"
2264 )
2265
2266
2267 print(completion)
2268 node.js: >
2269 import OpenAI from "openai";
2270
2271
2272 const openai = new OpenAI();
2273
2274
2275 async function main() {
2276 const messages = [{"role": "user", "content": "What's the weather like in Boston today?"}];
2277 const tools = [
2278 {
2279 "type": "function",
2280 "function": {
2281 "name": "get_current_weather",
2282 "description": "Get the current weather in a given location",
2283 "parameters": {
2284 "type": "object",
2285 "properties": {
2286 "location": {
2287 "type": "string",
2288 "description": "The city and state, e.g. San Francisco, CA",
2289 },
2290 "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
2291 },
2292 "required": ["location"],
2293 },
2294 }
2295 }
2296 ];
2297
2298 const response = await openai.chat.completions.create({
2299 model: "gpt-4.1",
2300 messages: messages,
2301 tools: tools,
2302 tool_choice: "auto",
2303 });
2304
2305 console.log(response);
2306 }
2307
2308
2309 main();
2310 csharp: >
2311 using System;
2312
2313 using System.Collections.Generic;
2314
2315
2316 using OpenAI.Chat;
2317
2318
2319 ChatClient client = new(
2320 model: "gpt-4.1",
2321 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
2322 );
2323
2324
2325 ChatTool getCurrentWeatherTool = ChatTool.CreateFunctionTool(
2326 functionName: "get_current_weather",
2327 functionDescription: "Get the current weather in a given location",
2328 functionParameters: BinaryData.FromString("""
2329 {
2330 "type": "object",
2331 "properties": {
2332 "location": {
2333 "type": "string",
2334 "description": "The city and state, e.g. San Francisco, CA"
2335 },
2336 "unit": {
2337 "type": "string",
2338 "enum": [ "celsius", "fahrenheit" ]
2339 }
2340 },
2341 "required": [ "location" ]
2342 }
2343 """)
2344 );
2345
2346
2347 List<ChatMessage> messages =
2348
2349 [
2350 new UserChatMessage("What's the weather like in Boston today?"),
2351 ];
2352
2353
2354 ChatCompletionOptions options = new()
2355
2356 {
2357 Tools =
2358 {
2359 getCurrentWeatherTool
2360 },
2361 ToolChoice = ChatToolChoice.CreateAutoChoice(),
2362 };
2363
2364
2365 ChatCompletion completion = client.CompleteChat(messages,
2366 options);
2367 response: |
2368 {
2369 "id": "chatcmpl-abc123",
2370 "object": "chat.completion",
2371 "created": 1699896916,
2372 "model": "gpt-4o-mini",
2373 "choices": [
2374 {
2375 "index": 0,
2376 "message": {
2377 "role": "assistant",
2378 "content": null,
2379 "tool_calls": [
2380 {
2381 "id": "call_abc123",
2382 "type": "function",
2383 "function": {
2384 "name": "get_current_weather",
2385 "arguments": "{\n\"location\": \"Boston, MA\"\n}"
2386 }
2387 }
2388 ]
2389 },
2390 "logprobs": null,
2391 "finish_reason": "tool_calls"
2392 }
2393 ],
2394 "usage": {
2395 "prompt_tokens": 82,
2396 "completion_tokens": 17,
2397 "total_tokens": 99,
2398 "completion_tokens_details": {
2399 "reasoning_tokens": 0,
2400 "accepted_prediction_tokens": 0,
2401 "rejected_prediction_tokens": 0
2402 }
2403 }
2404 }
2405 - title: Logprobs
2406 request:
2407 curl: |
2408 curl https://api.openai.com/v1/chat/completions \
2409 -H "Content-Type: application/json" \
2410 -H "Authorization: Bearer $OPENAI_API_KEY" \
2411 -d '{
2412 "model": "VAR_chat_model_id",
2413 "messages": [
2414 {
2415 "role": "user",
2416 "content": "Hello!"
2417 }
2418 ],
2419 "logprobs": true,
2420 "top_logprobs": 2
2421 }'
2422 python: |
2423 from openai import OpenAI
2424 client = OpenAI()
2425
2426 completion = client.chat.completions.create(
2427 model="VAR_chat_model_id",
2428 messages=[
2429 {"role": "user", "content": "Hello!"}
2430 ],
2431 logprobs=True,
2432 top_logprobs=2
2433 )
2434
2435 print(completion.choices[0].message)
2436 print(completion.choices[0].logprobs)
2437 node.js: |
2438 import OpenAI from "openai";
2439
2440 const openai = new OpenAI();
2441
2442 async function main() {
2443 const completion = await openai.chat.completions.create({
2444 messages: [{ role: "user", content: "Hello!" }],
2445 model: "VAR_chat_model_id",
2446 logprobs: true,
2447 top_logprobs: 2,
2448 });
2449
2450 console.log(completion.choices[0]);
2451 }
2452
2453 main();
2454 csharp: >
2455 using System;
2456
2457 using System.Collections.Generic;
2458
2459
2460 using OpenAI.Chat;
2461
2462
2463 ChatClient client = new(
2464 model: "gpt-4.1",
2465 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
2466 );
2467
2468
2469 List<ChatMessage> messages =
2470
2471 [
2472 new UserChatMessage("Hello!")
2473 ];
2474
2475
2476 ChatCompletionOptions options = new()
2477
2478 {
2479 IncludeLogProbabilities = true,
2480 TopLogProbabilityCount = 2
2481 };
2482
2483
2484 ChatCompletion completion = client.CompleteChat(messages,
2485 options);
2486
2487
2488 Console.WriteLine(completion.Content[0].Text);
2489 response: |
2490 {
2491 "id": "chatcmpl-123",
2492 "object": "chat.completion",
2493 "created": 1702685778,
2494 "model": "gpt-4o-mini",
2495 "choices": [
2496 {
2497 "index": 0,
2498 "message": {
2499 "role": "assistant",
2500 "content": "Hello! How can I assist you today?"
2501 },
2502 "logprobs": {
2503 "content": [
2504 {
2505 "token": "Hello",
2506 "logprob": -0.31725305,
2507 "bytes": [72, 101, 108, 108, 111],
2508 "top_logprobs": [
2509 {
2510 "token": "Hello",
2511 "logprob": -0.31725305,
2512 "bytes": [72, 101, 108, 108, 111]
2513 },
2514 {
2515 "token": "Hi",
2516 "logprob": -1.3190403,
2517 "bytes": [72, 105]
2518 }
2519 ]
2520 },
2521 {
2522 "token": "!",
2523 "logprob": -0.02380986,
2524 "bytes": [
2525 33
2526 ],
2527 "top_logprobs": [
2528 {
2529 "token": "!",
2530 "logprob": -0.02380986,
2531 "bytes": [33]
2532 },
2533 {
2534 "token": " there",
2535 "logprob": -3.787621,
2536 "bytes": [32, 116, 104, 101, 114, 101]
2537 }
2538 ]
2539 },
2540 {
2541 "token": " How",
2542 "logprob": -0.000054669687,
2543 "bytes": [32, 72, 111, 119],
2544 "top_logprobs": [
2545 {
2546 "token": " How",
2547 "logprob": -0.000054669687,
2548 "bytes": [32, 72, 111, 119]
2549 },
2550 {
2551 "token": "<|end|>",
2552 "logprob": -10.953937,
2553 "bytes": null
2554 }
2555 ]
2556 },
2557 {
2558 "token": " can",
2559 "logprob": -0.015801601,
2560 "bytes": [32, 99, 97, 110],
2561 "top_logprobs": [
2562 {
2563 "token": " can",
2564 "logprob": -0.015801601,
2565 "bytes": [32, 99, 97, 110]
2566 },
2567 {
2568 "token": " may",
2569 "logprob": -4.161023,
2570 "bytes": [32, 109, 97, 121]
2571 }
2572 ]
2573 },
2574 {
2575 "token": " I",
2576 "logprob": -3.7697225e-6,
2577 "bytes": [
2578 32,
2579 73
2580 ],
2581 "top_logprobs": [
2582 {
2583 "token": " I",
2584 "logprob": -3.7697225e-6,
2585 "bytes": [32, 73]
2586 },
2587 {
2588 "token": " assist",
2589 "logprob": -13.596657,
2590 "bytes": [32, 97, 115, 115, 105, 115, 116]
2591 }
2592 ]
2593 },
2594 {
2595 "token": " assist",
2596 "logprob": -0.04571125,
2597 "bytes": [32, 97, 115, 115, 105, 115, 116],
2598 "top_logprobs": [
2599 {
2600 "token": " assist",
2601 "logprob": -0.04571125,
2602 "bytes": [32, 97, 115, 115, 105, 115, 116]
2603 },
2604 {
2605 "token": " help",
2606 "logprob": -3.1089056,
2607 "bytes": [32, 104, 101, 108, 112]
2608 }
2609 ]
2610 },
2611 {
2612 "token": " you",
2613 "logprob": -5.4385737e-6,
2614 "bytes": [32, 121, 111, 117],
2615 "top_logprobs": [
2616 {
2617 "token": " you",
2618 "logprob": -5.4385737e-6,
2619 "bytes": [32, 121, 111, 117]
2620 },
2621 {
2622 "token": " today",
2623 "logprob": -12.807695,
2624 "bytes": [32, 116, 111, 100, 97, 121]
2625 }
2626 ]
2627 },
2628 {
2629 "token": " today",
2630 "logprob": -0.0040071653,
2631 "bytes": [32, 116, 111, 100, 97, 121],
2632 "top_logprobs": [
2633 {
2634 "token": " today",
2635 "logprob": -0.0040071653,
2636 "bytes": [32, 116, 111, 100, 97, 121]
2637 },
2638 {
2639 "token": "?",
2640 "logprob": -5.5247097,
2641 "bytes": [63]
2642 }
2643 ]
2644 },
2645 {
2646 "token": "?",
2647 "logprob": -0.0008108172,
2648 "bytes": [63],
2649 "top_logprobs": [
2650 {
2651 "token": "?",
2652 "logprob": -0.0008108172,
2653 "bytes": [63]
2654 },
2655 {
2656 "token": "?\n",
2657 "logprob": -7.184561,
2658 "bytes": [63, 10]
2659 }
2660 ]
2661 }
2662 ]
2663 },
2664 "finish_reason": "stop"
2665 }
2666 ],
2667 "usage": {
2668 "prompt_tokens": 9,
2669 "completion_tokens": 9,
2670 "total_tokens": 18,
2671 "completion_tokens_details": {
2672 "reasoning_tokens": 0,
2673 "accepted_prediction_tokens": 0,
2674 "rejected_prediction_tokens": 0
2675 }
2676 },
2677 "system_fingerprint": null
2678 }
2679 /chat/completions/{completion_id}:
2680 get:
2681 operationId: getChatCompletion
2682 tags:
2683 - Chat
2684 summary: >
2685 Get a stored chat completion. Only Chat Completions that have been
2686 created
2687
2688 with the `store` parameter set to `true` will be returned.
2689 parameters:
2690 - in: path
2691 name: completion_id
2692 required: true
2693 schema:
2694 type: string
2695 description: The ID of the chat completion to retrieve.
2696 responses:
2697 "200":
2698 description: A chat completion
2699 content:
2700 application/json:
2701 schema:
2702 $ref: "#/components/schemas/CreateChatCompletionResponse"
2703 x-oaiMeta:
2704 name: Get chat completion
2705 group: chat
2706 returns: The [ChatCompletion](/docs/api-reference/chat/object) object matching
2707 the specified ID.
2708 examples:
2709 request:
2710 curl: |
2711 curl https://api.openai.com/v1/chat/completions/chatcmpl-abc123 \
2712 -H "Authorization: Bearer $OPENAI_API_KEY" \
2713 -H "Content-Type: application/json"
2714 python: >
2715 from openai import OpenAI
2716
2717 client = OpenAI()
2718
2719
2720 completions = client.chat.completions.list()
2721
2722 first_id = completions[0].id
2723
2724 first_completion =
2725 client.chat.completions.retrieve(completion_id=first_id)
2726
2727 print(first_completion)
2728 response: >
2729 {
2730 "object": "chat.completion",
2731 "id": "chatcmpl-abc123",
2732 "model": "gpt-4o-2024-08-06",
2733 "created": 1738960610,
2734 "request_id": "req_ded8ab984ec4bf840f37566c1011c417",
2735 "tool_choice": null,
2736 "usage": {
2737 "total_tokens": 31,
2738 "completion_tokens": 18,
2739 "prompt_tokens": 13
2740 },
2741 "seed": 4944116822809979520,
2742 "top_p": 1.0,
2743 "temperature": 1.0,
2744 "presence_penalty": 0.0,
2745 "frequency_penalty": 0.0,
2746 "system_fingerprint": "fp_50cad350e4",
2747 "input_user": null,
2748 "service_tier": "default",
2749 "tools": null,
2750 "metadata": {},
2751 "choices": [
2752 {
2753 "index": 0,
2754 "message": {
2755 "content": "Mind of circuits hum, \nLearning patterns in silence— \nFuture's quiet spark.",
2756 "role": "assistant",
2757 "tool_calls": null,
2758 "function_call": null
2759 },
2760 "finish_reason": "stop",
2761 "logprobs": null
2762 }
2763 ],
2764 "response_format": null
2765 }
2766 post:
2767 operationId: updateChatCompletion
2768 tags:
2769 - Chat
2770 summary: >
2771 Modify a stored chat completion. Only Chat Completions that have been
2772
2773 created with the `store` parameter set to `true` can be modified.
2774 Currently,
2775
2776 the only supported modification is to update the `metadata` field.
2777 parameters:
2778 - in: path
2779 name: completion_id
2780 required: true
2781 schema:
2782 type: string
2783 description: The ID of the chat completion to update.
2784 requestBody:
2785 required: true
2786 content:
2787 application/json:
2788 schema:
2789 type: object
2790 required:
2791 - metadata
2792 properties:
2793 metadata:
2794 $ref: "#/components/schemas/Metadata"
2795 responses:
2796 "200":
2797 description: A chat completion
2798 content:
2799 application/json:
2800 schema:
2801 $ref: "#/components/schemas/CreateChatCompletionResponse"
2802 x-oaiMeta:
2803 name: Update chat completion
2804 group: chat
2805 returns: The [ChatCompletion](/docs/api-reference/chat/object) object matching
2806 the specified ID.
2807 examples:
2808 request:
2809 curl: >
2810 curl -X POST
2811 https://api.openai.com/v1/chat/completions/chat_abc123 \
2812 -H "Authorization: Bearer $OPENAI_API_KEY" \
2813 -H "Content-Type: application/json" \
2814 -d '{"metadata": {"foo": "bar"}}'
2815 python: >
2816 from openai import OpenAI
2817
2818 client = OpenAI()
2819
2820
2821 completions = client.chat.completions.list()
2822
2823 first_id = completions[0].id
2824
2825 updated_completion =
2826 client.chat.completions.update(completion_id=first_id,
2827 request_body={"metadata": {"foo": "bar"}})
2828
2829 print(updated_completion)
2830 response: >
2831 {
2832 "object": "chat.completion",
2833 "id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2",
2834 "model": "gpt-4o-2024-08-06",
2835 "created": 1738960610,
2836 "request_id": "req_ded8ab984ec4bf840f37566c1011c417",
2837 "tool_choice": null,
2838 "usage": {
2839 "total_tokens": 31,
2840 "completion_tokens": 18,
2841 "prompt_tokens": 13
2842 },
2843 "seed": 4944116822809979520,
2844 "top_p": 1.0,
2845 "temperature": 1.0,
2846 "presence_penalty": 0.0,
2847 "frequency_penalty": 0.0,
2848 "system_fingerprint": "fp_50cad350e4",
2849 "input_user": null,
2850 "service_tier": "default",
2851 "tools": null,
2852 "metadata": {
2853 "foo": "bar"
2854 },
2855 "choices": [
2856 {
2857 "index": 0,
2858 "message": {
2859 "content": "Mind of circuits hum, \nLearning patterns in silence— \nFuture's quiet spark.",
2860 "role": "assistant",
2861 "tool_calls": null,
2862 "function_call": null
2863 },
2864 "finish_reason": "stop",
2865 "logprobs": null
2866 }
2867 ],
2868 "response_format": null
2869 }
2870 delete:
2871 operationId: deleteChatCompletion
2872 tags:
2873 - Chat
2874 summary: |
2875 Delete a stored chat completion. Only Chat Completions that have been
2876 created with the `store` parameter set to `true` can be deleted.
2877 parameters:
2878 - in: path
2879 name: completion_id
2880 required: true
2881 schema:
2882 type: string
2883 description: The ID of the chat completion to delete.
2884 responses:
2885 "200":
2886 description: The chat completion was deleted successfully.
2887 content:
2888 application/json:
2889 schema:
2890 $ref: "#/components/schemas/ChatCompletionDeleted"
2891 x-oaiMeta:
2892 name: Delete chat completion
2893 group: chat
2894 returns: A deletion confirmation object.
2895 examples:
2896 request:
2897 curl: >
2898 curl -X DELETE
2899 https://api.openai.com/v1/chat/completions/chat_abc123 \
2900 -H "Authorization: Bearer $OPENAI_API_KEY" \
2901 -H "Content-Type: application/json"
2902 python: >
2903 from openai import OpenAI
2904
2905 client = OpenAI()
2906
2907
2908 completions = client.chat.completions.list()
2909
2910 first_id = completions[0].id
2911
2912 delete_response =
2913 client.chat.completions.delete(completion_id=first_id)
2914
2915 print(delete_response)
2916 response: |
2917 {
2918 "object": "chat.completion.deleted",
2919 "id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2",
2920 "deleted": true
2921 }
2922 /chat/completions/{completion_id}/messages:
2923 get:
2924 operationId: getChatCompletionMessages
2925 tags:
2926 - Chat
2927 summary: |
2928 Get the messages in a stored chat completion. Only Chat Completions that
2929 have been created with the `store` parameter set to `true` will be
2930 returned.
2931 parameters:
2932 - in: path
2933 name: completion_id
2934 required: true
2935 schema:
2936 type: string
2937 description: The ID of the chat completion to retrieve messages from.
2938 - name: after
2939 in: query
2940 description: Identifier for the last message from the previous pagination request.
2941 required: false
2942 schema:
2943 type: string
2944 - name: limit
2945 in: query
2946 description: Number of messages to retrieve.
2947 required: false
2948 schema:
2949 type: integer
2950 default: 20
2951 - name: order
2952 in: query
2953 description: Sort order for messages by timestamp. Use `asc` for ascending order
2954 or `desc` for descending order. Defaults to `asc`.
2955 required: false
2956 schema:
2957 type: string
2958 enum:
2959 - asc
2960 - desc
2961 default: asc
2962 responses:
2963 "200":
2964 description: A list of messages
2965 content:
2966 application/json:
2967 schema:
2968 $ref: "#/components/schemas/ChatCompletionMessageList"
2969 x-oaiMeta:
2970 name: Get chat messages
2971 group: chat
2972 returns: A list of [messages](/docs/api-reference/chat/message-list) for the
2973 specified chat completion.
2974 examples:
2975 request:
2976 curl: >
2977 curl
2978 https://api.openai.com/v1/chat/completions/chat_abc123/messages \
2979 -H "Authorization: Bearer $OPENAI_API_KEY" \
2980 -H "Content-Type: application/json"
2981 python: >
2982 from openai import OpenAI
2983
2984 client = OpenAI()
2985
2986
2987 completions = client.chat.completions.list()
2988
2989 first_id = completions[0].id
2990
2991 first_completion =
2992 client.chat.completions.retrieve(completion_id=first_id)
2993
2994 messages =
2995 client.chat.completions.messages.list(completion_id=first_id)
2996
2997 print(messages)
2998 response: |
2999 {
3000 "object": "list",
3001 "data": [
3002 {
3003 "id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0",
3004 "role": "user",
3005 "content": "write a haiku about ai",
3006 "name": null,
3007 "content_parts": null
3008 }
3009 ],
3010 "first_id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0",
3011 "last_id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0",
3012 "has_more": false
3013 }
3014 /completions:
3015 post:
3016 operationId: createCompletion
3017 tags:
3018 - Completions
3019 summary: Creates a completion for the provided prompt and parameters.
3020 requestBody:
3021 required: true
3022 content:
3023 application/json:
3024 schema:
3025 $ref: "#/components/schemas/CreateCompletionRequest"
3026 responses:
3027 "200":
3028 description: OK
3029 content:
3030 application/json:
3031 schema:
3032 $ref: "#/components/schemas/CreateCompletionResponse"
3033 x-oaiMeta:
3034 name: Create completion
3035 group: completions
3036 returns: >
3037 Returns a [completion](/docs/api-reference/completions/object) object,
3038 or a sequence of completion objects if the request is streamed.
3039 legacy: true
3040 examples:
3041 - title: No streaming
3042 request:
3043 curl: |
3044 curl https://api.openai.com/v1/completions \
3045 -H "Content-Type: application/json" \
3046 -H "Authorization: Bearer $OPENAI_API_KEY" \
3047 -d '{
3048 "model": "VAR_completion_model_id",
3049 "prompt": "Say this is a test",
3050 "max_tokens": 7,
3051 "temperature": 0
3052 }'
3053 python: |
3054 from openai import OpenAI
3055 client = OpenAI()
3056
3057 client.completions.create(
3058 model="VAR_completion_model_id",
3059 prompt="Say this is a test",
3060 max_tokens=7,
3061 temperature=0
3062 )
3063 node.js: |-
3064 import OpenAI from "openai";
3065
3066 const openai = new OpenAI();
3067
3068 async function main() {
3069 const completion = await openai.completions.create({
3070 model: "VAR_completion_model_id",
3071 prompt: "Say this is a test.",
3072 max_tokens: 7,
3073 temperature: 0,
3074 });
3075
3076 console.log(completion);
3077 }
3078 main();
3079 response: |
3080 {
3081 "id": "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7",
3082 "object": "text_completion",
3083 "created": 1589478378,
3084 "model": "VAR_completion_model_id",
3085 "system_fingerprint": "fp_44709d6fcb",
3086 "choices": [
3087 {
3088 "text": "\n\nThis is indeed a test",
3089 "index": 0,
3090 "logprobs": null,
3091 "finish_reason": "length"
3092 }
3093 ],
3094 "usage": {
3095 "prompt_tokens": 5,
3096 "completion_tokens": 7,
3097 "total_tokens": 12
3098 }
3099 }
3100 - title: Streaming
3101 request:
3102 curl: |
3103 curl https://api.openai.com/v1/completions \
3104 -H "Content-Type: application/json" \
3105 -H "Authorization: Bearer $OPENAI_API_KEY" \
3106 -d '{
3107 "model": "VAR_completion_model_id",
3108 "prompt": "Say this is a test",
3109 "max_tokens": 7,
3110 "temperature": 0,
3111 "stream": true
3112 }'
3113 python: |
3114 from openai import OpenAI
3115 client = OpenAI()
3116
3117 for chunk in client.completions.create(
3118 model="VAR_completion_model_id",
3119 prompt="Say this is a test",
3120 max_tokens=7,
3121 temperature=0,
3122 stream=True
3123 ):
3124 print(chunk.choices[0].text)
3125 node.js: |-
3126 import OpenAI from "openai";
3127
3128 const openai = new OpenAI();
3129
3130 async function main() {
3131 const stream = await openai.completions.create({
3132 model: "VAR_completion_model_id",
3133 prompt: "Say this is a test.",
3134 stream: true,
3135 });
3136
3137 for await (const chunk of stream) {
3138 console.log(chunk.choices[0].text)
3139 }
3140 }
3141 main();
3142 response: |
3143 {
3144 "id": "cmpl-7iA7iJjj8V2zOkCGvWF2hAkDWBQZe",
3145 "object": "text_completion",
3146 "created": 1690759702,
3147 "choices": [
3148 {
3149 "text": "This",
3150 "index": 0,
3151 "logprobs": null,
3152 "finish_reason": null
3153 }
3154 ],
3155 "model": "gpt-3.5-turbo-instruct"
3156 "system_fingerprint": "fp_44709d6fcb",
3157 }
3158 /containers:
3159 get:
3160 summary: List Containers
3161 description: Lists containers.
3162 operationId: ListContainers
3163 parameters:
3164 - name: limit
3165 in: query
3166 description: >
3167 A limit on the number of objects to be returned. Limit can range
3168 between 1 and 100, and the default is 20.
3169 required: false
3170 schema:
3171 type: integer
3172 default: 20
3173 - name: order
3174 in: query
3175 description: >
3176 Sort order by the `created_at` timestamp of the objects. `asc` for
3177 ascending order and `desc` for descending order.
3178 schema:
3179 type: string
3180 default: desc
3181 enum:
3182 - asc
3183 - desc
3184 - name: after
3185 in: query
3186 description: >
3187 A cursor for use in pagination. `after` is an object ID that defines
3188 your place in the list. For instance, if you make a list request and
3189 receive 100 objects, ending with obj_foo, your subsequent call can
3190 include after=obj_foo in order to fetch the next page of the list.
3191 schema:
3192 type: string
3193 responses:
3194 "200":
3195 description: Success
3196 content:
3197 application/json:
3198 schema:
3199 $ref: "#/components/schemas/ContainerListResource"
3200 x-oaiMeta:
3201 name: List containers
3202 group: containers
3203 returns: a list of [container](/docs/api-reference/containers/object) objects.
3204 path: get
3205 examples:
3206 request:
3207 curl: |
3208 curl https://api.openai.com/v1/containers \
3209 -H "Authorization: Bearer $OPENAI_API_KEY"
3210 response: >
3211 {
3212 "object": "list",
3213 "data": [
3214 {
3215 "id": "cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863",
3216 "object": "container",
3217 "created_at": 1747844794,
3218 "status": "running",
3219 "expires_after": {
3220 "anchor": "last_active_at",
3221 "minutes": 20
3222 },
3223 "last_active_at": 1747844794,
3224 "name": "My Container"
3225 }
3226 ],
3227 "first_id": "container_123",
3228 "last_id": "container_123",
3229 "has_more": false
3230 }
3231 post:
3232 summary: Create Container
3233 description: Creates a container.
3234 operationId: CreateContainer
3235 parameters: []
3236 requestBody:
3237 content:
3238 application/json:
3239 schema:
3240 $ref: "#/components/schemas/CreateContainerBody"
3241 responses:
3242 "200":
3243 description: Success
3244 content:
3245 application/json:
3246 schema:
3247 $ref: "#/components/schemas/ContainerResource"
3248 x-oaiMeta:
3249 name: Create container
3250 group: containers
3251 returns: The created [container](/docs/api-reference/containers/object) object.
3252 path: post
3253 examples:
3254 request:
3255 curl: |
3256 curl https://api.openai.com/v1/containers \
3257 -H "Authorization: Bearer $OPENAI_API_KEY" \
3258 -H "Content-Type: application/json" \
3259 -d '{
3260 "name": "My Container"
3261 }'
3262 response: |
3263 {
3264 "id": "cntr_682e30645a488191b6363a0cbefc0f0a025ec61b66250591",
3265 "object": "container",
3266 "created_at": 1747857508,
3267 "status": "running",
3268 "expires_after": {
3269 "anchor": "last_active_at",
3270 "minutes": 20
3271 },
3272 "last_active_at": 1747857508,
3273 "name": "My Container"
3274 }
3275 /containers/{container_id}:
3276 get:
3277 summary: Retrieve Container
3278 description: Retrieves a container.
3279 operationId: RetrieveContainer
3280 parameters:
3281 - name: container_id
3282 in: path
3283 required: true
3284 schema:
3285 type: string
3286 responses:
3287 "200":
3288 description: Success
3289 content:
3290 application/json:
3291 schema:
3292 $ref: "#/components/schemas/ContainerResource"
3293 x-oaiMeta:
3294 name: Retrieve container
3295 group: containers
3296 returns: The [container](/docs/api-reference/containers/object) object.
3297 path: get
3298 examples:
3299 request:
3300 curl: |
3301 curl https://api.openai.com/v1/containers/cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863 \
3302 -H "Authorization: Bearer $OPENAI_API_KEY"
3303 response: |
3304 {
3305 "id": "cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863",
3306 "object": "container",
3307 "created_at": 1747844794,
3308 "status": "running",
3309 "expires_after": {
3310 "anchor": "last_active_at",
3311 "minutes": 20
3312 },
3313 "last_active_at": 1747844794,
3314 "name": "My Container"
3315 }
3316 delete:
3317 operationId: DeleteContainer
3318 summary: Delete Container
3319 description: Delete a container.
3320 parameters:
3321 - name: container_id
3322 in: path
3323 description: The ID of the container to delete.
3324 required: true
3325 schema:
3326 type: string
3327 responses:
3328 "200":
3329 description: OK
3330 x-oaiMeta:
3331 name: Delete a container
3332 group: containers
3333 returns: Deletion Status
3334 path: delete
3335 examples:
3336 request:
3337 curl: |
3338 curl -X DELETE https://api.openai.com/v1/containers/cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863 \
3339 -H "Authorization: Bearer $OPENAI_API_KEY"
3340 response: |
3341 {
3342 "id": "cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863",
3343 "object": "container.deleted",
3344 "deleted": true
3345 }
3346 /containers/{container_id}/files:
3347 post:
3348 summary: >
3349 Create a Container File
3350
3351
3352 You can send either a multipart/form-data request with the raw file
3353 content, or a JSON request with a file ID.
3354 description: |
3355 Creates a container file.
3356 operationId: CreateContainerFile
3357 parameters:
3358 - name: container_id
3359 in: path
3360 required: true
3361 schema:
3362 type: string
3363 requestBody:
3364 required: true
3365 content:
3366 multipart/form-data:
3367 schema:
3368 $ref: "#/components/schemas/CreateContainerFileBody"
3369 responses:
3370 "200":
3371 description: Success
3372 content:
3373 application/json:
3374 schema:
3375 $ref: "#/components/schemas/ContainerFileResource"
3376 x-oaiMeta:
3377 name: Create container file
3378 group: containers
3379 returns: The created [container
3380 file](/docs/api-reference/container-files/object) object.
3381 path: post
3382 examples:
3383 request:
3384 curl: |
3385 curl https://api.openai.com/v1/containers/cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04/files \
3386 -H "Authorization: Bearer $OPENAI_API_KEY" \
3387 -F file="@example.txt"
3388 response: >
3389 {
3390 "id": "cfile_682e0e8a43c88191a7978f477a09bdf5",
3391 "object": "container.file",
3392 "created_at": 1747848842,
3393 "bytes": 880,
3394 "container_id": "cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04",
3395 "path": "/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json",
3396 "source": "user"
3397 }
3398 get:
3399 summary: List Container files
3400 description: Lists container files.
3401 operationId: ListContainerFiles
3402 parameters:
3403 - name: container_id
3404 in: path
3405 required: true
3406 schema:
3407 type: string
3408 - name: limit
3409 in: query
3410 description: >
3411 A limit on the number of objects to be returned. Limit can range
3412 between 1 and 100, and the default is 20.
3413 required: false
3414 schema:
3415 type: integer
3416 default: 20
3417 - name: order
3418 in: query
3419 description: >
3420 Sort order by the `created_at` timestamp of the objects. `asc` for
3421 ascending order and `desc` for descending order.
3422 schema:
3423 type: string
3424 default: desc
3425 enum:
3426 - asc
3427 - desc
3428 - name: after
3429 in: query
3430 description: >
3431 A cursor for use in pagination. `after` is an object ID that defines
3432 your place in the list. For instance, if you make a list request and
3433 receive 100 objects, ending with obj_foo, your subsequent call can
3434 include after=obj_foo in order to fetch the next page of the list.
3435 schema:
3436 type: string
3437 responses:
3438 "200":
3439 description: Success
3440 content:
3441 application/json:
3442 schema:
3443 $ref: "#/components/schemas/ContainerFileListResource"
3444 x-oaiMeta:
3445 name: List container files
3446 group: containers
3447 returns: a list of [container file](/docs/api-reference/container-files/object)
3448 objects.
3449 path: get
3450 examples:
3451 request:
3452 curl: |
3453 curl https://api.openai.com/v1/containers/cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04/files \
3454 -H "Authorization: Bearer $OPENAI_API_KEY"
3455 response: >
3456 {
3457 "object": "list",
3458 "data": [
3459 {
3460 "id": "cfile_682e0e8a43c88191a7978f477a09bdf5",
3461 "object": "container.file",
3462 "created_at": 1747848842,
3463 "bytes": 880,
3464 "container_id": "cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04",
3465 "path": "/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json",
3466 "source": "user"
3467 }
3468 ],
3469 "first_id": "cfile_682e0e8a43c88191a7978f477a09bdf5",
3470 "has_more": false,
3471 "last_id": "cfile_682e0e8a43c88191a7978f477a09bdf5"
3472 }
3473 /containers/{container_id}/files/{file_id}:
3474 get:
3475 summary: Retrieve Container File
3476 description: Retrieves a container file.
3477 operationId: RetrieveContainerFile
3478 parameters:
3479 - name: container_id
3480 in: path
3481 required: true
3482 schema:
3483 type: string
3484 - name: file_id
3485 in: path
3486 required: true
3487 schema:
3488 type: string
3489 responses:
3490 "200":
3491 description: Success
3492 content:
3493 application/json:
3494 schema:
3495 $ref: "#/components/schemas/ContainerFileResource"
3496 x-oaiMeta:
3497 name: Retrieve container file
3498 group: containers
3499 returns: The [container file](/docs/api-reference/container-files/object)
3500 object.
3501 path: get
3502 examples:
3503 request:
3504 curl: >
3505 curl
3506 https://api.openai.com/v1/containers/container_123/files/file_456
3507 \
3508 -H "Authorization: Bearer $OPENAI_API_KEY"
3509 response: >
3510 {
3511 "id": "cfile_682e0e8a43c88191a7978f477a09bdf5",
3512 "object": "container.file",
3513 "created_at": 1747848842,
3514 "bytes": 880,
3515 "container_id": "cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04",
3516 "path": "/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json",
3517 "source": "user"
3518 }
3519 delete:
3520 operationId: DeleteContainerFile
3521 summary: Delete Container File
3522 description: Delete a container file.
3523 parameters:
3524 - name: container_id
3525 in: path
3526 required: true
3527 schema:
3528 type: string
3529 - name: file_id
3530 in: path
3531 required: true
3532 schema:
3533 type: string
3534 responses:
3535 "200":
3536 description: OK
3537 x-oaiMeta:
3538 name: Delete a container file
3539 group: containers
3540 returns: Deletion Status
3541 path: delete
3542 examples:
3543 request:
3544 curl: |
3545 curl -X DELETE https://api.openai.com/v1/containers/cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863/files/cfile_682e0e8a43c88191a7978f477a09bdf5 \
3546 -H "Authorization: Bearer $OPENAI_API_KEY"
3547 response: |
3548 {
3549 "id": "cfile_682e0e8a43c88191a7978f477a09bdf5",
3550 "object": "container.file.deleted",
3551 "deleted": true
3552 }
3553 /containers/{container_id}/files/{file_id}/content:
3554 get:
3555 summary: Retrieve Container File Content
3556 description: Retrieves a container file content.
3557 operationId: RetrieveContainerFileContent
3558 parameters:
3559 - name: container_id
3560 in: path
3561 required: true
3562 schema:
3563 type: string
3564 - name: file_id
3565 in: path
3566 required: true
3567 schema:
3568 type: string
3569 responses:
3570 "200":
3571 description: Success
3572 x-oaiMeta:
3573 name: Retrieve container file content
3574 group: containers
3575 returns: The contents of the container file.
3576 path: get
3577 examples:
3578 request:
3579 curl: |
3580 curl https://api.openai.com/v1/containers/container_123/files/cfile_456/content \
3581 -H "Authorization: Bearer $OPENAI_API_KEY"
3582 response: |
3583 <binary content of the file>
3584 /embeddings:
3585 post:
3586 operationId: createEmbedding
3587 tags:
3588 - Embeddings
3589 summary: Creates an embedding vector representing the input text.
3590 requestBody:
3591 required: true
3592 content:
3593 application/json:
3594 schema:
3595 $ref: "#/components/schemas/CreateEmbeddingRequest"
3596 responses:
3597 "200":
3598 description: OK
3599 content:
3600 application/json:
3601 schema:
3602 $ref: "#/components/schemas/CreateEmbeddingResponse"
3603 x-oaiMeta:
3604 name: Create embeddings
3605 group: embeddings
3606 returns: A list of [embedding](/docs/api-reference/embeddings/object) objects.
3607 examples:
3608 request:
3609 curl: |
3610 curl https://api.openai.com/v1/embeddings \
3611 -H "Authorization: Bearer $OPENAI_API_KEY" \
3612 -H "Content-Type: application/json" \
3613 -d '{
3614 "input": "The food was delicious and the waiter...",
3615 "model": "text-embedding-ada-002",
3616 "encoding_format": "float"
3617 }'
3618 python: |
3619 from openai import OpenAI
3620 client = OpenAI()
3621
3622 client.embeddings.create(
3623 model="text-embedding-ada-002",
3624 input="The food was delicious and the waiter...",
3625 encoding_format="float"
3626 )
3627 node.js: |
3628 import OpenAI from "openai";
3629
3630 const openai = new OpenAI();
3631
3632 async function main() {
3633 const embedding = await openai.embeddings.create({
3634 model: "text-embedding-ada-002",
3635 input: "The quick brown fox jumped over the lazy dog",
3636 encoding_format: "float",
3637 });
3638
3639 console.log(embedding);
3640 }
3641
3642 main();
3643 csharp: >
3644 using System;
3645
3646
3647 using OpenAI.Embeddings;
3648
3649
3650 EmbeddingClient client = new(
3651 model: "text-embedding-3-small",
3652 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
3653 );
3654
3655
3656 OpenAIEmbedding embedding = client.GenerateEmbedding(input: "The
3657 quick brown fox jumped over the lazy dog");
3658
3659 ReadOnlyMemory<float> vector = embedding.ToFloats();
3660
3661
3662 for (int i = 0; i < vector.Length; i++)
3663
3664 {
3665 Console.WriteLine($" [{i,4}] = {vector.Span[i]}");
3666 }
3667 response: |
3668 {
3669 "object": "list",
3670 "data": [
3671 {
3672 "object": "embedding",
3673 "embedding": [
3674 0.0023064255,
3675 -0.009327292,
3676 .... (1536 floats total for ada-002)
3677 -0.0028842222,
3678 ],
3679 "index": 0
3680 }
3681 ],
3682 "model": "text-embedding-ada-002",
3683 "usage": {
3684 "prompt_tokens": 8,
3685 "total_tokens": 8
3686 }
3687 }
3688 /evals:
3689 get:
3690 operationId: listEvals
3691 tags:
3692 - Evals
3693 summary: |
3694 List evaluations for a project.
3695 parameters:
3696 - name: after
3697 in: query
3698 description: Identifier for the last eval from the previous pagination request.
3699 required: false
3700 schema:
3701 type: string
3702 - name: limit
3703 in: query
3704 description: Number of evals to retrieve.
3705 required: false
3706 schema:
3707 type: integer
3708 default: 20
3709 - name: order
3710 in: query
3711 description: Sort order for evals by timestamp. Use `asc` for ascending order or
3712 `desc` for descending order.
3713 required: false
3714 schema:
3715 type: string
3716 enum:
3717 - asc
3718 - desc
3719 default: asc
3720 - name: order_by
3721 in: query
3722 description: >
3723 Evals can be ordered by creation time or last updated time. Use
3724
3725 `created_at` for creation time or `updated_at` for last updated
3726 time.
3727 required: false
3728 schema:
3729 type: string
3730 enum:
3731 - created_at
3732 - updated_at
3733 default: created_at
3734 responses:
3735 "200":
3736 description: A list of evals
3737 content:
3738 application/json:
3739 schema:
3740 $ref: "#/components/schemas/EvalList"
3741 x-oaiMeta:
3742 name: List evals
3743 group: evals
3744 returns: A list of [evals](/docs/api-reference/evals/object) matching the
3745 specified filters.
3746 path: list
3747 examples:
3748 request:
3749 curl: |
3750 curl https://api.openai.com/v1/evals?limit=1 \
3751 -H "Authorization: Bearer $OPENAI_API_KEY" \
3752 -H "Content-Type: application/json"
3753 python: |
3754 from openai import OpenAI
3755 client = OpenAI()
3756
3757 evals = client.evals.list(limit=1)
3758 print(evals)
3759 node.js: |
3760 import OpenAI from "openai";
3761
3762 const openai = new OpenAI();
3763
3764 const evals = await openai.evals.list({ limit: 1 });
3765 console.log(evals);
3766 response: >
3767 {
3768 "object": "list",
3769 "data": [
3770 {
3771 "id": "eval_67abd54d9b0081909a86353f6fb9317a",
3772 "object": "eval",
3773 "data_source_config": {
3774 "type": "stored_completions",
3775 "metadata": {
3776 "usecase": "push_notifications_summarizer"
3777 },
3778 "schema": {
3779 "type": "object",
3780 "properties": {
3781 "item": {
3782 "type": "object"
3783 },
3784 "sample": {
3785 "type": "object"
3786 }
3787 },
3788 "required": [
3789 "item",
3790 "sample"
3791 ]
3792 }
3793 },
3794 "testing_criteria": [
3795 {
3796 "name": "Push Notification Summary Grader",
3797 "id": "Push Notification Summary Grader-9b876f24-4762-4be9-aff4-db7a9b31c673",
3798 "type": "label_model",
3799 "model": "o3-mini",
3800 "input": [
3801 {
3802 "type": "message",
3803 "role": "developer",
3804 "content": {
3805 "type": "input_text",
3806 "text": "\nLabel the following push notification summary as either correct or incorrect.\nThe push notification and the summary will be provided below.\nA good push notificiation summary is concise and snappy.\nIf it is good, then label it as correct, if not, then incorrect.\n"
3807 }
3808 },
3809 {
3810 "type": "message",
3811 "role": "user",
3812 "content": {
3813 "type": "input_text",
3814 "text": "\nPush notifications: {{item.input}}\nSummary: {{sample.output_text}}\n"
3815 }
3816 }
3817 ],
3818 "passing_labels": [
3819 "correct"
3820 ],
3821 "labels": [
3822 "correct",
3823 "incorrect"
3824 ],
3825 "sampling_params": null
3826 }
3827 ],
3828 "name": "Push Notification Summary Grader",
3829 "created_at": 1739314509,
3830 "metadata": {
3831 "description": "A stored completions eval for push notification summaries"
3832 }
3833 }
3834 ],
3835 "first_id": "eval_67abd54d9b0081909a86353f6fb9317a",
3836 "last_id": "eval_67aa884cf6688190b58f657d4441c8b7",
3837 "has_more": true
3838 }
3839 post:
3840 operationId: createEval
3841 tags:
3842 - Evals
3843 summary: >
3844 Create the structure of an evaluation that can be used to test a model's
3845 performance.
3846
3847 An evaluation is a set of testing criteria and the config for a data
3848 source, which dictates the schema of the data used in the evaluation.
3849 After creating an evaluation, you can run it on different models and
3850 model parameters. We support several types of graders and datasources.
3851
3852 For more information, see the [Evals guide](/docs/guides/evals).
3853 requestBody:
3854 required: true
3855 content:
3856 application/json:
3857 schema:
3858 $ref: "#/components/schemas/CreateEvalRequest"
3859 responses:
3860 "201":
3861 description: OK
3862 content:
3863 application/json:
3864 schema:
3865 $ref: "#/components/schemas/Eval"
3866 x-oaiMeta:
3867 name: Create eval
3868 group: evals
3869 returns: The created [Eval](/docs/api-reference/evals/object) object.
3870 path: post
3871 examples:
3872 request:
3873 curl: >
3874 curl https://api.openai.com/v1/evals \
3875 -H "Authorization: Bearer $OPENAI_API_KEY" \
3876 -H "Content-Type: application/json" \
3877 -d '{
3878 "name": "Sentiment",
3879 "data_source_config": {
3880 "type": "stored_completions",
3881 "metadata": {
3882 "usecase": "chatbot"
3883 }
3884 },
3885 "testing_criteria": [
3886 {
3887 "type": "label_model",
3888 "model": "o3-mini",
3889 "input": [
3890 {
3891 "role": "developer",
3892 "content": "Classify the sentiment of the following statement as one of 'positive', 'neutral', or 'negative'"
3893 },
3894 {
3895 "role": "user",
3896 "content": "Statement: {{item.input}}"
3897 }
3898 ],
3899 "passing_labels": [
3900 "positive"
3901 ],
3902 "labels": [
3903 "positive",
3904 "neutral",
3905 "negative"
3906 ],
3907 "name": "Example label grader"
3908 }
3909 ]
3910 }'
3911 python: >
3912 from openai import OpenAI
3913
3914 client = OpenAI()
3915
3916
3917 eval_obj = client.evals.create(
3918 name="Sentiment",
3919 data_source_config={
3920 "type": "stored_completions",
3921 "metadata": {"usecase": "chatbot"}
3922 },
3923 testing_criteria=[
3924 {
3925 "type": "label_model",
3926 "model": "o3-mini",
3927 "input": [
3928 {"role": "developer", "content": "Classify the sentiment of the following statement as one of 'positive', 'neutral', or 'negative'"},
3929 {"role": "user", "content": "Statement: {{item.input}}"}
3930 ],
3931 "passing_labels": ["positive"],
3932 "labels": ["positive", "neutral", "negative"],
3933 "name": "Example label grader"
3934 }
3935 ]
3936 )
3937
3938 print(eval_obj)
3939 node.js: >
3940 import OpenAI from "openai";
3941
3942
3943 const openai = new OpenAI();
3944
3945
3946 const evalObj = await openai.evals.create({
3947 name: "Sentiment",
3948 data_source_config: {
3949 type: "stored_completions",
3950 metadata: { usecase: "chatbot" }
3951 },
3952 testing_criteria: [
3953 {
3954 type: "label_model",
3955 model: "o3-mini",
3956 input: [
3957 { role: "developer", content: "Classify the sentiment of the following statement as one of 'positive', 'neutral', or 'negative'" },
3958 { role: "user", content: "Statement: {{item.input}}" }
3959 ],
3960 passing_labels: ["positive"],
3961 labels: ["positive", "neutral", "negative"],
3962 name: "Example label grader"
3963 }
3964 ]
3965 });
3966
3967 console.log(evalObj);
3968 response: >
3969 {
3970 "object": "eval",
3971 "id": "eval_67b7fa9a81a88190ab4aa417e397ea21",
3972 "data_source_config": {
3973 "type": "stored_completions",
3974 "metadata": {
3975 "usecase": "chatbot"
3976 },
3977 "schema": {
3978 "type": "object",
3979 "properties": {
3980 "item": {
3981 "type": "object"
3982 },
3983 "sample": {
3984 "type": "object"
3985 }
3986 },
3987 "required": [
3988 "item",
3989 "sample"
3990 ]
3991 },
3992 "testing_criteria": [
3993 {
3994 "name": "Example label grader",
3995 "type": "label_model",
3996 "model": "o3-mini",
3997 "input": [
3998 {
3999 "type": "message",
4000 "role": "developer",
4001 "content": {
4002 "type": "input_text",
4003 "text": "Classify the sentiment of the following statement as one of positive, neutral, or negative"
4004 }
4005 },
4006 {
4007 "type": "message",
4008 "role": "user",
4009 "content": {
4010 "type": "input_text",
4011 "text": "Statement: {{item.input}}"
4012 }
4013 }
4014 ],
4015 "passing_labels": [
4016 "positive"
4017 ],
4018 "labels": [
4019 "positive",
4020 "neutral",
4021 "negative"
4022 ]
4023 }
4024 ],
4025 "name": "Sentiment",
4026 "created_at": 1740110490,
4027 "metadata": {
4028 "description": "An eval for sentiment analysis"
4029 }
4030 }
4031 /evals/{eval_id}:
4032 get:
4033 operationId: getEval
4034 tags:
4035 - Evals
4036 summary: |
4037 Get an evaluation by ID.
4038 parameters:
4039 - name: eval_id
4040 in: path
4041 required: true
4042 schema:
4043 type: string
4044 description: The ID of the evaluation to retrieve.
4045 responses:
4046 "200":
4047 description: The evaluation
4048 content:
4049 application/json:
4050 schema:
4051 $ref: "#/components/schemas/Eval"
4052 x-oaiMeta:
4053 name: Get an eval
4054 group: evals
4055 returns: The [Eval](/docs/api-reference/evals/object) object matching the
4056 specified ID.
4057 path: get
4058 examples:
4059 request:
4060 curl: |
4061 curl https://api.openai.com/v1/evals/eval_67abd54d9b0081909a86353f6fb9317a \
4062 -H "Authorization: Bearer $OPENAI_API_KEY" \
4063 -H "Content-Type: application/json"
4064 python: >
4065 from openai import OpenAI
4066
4067 client = OpenAI()
4068
4069
4070 eval_obj =
4071 client.evals.retrieve("eval_67abd54d9b0081909a86353f6fb9317a")
4072
4073 print(eval_obj)
4074 node.js: >
4075 import OpenAI from "openai";
4076
4077
4078 const openai = new OpenAI();
4079
4080
4081 const evalObj = await
4082 openai.evals.retrieve("eval_67abd54d9b0081909a86353f6fb9317a");
4083
4084 console.log(evalObj);
4085 response: |
4086 {
4087 "object": "eval",
4088 "id": "eval_67abd54d9b0081909a86353f6fb9317a",
4089 "data_source_config": {
4090 "type": "custom",
4091 "schema": {
4092 "type": "object",
4093 "properties": {
4094 "item": {
4095 "type": "object",
4096 "properties": {
4097 "input": {
4098 "type": "string"
4099 },
4100 "ground_truth": {
4101 "type": "string"
4102 }
4103 },
4104 "required": [
4105 "input",
4106 "ground_truth"
4107 ]
4108 }
4109 },
4110 "required": [
4111 "item"
4112 ]
4113 }
4114 },
4115 "testing_criteria": [
4116 {
4117 "name": "String check",
4118 "id": "String check-2eaf2d8d-d649-4335-8148-9535a7ca73c2",
4119 "type": "string_check",
4120 "input": "{{item.input}}",
4121 "reference": "{{item.ground_truth}}",
4122 "operation": "eq"
4123 }
4124 ],
4125 "name": "External Data Eval",
4126 "created_at": 1739314509,
4127 "metadata": {},
4128 }
4129 post:
4130 operationId: updateEval
4131 tags:
4132 - Evals
4133 summary: |
4134 Update certain properties of an evaluation.
4135 parameters:
4136 - name: eval_id
4137 in: path
4138 required: true
4139 schema:
4140 type: string
4141 description: The ID of the evaluation to update.
4142 requestBody:
4143 description: Request to update an evaluation
4144 required: true
4145 content:
4146 application/json:
4147 schema:
4148 type: object
4149 properties:
4150 name:
4151 type: string
4152 description: Rename the evaluation.
4153 metadata:
4154 $ref: "#/components/schemas/Metadata"
4155 responses:
4156 "200":
4157 description: The updated evaluation
4158 content:
4159 application/json:
4160 schema:
4161 $ref: "#/components/schemas/Eval"
4162 x-oaiMeta:
4163 name: Update an eval
4164 group: evals
4165 returns: The [Eval](/docs/api-reference/evals/object) object matching the
4166 updated version.
4167 path: update
4168 examples:
4169 request:
4170 curl: |
4171 curl https://api.openai.com/v1/evals/eval_67abd54d9b0081909a86353f6fb9317a \
4172 -H "Authorization: Bearer $OPENAI_API_KEY" \
4173 -H "Content-Type: application/json" \
4174 -d '{"name": "Updated Eval", "metadata": {"description": "Updated description"}}'
4175 python: |
4176 from openai import OpenAI
4177 client = OpenAI()
4178
4179 updated_eval = client.evals.update(
4180 "eval_67abd54d9b0081909a86353f6fb9317a",
4181 name="Updated Eval",
4182 metadata={"description": "Updated description"}
4183 )
4184 print(updated_eval)
4185 node.js: |
4186 import OpenAI from "openai";
4187
4188 const openai = new OpenAI();
4189
4190 const updatedEval = await openai.evals.update(
4191 "eval_67abd54d9b0081909a86353f6fb9317a",
4192 {
4193 name: "Updated Eval",
4194 metadata: { description: "Updated description" }
4195 }
4196 );
4197 console.log(updatedEval);
4198 response: |
4199 {
4200 "object": "eval",
4201 "id": "eval_67abd54d9b0081909a86353f6fb9317a",
4202 "data_source_config": {
4203 "type": "custom",
4204 "schema": {
4205 "type": "object",
4206 "properties": {
4207 "item": {
4208 "type": "object",
4209 "properties": {
4210 "input": {
4211 "type": "string"
4212 },
4213 "ground_truth": {
4214 "type": "string"
4215 }
4216 },
4217 "required": [
4218 "input",
4219 "ground_truth"
4220 ]
4221 }
4222 },
4223 "required": [
4224 "item"
4225 ]
4226 }
4227 },
4228 "testing_criteria": [
4229 {
4230 "name": "String check",
4231 "id": "String check-2eaf2d8d-d649-4335-8148-9535a7ca73c2",
4232 "type": "string_check",
4233 "input": "{{item.input}}",
4234 "reference": "{{item.ground_truth}}",
4235 "operation": "eq"
4236 }
4237 ],
4238 "name": "Updated Eval",
4239 "created_at": 1739314509,
4240 "metadata": {"description": "Updated description"},
4241 }
4242 delete:
4243 operationId: deleteEval
4244 tags:
4245 - Evals
4246 summary: |
4247 Delete an evaluation.
4248 parameters:
4249 - name: eval_id
4250 in: path
4251 required: true
4252 schema:
4253 type: string
4254 description: The ID of the evaluation to delete.
4255 responses:
4256 "200":
4257 description: Successfully deleted the evaluation.
4258 content:
4259 application/json:
4260 schema:
4261 type: object
4262 properties:
4263 object:
4264 type: string
4265 example: eval.deleted
4266 deleted:
4267 type: boolean
4268 example: true
4269 eval_id:
4270 type: string
4271 example: eval_abc123
4272 required:
4273 - object
4274 - deleted
4275 - eval_id
4276 "404":
4277 description: Evaluation not found.
4278 content:
4279 application/json:
4280 schema:
4281 $ref: "#/components/schemas/Error"
4282 x-oaiMeta:
4283 name: Delete an eval
4284 group: evals
4285 returns: A deletion confirmation object.
4286 examples:
4287 request:
4288 curl: |
4289 curl https://api.openai.com/v1/evals/eval_abc123 \
4290 -X DELETE \
4291 -H "Authorization: Bearer $OPENAI_API_KEY"
4292 python: |
4293 from openai import OpenAI
4294 client = OpenAI()
4295
4296 deleted = client.evals.delete("eval_abc123")
4297 print(deleted)
4298 node.js: |
4299 import OpenAI from "openai";
4300
4301 const openai = new OpenAI();
4302
4303 const deleted = await openai.evals.delete("eval_abc123");
4304 console.log(deleted);
4305 response: |
4306 {
4307 "object": "eval.deleted",
4308 "deleted": true,
4309 "eval_id": "eval_abc123"
4310 }
4311 /evals/{eval_id}/runs:
4312 get:
4313 operationId: getEvalRuns
4314 tags:
4315 - Evals
4316 summary: |
4317 Get a list of runs for an evaluation.
4318 parameters:
4319 - name: eval_id
4320 in: path
4321 required: true
4322 schema:
4323 type: string
4324 description: The ID of the evaluation to retrieve runs for.
4325 - name: after
4326 in: query
4327 description: Identifier for the last run from the previous pagination request.
4328 required: false
4329 schema:
4330 type: string
4331 - name: limit
4332 in: query
4333 description: Number of runs to retrieve.
4334 required: false
4335 schema:
4336 type: integer
4337 default: 20
4338 - name: order
4339 in: query
4340 description: Sort order for runs by timestamp. Use `asc` for ascending order or
4341 `desc` for descending order. Defaults to `asc`.
4342 required: false
4343 schema:
4344 type: string
4345 enum:
4346 - asc
4347 - desc
4348 default: asc
4349 - name: status
4350 in: query
4351 description: Filter runs by status. One of `queued` | `in_progress` | `failed` |
4352 `completed` | `canceled`.
4353 required: false
4354 schema:
4355 type: string
4356 enum:
4357 - queued
4358 - in_progress
4359 - completed
4360 - canceled
4361 - failed
4362 responses:
4363 "200":
4364 description: A list of runs for the evaluation
4365 content:
4366 application/json:
4367 schema:
4368 $ref: "#/components/schemas/EvalRunList"
4369 x-oaiMeta:
4370 name: Get eval runs
4371 group: evals
4372 returns: A list of [EvalRun](/docs/api-reference/evals/run-object) objects
4373 matching the specified ID.
4374 path: get-runs
4375 examples:
4376 request:
4377 curl: |
4378 curl https://api.openai.com/v1/evals/egroup_67abd54d9b0081909a86353f6fb9317a/runs \
4379 -H "Authorization: Bearer $OPENAI_API_KEY" \
4380 -H "Content-Type: application/json"
4381 python: >
4382 from openai import OpenAI
4383
4384 client = OpenAI()
4385
4386
4387 runs =
4388 client.evals.runs.list("egroup_67abd54d9b0081909a86353f6fb9317a")
4389
4390 print(runs)
4391 node.js: >
4392 import OpenAI from "openai";
4393
4394
4395 const openai = new OpenAI();
4396
4397
4398 const runs = await
4399 openai.evals.runs.list("egroup_67abd54d9b0081909a86353f6fb9317a");
4400
4401 console.log(runs);
4402 response: >
4403 {
4404 "object": "list",
4405 "data": [
4406 {
4407 "object": "eval.run",
4408 "id": "evalrun_67e0c7d31560819090d60c0780591042",
4409 "eval_id": "eval_67e0c726d560819083f19a957c4c640b",
4410 "report_url": "https://platform.openai.com/evaluations/eval_67e0c726d560819083f19a957c4c640b",
4411 "status": "completed",
4412 "model": "o3-mini",
4413 "name": "bulk_with_negative_examples_o3-mini",
4414 "created_at": 1742784467,
4415 "result_counts": {
4416 "total": 1,
4417 "errored": 0,
4418 "failed": 0,
4419 "passed": 1
4420 },
4421 "per_model_usage": [
4422 {
4423 "model_name": "o3-mini",
4424 "invocation_count": 1,
4425 "prompt_tokens": 563,
4426 "completion_tokens": 874,
4427 "total_tokens": 1437,
4428 "cached_tokens": 0
4429 }
4430 ],
4431 "per_testing_criteria_results": [
4432 {
4433 "testing_criteria": "Push Notification Summary Grader-1808cd0b-eeec-4e0b-a519-337e79f4f5d1",
4434 "passed": 1,
4435 "failed": 0
4436 }
4437 ],
4438 "data_source": {
4439 "type": "completions",
4440 "source": {
4441 "type": "file_content",
4442 "content": [
4443 {
4444 "item": {
4445 "notifications": "\n- New message from Sarah: \"Can you call me later?\"\n- Your package has been delivered!\n- Flash sale: 20% off electronics for the next 2 hours!\n"
4446 }
4447 }
4448 ]
4449 },
4450 "input_messages": {
4451 "type": "template",
4452 "template": [
4453 {
4454 "type": "message",
4455 "role": "developer",
4456 "content": {
4457 "type": "input_text",
4458 "text": "\n\n\n\nYou are a helpful assistant that takes in an array of push notifications and returns a collapsed summary of them.\nThe push notification will be provided as follows:\n<push_notifications>\n...notificationlist...\n</push_notifications>\n\nYou should return just the summary and nothing else.\n\n\nYou should return a summary that is concise and snappy.\n\n\nHere is an example of a good summary:\n<push_notifications>\n- Traffic alert: Accident reported on Main Street.- Package out for delivery: Expected by 5 PM.- New friend suggestion: Connect with Emma.\n</push_notifications>\n<summary>\nTraffic alert, package expected by 5pm, suggestion for new friend (Emily).\n</summary>\n\n\nHere is an example of a bad summary:\n<push_notifications>\n- Traffic alert: Accident reported on Main Street.- Package out for delivery: Expected by 5 PM.- New friend suggestion: Connect with Emma.\n</push_notifications>\n<summary>\nTraffic alert reported on main street. You have a package that will arrive by 5pm, Emily is a new friend suggested for you.\n</summary>\n"
4459 }
4460 },
4461 {
4462 "type": "message",
4463 "role": "user",
4464 "content": {
4465 "type": "input_text",
4466 "text": "<push_notifications>{{item.notifications}}</push_notifications>"
4467 }
4468 }
4469 ]
4470 },
4471 "model": "o3-mini",
4472 "sampling_params": null
4473 },
4474 "error": null,
4475 "metadata": {}
4476 }
4477 ],
4478 "first_id": "evalrun_67e0c7d31560819090d60c0780591042",
4479 "last_id": "evalrun_67e0c7d31560819090d60c0780591042",
4480 "has_more": true
4481 }
4482 post:
4483 operationId: createEvalRun
4484 tags:
4485 - Evals
4486 summary: >
4487 Kicks off a new run for a given evaluation, specifying the data source,
4488 and what model configuration to use to test. The datasource will be
4489 validated against the schema specified in the config of the evaluation.
4490 parameters:
4491 - in: path
4492 name: eval_id
4493 required: true
4494 schema:
4495 type: string
4496 description: The ID of the evaluation to create a run for.
4497 requestBody:
4498 required: true
4499 content:
4500 application/json:
4501 schema:
4502 $ref: "#/components/schemas/CreateEvalRunRequest"
4503 responses:
4504 "201":
4505 description: Successfully created a run for the evaluation
4506 content:
4507 application/json:
4508 schema:
4509 $ref: "#/components/schemas/EvalRun"
4510 "400":
4511 description: Bad request (for example, missing eval object)
4512 content:
4513 application/json:
4514 schema:
4515 $ref: "#/components/schemas/Error"
4516 x-oaiMeta:
4517 name: Create eval run
4518 group: evals
4519 returns: The [EvalRun](/docs/api-reference/evals/run-object) object matching the
4520 specified ID.
4521 examples:
4522 request:
4523 curl: |
4524 curl https://api.openai.com/v1/evals/eval_67e579652b548190aaa83ada4b125f47/runs \
4525 -X POST \
4526 -H "Authorization: Bearer $OPENAI_API_KEY" \
4527 -H "Content-Type: application/json" \
4528 -d '{"name":"gpt-4o-mini","data_source":{"type":"completions","input_messages":{"type":"template","template":[{"role":"developer","content":"Categorize a given news headline into one of the following topics: Technology, Markets, World, Business, or Sports.\n\n# Steps\n\n1. Analyze the content of the news headline to understand its primary focus.\n2. Extract the subject matter, identifying any key indicators or keywords.\n3. Use the identified indicators to determine the most suitable category out of the five options: Technology, Markets, World, Business, or Sports.\n4. Ensure only one category is selected per headline.\n\n# Output Format\n\nRespond with the chosen category as a single word. For instance: \"Technology\", \"Markets\", \"World\", \"Business\", or \"Sports\".\n\n# Examples\n\n**Input**: \"Apple Unveils New iPhone Model, Featuring Advanced AI Features\" \n**Output**: \"Technology\"\n\n**Input**: \"Global Stocks Mixed as Investors Await Central Bank Decisions\" \n**Output**: \"Markets\"\n\n**Input**: \"War in Ukraine: Latest Updates on Negotiation Status\" \n**Output**: \"World\"\n\n**Input**: \"Microsoft in Talks to Acquire Gaming Company for $2 Billion\" \n**Output**: \"Business\"\n\n**Input**: \"Manchester United Secures Win in Premier League Football Match\" \n**Output**: \"Sports\" \n\n# Notes\n\n- If the headline appears to fit into more than one category, choose the most dominant theme.\n- Keywords or phrases such as \"stocks\", \"company acquisition\", \"match\", or technological brands can be good indicators for classification.\n"} , {"role":"user","content":"{{item.input}}"}]} ,"sampling_params":{"temperature":1,"max_completions_tokens":2048,"top_p":1,"seed":42},"model":"gpt-4o-mini","source":{"type":"file_content","content":[{"item":{"input":"Tech Company Launches Advanced Artificial Intelligence Platform","ground_truth":"Technology"}}]}}'
4529 python: >
4530 from openai import OpenAI
4531
4532 client = OpenAI()
4533
4534
4535 run = client.evals.runs.create(
4536 "eval_67e579652b548190aaa83ada4b125f47",
4537 name="gpt-4o-mini",
4538 data_source={
4539 "type": "completions",
4540 "input_messages": {
4541 "type": "template",
4542 "template": [
4543 {
4544 "role": "developer",
4545 "content": "Categorize a given news headline into one of the following topics: Technology, Markets, World, Business, or Sports.\n\n# Steps\n\n1. Analyze the content of the news headline to understand its primary focus.\n2. Extract the subject matter, identifying any key indicators or keywords.\n3. Use the identified indicators to determine the most suitable category out of the five options: Technology, Markets, World, Business, or Sports.\n4. Ensure only one category is selected per headline.\n\n# Output Format\n\nRespond with the chosen category as a single word. For instance: \"Technology\", \"Markets\", \"World\", \"Business\", or \"Sports\".\n\n# Examples\n\n**Input**: \"Apple Unveils New iPhone Model, Featuring Advanced AI Features\" \n**Output**: \"Technology\"\n\n**Input**: \"Global Stocks Mixed as Investors Await Central Bank Decisions\" \n**Output**: \"Markets\"\n\n**Input**: \"War in Ukraine: Latest Updates on Negotiation Status\" \n**Output**: \"World\"\n\n**Input**: \"Microsoft in Talks to Acquire Gaming Company for $2 Billion\" \n**Output**: \"Business\"\n\n**Input**: \"Manchester United Secures Win in Premier League Football Match\" \n**Output**: \"Sports\" \n\n# Notes\n\n- If the headline appears to fit into more than one category, choose the most dominant theme.\n- Keywords or phrases such as \"stocks\", \"company acquisition\", \"match\", or technological brands can be good indicators for classification.\n"
4546 },
4547 {
4548 "role": "user",
4549 "content": "{{item.input}}"
4550 }
4551 ]
4552 },
4553 "sampling_params": {
4554 "temperature": 1,
4555 "max_completions_tokens": 2048,
4556 "top_p": 1,
4557 "seed": 42
4558 },
4559 "model": "gpt-4o-mini",
4560 "source": {
4561 "type": "file_content",
4562 "content": [
4563 {
4564 "item": {
4565 "input": "Tech Company Launches Advanced Artificial Intelligence Platform",
4566 "ground_truth": "Technology"
4567 }
4568 }
4569 ]
4570 }
4571 }
4572 )
4573
4574 print(run)
4575 node.js: >
4576 import OpenAI from "openai";
4577
4578
4579 const openai = new OpenAI();
4580
4581
4582 const run = await openai.evals.runs.create(
4583 "eval_67e579652b548190aaa83ada4b125f47",
4584 {
4585 name: "gpt-4o-mini",
4586 data_source: {
4587 type: "completions",
4588 input_messages: {
4589 type: "template",
4590 template: [
4591 {
4592 role: "developer",
4593 content: "Categorize a given news headline into one of the following topics: Technology, Markets, World, Business, or Sports.\n\n# Steps\n\n1. Analyze the content of the news headline to understand its primary focus.\n2. Extract the subject matter, identifying any key indicators or keywords.\n3. Use the identified indicators to determine the most suitable category out of the five options: Technology, Markets, World, Business, or Sports.\n4. Ensure only one category is selected per headline.\n\n# Output Format\n\nRespond with the chosen category as a single word. For instance: \"Technology\", \"Markets\", \"World\", \"Business\", or \"Sports\".\n\n# Examples\n\n**Input**: \"Apple Unveils New iPhone Model, Featuring Advanced AI Features\" \n**Output**: \"Technology\"\n\n**Input**: \"Global Stocks Mixed as Investors Await Central Bank Decisions\" \n**Output**: \"Markets\"\n\n**Input**: \"War in Ukraine: Latest Updates on Negotiation Status\" \n**Output**: \"World\"\n\n**Input**: \"Microsoft in Talks to Acquire Gaming Company for $2 Billion\" \n**Output**: \"Business\"\n\n**Input**: \"Manchester United Secures Win in Premier League Football Match\" \n**Output**: \"Sports\" \n\n# Notes\n\n- If the headline appears to fit into more than one category, choose the most dominant theme.\n- Keywords or phrases such as \"stocks\", \"company acquisition\", \"match\", or technological brands can be good indicators for classification.\n"
4594 },
4595 {
4596 role: "user",
4597 content: "{{item.input}}"
4598 }
4599 ]
4600 },
4601 sampling_params: {
4602 temperature: 1,
4603 max_completions_tokens: 2048,
4604 top_p: 1,
4605 seed: 42
4606 },
4607 model: "gpt-4o-mini",
4608 source: {
4609 type: "file_content",
4610 content: [
4611 {
4612 item: {
4613 input: "Tech Company Launches Advanced Artificial Intelligence Platform",
4614 ground_truth: "Technology"
4615 }
4616 }
4617 ]
4618 }
4619 }
4620 }
4621 );
4622
4623 console.log(run);
4624 response: >
4625 {
4626 "object": "eval.run",
4627 "id": "evalrun_67e57965b480819094274e3a32235e4c",
4628 "eval_id": "eval_67e579652b548190aaa83ada4b125f47",
4629 "report_url": "https://platform.openai.com/evaluations/eval_67e579652b548190aaa83ada4b125f47&run_id=evalrun_67e57965b480819094274e3a32235e4c",
4630 "status": "queued",
4631 "model": "gpt-4o-mini",
4632 "name": "gpt-4o-mini",
4633 "created_at": 1743092069,
4634 "result_counts": {
4635 "total": 0,
4636 "errored": 0,
4637 "failed": 0,
4638 "passed": 0
4639 },
4640 "per_model_usage": null,
4641 "per_testing_criteria_results": null,
4642 "data_source": {
4643 "type": "completions",
4644 "source": {
4645 "type": "file_content",
4646 "content": [
4647 {
4648 "item": {
4649 "input": "Tech Company Launches Advanced Artificial Intelligence Platform",
4650 "ground_truth": "Technology"
4651 }
4652 }
4653 ]
4654 },
4655 "input_messages": {
4656 "type": "template",
4657 "template": [
4658 {
4659 "type": "message",
4660 "role": "developer",
4661 "content": {
4662 "type": "input_text",
4663 "text": "Categorize a given news headline into one of the following topics: Technology, Markets, World, Business, or Sports.\n\n# Steps\n\n1. Analyze the content of the news headline to understand its primary focus.\n2. Extract the subject matter, identifying any key indicators or keywords.\n3. Use the identified indicators to determine the most suitable category out of the five options: Technology, Markets, World, Business, or Sports.\n4. Ensure only one category is selected per headline.\n\n# Output Format\n\nRespond with the chosen category as a single word. For instance: \"Technology\", \"Markets\", \"World\", \"Business\", or \"Sports\".\n\n# Examples\n\n**Input**: \"Apple Unveils New iPhone Model, Featuring Advanced AI Features\" \n**Output**: \"Technology\"\n\n**Input**: \"Global Stocks Mixed as Investors Await Central Bank Decisions\" \n**Output**: \"Markets\"\n\n**Input**: \"War in Ukraine: Latest Updates on Negotiation Status\" \n**Output**: \"World\"\n\n**Input**: \"Microsoft in Talks to Acquire Gaming Company for $2 Billion\" \n**Output**: \"Business\"\n\n**Input**: \"Manchester United Secures Win in Premier League Football Match\" \n**Output**: \"Sports\" \n\n# Notes\n\n- If the headline appears to fit into more than one category, choose the most dominant theme.\n- Keywords or phrases such as \"stocks\", \"company acquisition\", \"match\", or technological brands can be good indicators for classification.\n"
4664 }
4665 },
4666 {
4667 "type": "message",
4668 "role": "user",
4669 "content": {
4670 "type": "input_text",
4671 "text": "{{item.input}}"
4672 }
4673 }
4674 ]
4675 },
4676 "model": "gpt-4o-mini",
4677 "sampling_params": {
4678 "seed": 42,
4679 "temperature": 1.0,
4680 "top_p": 1.0,
4681 "max_completions_tokens": 2048
4682 }
4683 },
4684 "error": null,
4685 "metadata": {}
4686 }
4687 /evals/{eval_id}/runs/{run_id}:
4688 get:
4689 operationId: getEvalRun
4690 tags:
4691 - Evals
4692 summary: |
4693 Get an evaluation run by ID.
4694 parameters:
4695 - name: eval_id
4696 in: path
4697 required: true
4698 schema:
4699 type: string
4700 description: The ID of the evaluation to retrieve runs for.
4701 - name: run_id
4702 in: path
4703 required: true
4704 schema:
4705 type: string
4706 description: The ID of the run to retrieve.
4707 responses:
4708 "200":
4709 description: The evaluation run
4710 content:
4711 application/json:
4712 schema:
4713 $ref: "#/components/schemas/EvalRun"
4714 x-oaiMeta:
4715 name: Get an eval run
4716 group: evals
4717 returns: The [EvalRun](/docs/api-reference/evals/run-object) object matching the
4718 specified ID.
4719 path: get
4720 examples:
4721 request:
4722 curl: |
4723 curl https://api.openai.com/v1/evals/eval_67abd54d9b0081909a86353f6fb9317a/runs/evalrun_67abd54d60ec8190832b46859da808f7 \
4724 -H "Authorization: Bearer $OPENAI_API_KEY" \
4725 -H "Content-Type: application/json"
4726 python: |
4727 from openai import OpenAI
4728 client = OpenAI()
4729
4730 run = client.evals.runs.retrieve(
4731 "eval_67abd54d9b0081909a86353f6fb9317a",
4732 "evalrun_67abd54d60ec8190832b46859da808f7"
4733 )
4734 print(run)
4735 node.js: |
4736 import OpenAI from "openai";
4737
4738 const openai = new OpenAI();
4739
4740 const run = await openai.evals.runs.retrieve(
4741 "eval_67abd54d9b0081909a86353f6fb9317a",
4742 "evalrun_67abd54d60ec8190832b46859da808f7"
4743 );
4744 console.log(run);
4745 response: >
4746 {
4747 "object": "eval.run",
4748 "id": "evalrun_67abd54d60ec8190832b46859da808f7",
4749 "eval_id": "eval_67abd54d9b0081909a86353f6fb9317a",
4750 "report_url": "https://platform.openai.com/evaluations/eval_67abd54d9b0081909a86353f6fb9317a?run_id=evalrun_67abd54d60ec8190832b46859da808f7",
4751 "status": "queued",
4752 "model": "gpt-4o-mini",
4753 "name": "gpt-4o-mini",
4754 "created_at": 1743092069,
4755 "result_counts": {
4756 "total": 0,
4757 "errored": 0,
4758 "failed": 0,
4759 "passed": 0
4760 },
4761 "per_model_usage": null,
4762 "per_testing_criteria_results": null,
4763 "data_source": {
4764 "type": "completions",
4765 "source": {
4766 "type": "file_content",
4767 "content": [
4768 {
4769 "item": {
4770 "input": "Tech Company Launches Advanced Artificial Intelligence Platform",
4771 "ground_truth": "Technology"
4772 }
4773 },
4774 {
4775 "item": {
4776 "input": "Central Bank Increases Interest Rates Amid Inflation Concerns",
4777 "ground_truth": "Markets"
4778 }
4779 },
4780 {
4781 "item": {
4782 "input": "International Summit Addresses Climate Change Strategies",
4783 "ground_truth": "World"
4784 }
4785 },
4786 {
4787 "item": {
4788 "input": "Major Retailer Reports Record-Breaking Holiday Sales",
4789 "ground_truth": "Business"
4790 }
4791 },
4792 {
4793 "item": {
4794 "input": "National Team Qualifies for World Championship Finals",
4795 "ground_truth": "Sports"
4796 }
4797 },
4798 {
4799 "item": {
4800 "input": "Stock Markets Rally After Positive Economic Data Released",
4801 "ground_truth": "Markets"
4802 }
4803 },
4804 {
4805 "item": {
4806 "input": "Global Manufacturer Announces Merger with Competitor",
4807 "ground_truth": "Business"
4808 }
4809 },
4810 {
4811 "item": {
4812 "input": "Breakthrough in Renewable Energy Technology Unveiled",
4813 "ground_truth": "Technology"
4814 }
4815 },
4816 {
4817 "item": {
4818 "input": "World Leaders Sign Historic Climate Agreement",
4819 "ground_truth": "World"
4820 }
4821 },
4822 {
4823 "item": {
4824 "input": "Professional Athlete Sets New Record in Championship Event",
4825 "ground_truth": "Sports"
4826 }
4827 },
4828 {
4829 "item": {
4830 "input": "Financial Institutions Adapt to New Regulatory Requirements",
4831 "ground_truth": "Business"
4832 }
4833 },
4834 {
4835 "item": {
4836 "input": "Tech Conference Showcases Advances in Artificial Intelligence",
4837 "ground_truth": "Technology"
4838 }
4839 },
4840 {
4841 "item": {
4842 "input": "Global Markets Respond to Oil Price Fluctuations",
4843 "ground_truth": "Markets"
4844 }
4845 },
4846 {
4847 "item": {
4848 "input": "International Cooperation Strengthened Through New Treaty",
4849 "ground_truth": "World"
4850 }
4851 },
4852 {
4853 "item": {
4854 "input": "Sports League Announces Revised Schedule for Upcoming Season",
4855 "ground_truth": "Sports"
4856 }
4857 }
4858 ]
4859 },
4860 "input_messages": {
4861 "type": "template",
4862 "template": [
4863 {
4864 "type": "message",
4865 "role": "developer",
4866 "content": {
4867 "type": "input_text",
4868 "text": "Categorize a given news headline into one of the following topics: Technology, Markets, World, Business, or Sports.\n\n# Steps\n\n1. Analyze the content of the news headline to understand its primary focus.\n2. Extract the subject matter, identifying any key indicators or keywords.\n3. Use the identified indicators to determine the most suitable category out of the five options: Technology, Markets, World, Business, or Sports.\n4. Ensure only one category is selected per headline.\n\n# Output Format\n\nRespond with the chosen category as a single word. For instance: \"Technology\", \"Markets\", \"World\", \"Business\", or \"Sports\".\n\n# Examples\n\n**Input**: \"Apple Unveils New iPhone Model, Featuring Advanced AI Features\" \n**Output**: \"Technology\"\n\n**Input**: \"Global Stocks Mixed as Investors Await Central Bank Decisions\" \n**Output**: \"Markets\"\n\n**Input**: \"War in Ukraine: Latest Updates on Negotiation Status\" \n**Output**: \"World\"\n\n**Input**: \"Microsoft in Talks to Acquire Gaming Company for $2 Billion\" \n**Output**: \"Business\"\n\n**Input**: \"Manchester United Secures Win in Premier League Football Match\" \n**Output**: \"Sports\" \n\n# Notes\n\n- If the headline appears to fit into more than one category, choose the most dominant theme.\n- Keywords or phrases such as \"stocks\", \"company acquisition\", \"match\", or technological brands can be good indicators for classification.\n"
4869 }
4870 },
4871 {
4872 "type": "message",
4873 "role": "user",
4874 "content": {
4875 "type": "input_text",
4876 "text": "{{item.input}}"
4877 }
4878 }
4879 ]
4880 },
4881 "model": "gpt-4o-mini",
4882 "sampling_params": {
4883 "seed": 42,
4884 "temperature": 1.0,
4885 "top_p": 1.0,
4886 "max_completions_tokens": 2048
4887 }
4888 },
4889 "error": null,
4890 "metadata": {}
4891 }
4892 post:
4893 operationId: cancelEvalRun
4894 tags:
4895 - Evals
4896 summary: |
4897 Cancel an ongoing evaluation run.
4898 parameters:
4899 - name: eval_id
4900 in: path
4901 required: true
4902 schema:
4903 type: string
4904 description: The ID of the evaluation whose run you want to cancel.
4905 - name: run_id
4906 in: path
4907 required: true
4908 schema:
4909 type: string
4910 description: The ID of the run to cancel.
4911 responses:
4912 "200":
4913 description: The canceled eval run object
4914 content:
4915 application/json:
4916 schema:
4917 $ref: "#/components/schemas/EvalRun"
4918 x-oaiMeta:
4919 name: Cancel eval run
4920 group: evals
4921 returns: The updated [EvalRun](/docs/api-reference/evals/run-object) object
4922 reflecting that the run is canceled.
4923 path: post
4924 examples:
4925 request:
4926 curl: |
4927 curl https://api.openai.com/v1/evals/eval_67abd54d9b0081909a86353f6fb9317a/runs/evalrun_67abd54d60ec8190832b46859da808f7/cancel \
4928 -X POST \
4929 -H "Authorization: Bearer $OPENAI_API_KEY" \
4930 -H "Content-Type: application/json"
4931 python: |
4932 from openai import OpenAI
4933 client = OpenAI()
4934
4935 canceled_run = client.evals.runs.cancel(
4936 "eval_67abd54d9b0081909a86353f6fb9317a",
4937 "evalrun_67abd54d60ec8190832b46859da808f7"
4938 )
4939 print(canceled_run)
4940 node.js: |
4941 import OpenAI from "openai";
4942
4943 const openai = new OpenAI();
4944
4945 const canceledRun = await openai.evals.runs.cancel(
4946 "eval_67abd54d9b0081909a86353f6fb9317a",
4947 "evalrun_67abd54d60ec8190832b46859da808f7"
4948 );
4949 console.log(canceledRun);
4950 response: >
4951 {
4952 "object": "eval.run",
4953 "id": "evalrun_67abd54d60ec8190832b46859da808f7",
4954 "eval_id": "eval_67abd54d9b0081909a86353f6fb9317a",
4955 "report_url": "https://platform.openai.com/evaluations/eval_67abd54d9b0081909a86353f6fb9317a?run_id=evalrun_67abd54d60ec8190832b46859da808f7",
4956 "status": "canceled",
4957 "model": "gpt-4o-mini",
4958 "name": "gpt-4o-mini",
4959 "created_at": 1743092069,
4960 "result_counts": {
4961 "total": 0,
4962 "errored": 0,
4963 "failed": 0,
4964 "passed": 0
4965 },
4966 "per_model_usage": null,
4967 "per_testing_criteria_results": null,
4968 "data_source": {
4969 "type": "completions",
4970 "source": {
4971 "type": "file_content",
4972 "content": [
4973 {
4974 "item": {
4975 "input": "Tech Company Launches Advanced Artificial Intelligence Platform",
4976 "ground_truth": "Technology"
4977 }
4978 },
4979 {
4980 "item": {
4981 "input": "Central Bank Increases Interest Rates Amid Inflation Concerns",
4982 "ground_truth": "Markets"
4983 }
4984 },
4985 {
4986 "item": {
4987 "input": "International Summit Addresses Climate Change Strategies",
4988 "ground_truth": "World"
4989 }
4990 },
4991 {
4992 "item": {
4993 "input": "Major Retailer Reports Record-Breaking Holiday Sales",
4994 "ground_truth": "Business"
4995 }
4996 },
4997 {
4998 "item": {
4999 "input": "National Team Qualifies for World Championship Finals",
5000 "ground_truth": "Sports"
5001 }
5002 },
5003 {
5004 "item": {
5005 "input": "Stock Markets Rally After Positive Economic Data Released",
5006 "ground_truth": "Markets"
5007 }
5008 },
5009 {
5010 "item": {
5011 "input": "Global Manufacturer Announces Merger with Competitor",
5012 "ground_truth": "Business"
5013 }
5014 },
5015 {
5016 "item": {
5017 "input": "Breakthrough in Renewable Energy Technology Unveiled",
5018 "ground_truth": "Technology"
5019 }
5020 },
5021 {
5022 "item": {
5023 "input": "World Leaders Sign Historic Climate Agreement",
5024 "ground_truth": "World"
5025 }
5026 },
5027 {
5028 "item": {
5029 "input": "Professional Athlete Sets New Record in Championship Event",
5030 "ground_truth": "Sports"
5031 }
5032 },
5033 {
5034 "item": {
5035 "input": "Financial Institutions Adapt to New Regulatory Requirements",
5036 "ground_truth": "Business"
5037 }
5038 },
5039 {
5040 "item": {
5041 "input": "Tech Conference Showcases Advances in Artificial Intelligence",
5042 "ground_truth": "Technology"
5043 }
5044 },
5045 {
5046 "item": {
5047 "input": "Global Markets Respond to Oil Price Fluctuations",
5048 "ground_truth": "Markets"
5049 }
5050 },
5051 {
5052 "item": {
5053 "input": "International Cooperation Strengthened Through New Treaty",
5054 "ground_truth": "World"
5055 }
5056 },
5057 {
5058 "item": {
5059 "input": "Sports League Announces Revised Schedule for Upcoming Season",
5060 "ground_truth": "Sports"
5061 }
5062 }
5063 ]
5064 },
5065 "input_messages": {
5066 "type": "template",
5067 "template": [
5068 {
5069 "type": "message",
5070 "role": "developer",
5071 "content": {
5072 "type": "input_text",
5073 "text": "Categorize a given news headline into one of the following topics: Technology, Markets, World, Business, or Sports.\n\n# Steps\n\n1. Analyze the content of the news headline to understand its primary focus.\n2. Extract the subject matter, identifying any key indicators or keywords.\n3. Use the identified indicators to determine the most suitable category out of the five options: Technology, Markets, World, Business, or Sports.\n4. Ensure only one category is selected per headline.\n\n# Output Format\n\nRespond with the chosen category as a single word. For instance: \"Technology\", \"Markets\", \"World\", \"Business\", or \"Sports\".\n\n# Examples\n\n**Input**: \"Apple Unveils New iPhone Model, Featuring Advanced AI Features\" \n**Output**: \"Technology\"\n\n**Input**: \"Global Stocks Mixed as Investors Await Central Bank Decisions\" \n**Output**: \"Markets\"\n\n**Input**: \"War in Ukraine: Latest Updates on Negotiation Status\" \n**Output**: \"World\"\n\n**Input**: \"Microsoft in Talks to Acquire Gaming Company for $2 Billion\" \n**Output**: \"Business\"\n\n**Input**: \"Manchester United Secures Win in Premier League Football Match\" \n**Output**: \"Sports\" \n\n# Notes\n\n- If the headline appears to fit into more than one category, choose the most dominant theme.\n- Keywords or phrases such as \"stocks\", \"company acquisition\", \"match\", or technological brands can be good indicators for classification.\n"
5074 }
5075 },
5076 {
5077 "type": "message",
5078 "role": "user",
5079 "content": {
5080 "type": "input_text",
5081 "text": "{{item.input}}"
5082 }
5083 }
5084 ]
5085 },
5086 "model": "gpt-4o-mini",
5087 "sampling_params": {
5088 "seed": 42,
5089 "temperature": 1.0,
5090 "top_p": 1.0,
5091 "max_completions_tokens": 2048
5092 }
5093 },
5094 "error": null,
5095 "metadata": {}
5096 }
5097 delete:
5098 operationId: deleteEvalRun
5099 tags:
5100 - Evals
5101 summary: |
5102 Delete an eval run.
5103 parameters:
5104 - name: eval_id
5105 in: path
5106 required: true
5107 schema:
5108 type: string
5109 description: The ID of the evaluation to delete the run from.
5110 - name: run_id
5111 in: path
5112 required: true
5113 schema:
5114 type: string
5115 description: The ID of the run to delete.
5116 responses:
5117 "200":
5118 description: Successfully deleted the eval run
5119 content:
5120 application/json:
5121 schema:
5122 type: object
5123 properties:
5124 object:
5125 type: string
5126 example: eval.run.deleted
5127 deleted:
5128 type: boolean
5129 example: true
5130 run_id:
5131 type: string
5132 example: evalrun_677469f564d48190807532a852da3afb
5133 "404":
5134 description: Run not found
5135 content:
5136 application/json:
5137 schema:
5138 $ref: "#/components/schemas/Error"
5139 x-oaiMeta:
5140 name: Delete eval run
5141 group: evals
5142 returns: An object containing the status of the delete operation.
5143 path: delete
5144 examples:
5145 request:
5146 curl: >
5147 curl
5148 https://api.openai.com/v1/evals/eval_123abc/runs/evalrun_abc456 \
5149 -X DELETE \
5150 -H "Authorization: Bearer $OPENAI_API_KEY" \
5151 -H "Content-Type: application/json"
5152 python: |
5153 from openai import OpenAI
5154 client = OpenAI()
5155
5156 deleted = client.evals.runs.delete(
5157 "eval_123abc",
5158 "evalrun_abc456"
5159 )
5160 print(deleted)
5161 node.js: |
5162 import OpenAI from "openai";
5163
5164 const openai = new OpenAI();
5165
5166 const deleted = await openai.evals.runs.delete(
5167 "eval_123abc",
5168 "evalrun_abc456"
5169 );
5170 console.log(deleted);
5171 response: |
5172 {
5173 "object": "eval.run.deleted",
5174 "deleted": true,
5175 "run_id": "evalrun_abc456"
5176 }
5177 /evals/{eval_id}/runs/{run_id}/output_items:
5178 get:
5179 operationId: getEvalRunOutputItems
5180 tags:
5181 - Evals
5182 summary: |
5183 Get a list of output items for an evaluation run.
5184 parameters:
5185 - name: eval_id
5186 in: path
5187 required: true
5188 schema:
5189 type: string
5190 description: The ID of the evaluation to retrieve runs for.
5191 - name: run_id
5192 in: path
5193 required: true
5194 schema:
5195 type: string
5196 description: The ID of the run to retrieve output items for.
5197 - name: after
5198 in: query
5199 description: Identifier for the last output item from the previous pagination
5200 request.
5201 required: false
5202 schema:
5203 type: string
5204 - name: limit
5205 in: query
5206 description: Number of output items to retrieve.
5207 required: false
5208 schema:
5209 type: integer
5210 default: 20
5211 - name: status
5212 in: query
5213 description: >
5214 Filter output items by status. Use `failed` to filter by failed
5215 output
5216
5217 items or `pass` to filter by passed output items.
5218 required: false
5219 schema:
5220 type: string
5221 enum:
5222 - fail
5223 - pass
5224 - name: order
5225 in: query
5226 description: Sort order for output items by timestamp. Use `asc` for ascending
5227 order or `desc` for descending order. Defaults to `asc`.
5228 required: false
5229 schema:
5230 type: string
5231 enum:
5232 - asc
5233 - desc
5234 default: asc
5235 responses:
5236 "200":
5237 description: A list of output items for the evaluation run
5238 content:
5239 application/json:
5240 schema:
5241 $ref: "#/components/schemas/EvalRunOutputItemList"
5242 x-oaiMeta:
5243 name: Get eval run output items
5244 group: evals
5245 returns: A list of
5246 [EvalRunOutputItem](/docs/api-reference/evals/run-output-item-object)
5247 objects matching the specified ID.
5248 path: get
5249 examples:
5250 request:
5251 curl: |
5252 curl https://api.openai.com/v1/evals/egroup_67abd54d9b0081909a86353f6fb9317a/runs/erun_67abd54d60ec8190832b46859da808f7/output_items \
5253 -H "Authorization: Bearer $OPENAI_API_KEY" \
5254 -H "Content-Type: application/json"
5255 python: |
5256 from openai import OpenAI
5257 client = OpenAI()
5258
5259 output_items = client.evals.runs.output_items.list(
5260 "egroup_67abd54d9b0081909a86353f6fb9317a",
5261 "erun_67abd54d60ec8190832b46859da808f7"
5262 )
5263 print(output_items)
5264 node.js: |
5265 import OpenAI from "openai";
5266
5267 const openai = new OpenAI();
5268
5269 const outputItems = await openai.evals.runs.outputItems.list(
5270 "egroup_67abd54d9b0081909a86353f6fb9317a",
5271 "erun_67abd54d60ec8190832b46859da808f7"
5272 );
5273 console.log(outputItems);
5274 response: >
5275 {
5276 "object": "list",
5277 "data": [
5278 {
5279 "object": "eval.run.output_item",
5280 "id": "outputitem_67e5796c28e081909917bf79f6e6214d",
5281 "created_at": 1743092076,
5282 "run_id": "evalrun_67abd54d60ec8190832b46859da808f7",
5283 "eval_id": "eval_67abd54d9b0081909a86353f6fb9317a",
5284 "status": "pass",
5285 "datasource_item_id": 5,
5286 "datasource_item": {
5287 "input": "Stock Markets Rally After Positive Economic Data Released",
5288 "ground_truth": "Markets"
5289 },
5290 "results": [
5291 {
5292 "name": "String check-a2486074-d803-4445-b431-ad2262e85d47",
5293 "sample": null,
5294 "passed": true,
5295 "score": 1.0
5296 }
5297 ],
5298 "sample": {
5299 "input": [
5300 {
5301 "role": "developer",
5302 "content": "Categorize a given news headline into one of the following topics: Technology, Markets, World, Business, or Sports.\n\n# Steps\n\n1. Analyze the content of the news headline to understand its primary focus.\n2. Extract the subject matter, identifying any key indicators or keywords.\n3. Use the identified indicators to determine the most suitable category out of the five options: Technology, Markets, World, Business, or Sports.\n4. Ensure only one category is selected per headline.\n\n# Output Format\n\nRespond with the chosen category as a single word. For instance: \"Technology\", \"Markets\", \"World\", \"Business\", or \"Sports\".\n\n# Examples\n\n**Input**: \"Apple Unveils New iPhone Model, Featuring Advanced AI Features\" \n**Output**: \"Technology\"\n\n**Input**: \"Global Stocks Mixed as Investors Await Central Bank Decisions\" \n**Output**: \"Markets\"\n\n**Input**: \"War in Ukraine: Latest Updates on Negotiation Status\" \n**Output**: \"World\"\n\n**Input**: \"Microsoft in Talks to Acquire Gaming Company for $2 Billion\" \n**Output**: \"Business\"\n\n**Input**: \"Manchester United Secures Win in Premier League Football Match\" \n**Output**: \"Sports\" \n\n# Notes\n\n- If the headline appears to fit into more than one category, choose the most dominant theme.\n- Keywords or phrases such as \"stocks\", \"company acquisition\", \"match\", or technological brands can be good indicators for classification.\n",
5303 "tool_call_id": null,
5304 "tool_calls": null,
5305 "function_call": null
5306 },
5307 {
5308 "role": "user",
5309 "content": "Stock Markets Rally After Positive Economic Data Released",
5310 "tool_call_id": null,
5311 "tool_calls": null,
5312 "function_call": null
5313 }
5314 ],
5315 "output": [
5316 {
5317 "role": "assistant",
5318 "content": "Markets",
5319 "tool_call_id": null,
5320 "tool_calls": null,
5321 "function_call": null
5322 }
5323 ],
5324 "finish_reason": "stop",
5325 "model": "gpt-4o-mini-2024-07-18",
5326 "usage": {
5327 "total_tokens": 325,
5328 "completion_tokens": 2,
5329 "prompt_tokens": 323,
5330 "cached_tokens": 0
5331 },
5332 "error": null,
5333 "temperature": 1.0,
5334 "max_completion_tokens": 2048,
5335 "top_p": 1.0,
5336 "seed": 42
5337 }
5338 }
5339 ],
5340 "first_id": "outputitem_67e5796c28e081909917bf79f6e6214d",
5341 "last_id": "outputitem_67e5796c28e081909917bf79f6e6214d",
5342 "has_more": true
5343 }
5344 /evals/{eval_id}/runs/{run_id}/output_items/{output_item_id}:
5345 get:
5346 operationId: getEvalRunOutputItem
5347 tags:
5348 - Evals
5349 summary: |
5350 Get an evaluation run output item by ID.
5351 parameters:
5352 - name: eval_id
5353 in: path
5354 required: true
5355 schema:
5356 type: string
5357 description: The ID of the evaluation to retrieve runs for.
5358 - name: run_id
5359 in: path
5360 required: true
5361 schema:
5362 type: string
5363 description: The ID of the run to retrieve.
5364 - name: output_item_id
5365 in: path
5366 required: true
5367 schema:
5368 type: string
5369 description: The ID of the output item to retrieve.
5370 responses:
5371 "200":
5372 description: The evaluation run output item
5373 content:
5374 application/json:
5375 schema:
5376 $ref: "#/components/schemas/EvalRunOutputItem"
5377 x-oaiMeta:
5378 name: Get an output item of an eval run
5379 group: evals
5380 returns: The
5381 [EvalRunOutputItem](/docs/api-reference/evals/run-output-item-object)
5382 object matching the specified ID.
5383 path: get
5384 examples:
5385 request:
5386 curl: |
5387 curl https://api.openai.com/v1/evals/eval_67abd54d9b0081909a86353f6fb9317a/runs/evalrun_67abd54d60ec8190832b46859da808f7/output_items/outputitem_67abd55eb6548190bb580745d5644a33 \
5388 -H "Authorization: Bearer $OPENAI_API_KEY" \
5389 -H "Content-Type: application/json"
5390 python: |
5391 from openai import OpenAI
5392 client = OpenAI()
5393
5394 output_item = client.evals.runs.output_items.retrieve(
5395 "eval_67abd54d9b0081909a86353f6fb9317a",
5396 "evalrun_67abd54d60ec8190832b46859da808f7",
5397 "outputitem_67abd55eb6548190bb580745d5644a33"
5398 )
5399 print(output_item)
5400 node.js: |
5401 import OpenAI from "openai";
5402
5403 const openai = new OpenAI();
5404
5405 const outputItem = await openai.evals.runs.outputItems.retrieve(
5406 "eval_67abd54d9b0081909a86353f6fb9317a",
5407 "evalrun_67abd54d60ec8190832b46859da808f7",
5408 "outputitem_67abd55eb6548190bb580745d5644a33"
5409 );
5410 console.log(outputItem);
5411 response: >
5412 {
5413 "object": "eval.run.output_item",
5414 "id": "outputitem_67e5796c28e081909917bf79f6e6214d",
5415 "created_at": 1743092076,
5416 "run_id": "evalrun_67abd54d60ec8190832b46859da808f7",
5417 "eval_id": "eval_67abd54d9b0081909a86353f6fb9317a",
5418 "status": "pass",
5419 "datasource_item_id": 5,
5420 "datasource_item": {
5421 "input": "Stock Markets Rally After Positive Economic Data Released",
5422 "ground_truth": "Markets"
5423 },
5424 "results": [
5425 {
5426 "name": "String check-a2486074-d803-4445-b431-ad2262e85d47",
5427 "sample": null,
5428 "passed": true,
5429 "score": 1.0
5430 }
5431 ],
5432 "sample": {
5433 "input": [
5434 {
5435 "role": "developer",
5436 "content": "Categorize a given news headline into one of the following topics: Technology, Markets, World, Business, or Sports.\n\n# Steps\n\n1. Analyze the content of the news headline to understand its primary focus.\n2. Extract the subject matter, identifying any key indicators or keywords.\n3. Use the identified indicators to determine the most suitable category out of the five options: Technology, Markets, World, Business, or Sports.\n4. Ensure only one category is selected per headline.\n\n# Output Format\n\nRespond with the chosen category as a single word. For instance: \"Technology\", \"Markets\", \"World\", \"Business\", or \"Sports\".\n\n# Examples\n\n**Input**: \"Apple Unveils New iPhone Model, Featuring Advanced AI Features\" \n**Output**: \"Technology\"\n\n**Input**: \"Global Stocks Mixed as Investors Await Central Bank Decisions\" \n**Output**: \"Markets\"\n\n**Input**: \"War in Ukraine: Latest Updates on Negotiation Status\" \n**Output**: \"World\"\n\n**Input**: \"Microsoft in Talks to Acquire Gaming Company for $2 Billion\" \n**Output**: \"Business\"\n\n**Input**: \"Manchester United Secures Win in Premier League Football Match\" \n**Output**: \"Sports\" \n\n# Notes\n\n- If the headline appears to fit into more than one category, choose the most dominant theme.\n- Keywords or phrases such as \"stocks\", \"company acquisition\", \"match\", or technological brands can be good indicators for classification.\n",
5437 "tool_call_id": null,
5438 "tool_calls": null,
5439 "function_call": null
5440 },
5441 {
5442 "role": "user",
5443 "content": "Stock Markets Rally After Positive Economic Data Released",
5444 "tool_call_id": null,
5445 "tool_calls": null,
5446 "function_call": null
5447 }
5448 ],
5449 "output": [
5450 {
5451 "role": "assistant",
5452 "content": "Markets",
5453 "tool_call_id": null,
5454 "tool_calls": null,
5455 "function_call": null
5456 }
5457 ],
5458 "finish_reason": "stop",
5459 "model": "gpt-4o-mini-2024-07-18",
5460 "usage": {
5461 "total_tokens": 325,
5462 "completion_tokens": 2,
5463 "prompt_tokens": 323,
5464 "cached_tokens": 0
5465 },
5466 "error": null,
5467 "temperature": 1.0,
5468 "max_completion_tokens": 2048,
5469 "top_p": 1.0,
5470 "seed": 42
5471 }
5472 }
5473 /files:
5474 get:
5475 operationId: listFiles
5476 tags:
5477 - Files
5478 summary: Returns a list of files.
5479 parameters:
5480 - in: query
5481 name: purpose
5482 required: false
5483 schema:
5484 type: string
5485 description: Only return files with the given purpose.
5486 - name: limit
5487 in: query
5488 description: >
5489 A limit on the number of objects to be returned. Limit can range
5490 between 1 and 10,000, and the default is 10,000.
5491 required: false
5492 schema:
5493 type: integer
5494 default: 10000
5495 - name: order
5496 in: query
5497 description: >
5498 Sort order by the `created_at` timestamp of the objects. `asc` for
5499 ascending order and `desc` for descending order.
5500 schema:
5501 type: string
5502 default: desc
5503 enum:
5504 - asc
5505 - desc
5506 - name: after
5507 in: query
5508 description: >
5509 A cursor for use in pagination. `after` is an object ID that defines
5510 your place in the list. For instance, if you make a list request and
5511 receive 100 objects, ending with obj_foo, your subsequent call can
5512 include after=obj_foo in order to fetch the next page of the list.
5513 schema:
5514 type: string
5515 responses:
5516 "200":
5517 description: OK
5518 content:
5519 application/json:
5520 schema:
5521 $ref: "#/components/schemas/ListFilesResponse"
5522 x-oaiMeta:
5523 name: List files
5524 group: files
5525 returns: A list of [File](/docs/api-reference/files/object) objects.
5526 examples:
5527 request:
5528 curl: |
5529 curl https://api.openai.com/v1/files \
5530 -H "Authorization: Bearer $OPENAI_API_KEY"
5531 python: |
5532 from openai import OpenAI
5533 client = OpenAI()
5534
5535 client.files.list()
5536 node.js: |-
5537 import OpenAI from "openai";
5538
5539 const openai = new OpenAI();
5540
5541 async function main() {
5542 const list = await openai.files.list();
5543
5544 for await (const file of list) {
5545 console.log(file);
5546 }
5547 }
5548
5549 main();
5550 response: |
5551 {
5552 "data": [
5553 {
5554 "id": "file-abc123",
5555 "object": "file",
5556 "bytes": 175,
5557 "created_at": 1613677385,
5558 "filename": "salesOverview.pdf",
5559 "purpose": "assistants",
5560 },
5561 {
5562 "id": "file-abc123",
5563 "object": "file",
5564 "bytes": 140,
5565 "created_at": 1613779121,
5566 "filename": "puppy.jsonl",
5567 "purpose": "fine-tune",
5568 }
5569 ],
5570 "object": "list"
5571 }
5572 post:
5573 operationId: createFile
5574 tags:
5575 - Files
5576 summary: >
5577 Upload a file that can be used across various endpoints. Individual
5578 files can be up to 512 MB, and the size of all files uploaded by one
5579 organization can be up to 100 GB.
5580
5581
5582 The Assistants API supports files up to 2 million tokens and of specific
5583 file types. See the [Assistants Tools guide](/docs/assistants/tools) for
5584 details.
5585
5586
5587 The Fine-tuning API only supports `.jsonl` files. The input also has
5588 certain required formats for fine-tuning
5589 [chat](/docs/api-reference/fine-tuning/chat-input) or
5590 [completions](/docs/api-reference/fine-tuning/completions-input) models.
5591
5592
5593 The Batch API only supports `.jsonl` files up to 200 MB in size. The
5594 input also has a specific required
5595 [format](/docs/api-reference/batch/request-input).
5596
5597
5598 Please [contact us](https://help.openai.com/) if you need to increase
5599 these storage limits.
5600 requestBody:
5601 required: true
5602 content:
5603 multipart/form-data:
5604 schema:
5605 $ref: "#/components/schemas/CreateFileRequest"
5606 responses:
5607 "200":
5608 description: OK
5609 content:
5610 application/json:
5611 schema:
5612 $ref: "#/components/schemas/OpenAIFile"
5613 x-oaiMeta:
5614 name: Upload file
5615 group: files
5616 returns: The uploaded [File](/docs/api-reference/files/object) object.
5617 examples:
5618 request:
5619 curl: |
5620 curl https://api.openai.com/v1/files \
5621 -H "Authorization: Bearer $OPENAI_API_KEY" \
5622 -F purpose="fine-tune" \
5623 -F file="@mydata.jsonl"
5624 python: |
5625 from openai import OpenAI
5626 client = OpenAI()
5627
5628 client.files.create(
5629 file=open("mydata.jsonl", "rb"),
5630 purpose="fine-tune"
5631 )
5632 node.js: |-
5633 import fs from "fs";
5634 import OpenAI from "openai";
5635
5636 const openai = new OpenAI();
5637
5638 async function main() {
5639 const file = await openai.files.create({
5640 file: fs.createReadStream("mydata.jsonl"),
5641 purpose: "fine-tune",
5642 });
5643
5644 console.log(file);
5645 }
5646
5647 main();
5648 response: |
5649 {
5650 "id": "file-abc123",
5651 "object": "file",
5652 "bytes": 120000,
5653 "created_at": 1677610602,
5654 "filename": "mydata.jsonl",
5655 "purpose": "fine-tune",
5656 }
5657 /files/{file_id}:
5658 delete:
5659 operationId: deleteFile
5660 tags:
5661 - Files
5662 summary: Delete a file.
5663 parameters:
5664 - in: path
5665 name: file_id
5666 required: true
5667 schema:
5668 type: string
5669 description: The ID of the file to use for this request.
5670 responses:
5671 "200":
5672 description: OK
5673 content:
5674 application/json:
5675 schema:
5676 $ref: "#/components/schemas/DeleteFileResponse"
5677 x-oaiMeta:
5678 name: Delete file
5679 group: files
5680 returns: Deletion status.
5681 examples:
5682 request:
5683 curl: |
5684 curl https://api.openai.com/v1/files/file-abc123 \
5685 -X DELETE \
5686 -H "Authorization: Bearer $OPENAI_API_KEY"
5687 python: |
5688 from openai import OpenAI
5689 client = OpenAI()
5690
5691 client.files.delete("file-abc123")
5692 node.js: |-
5693 import OpenAI from "openai";
5694
5695 const openai = new OpenAI();
5696
5697 async function main() {
5698 const file = await openai.files.del("file-abc123");
5699
5700 console.log(file);
5701 }
5702
5703 main();
5704 response: |
5705 {
5706 "id": "file-abc123",
5707 "object": "file",
5708 "deleted": true
5709 }
5710 get:
5711 operationId: retrieveFile
5712 tags:
5713 - Files
5714 summary: Returns information about a specific file.
5715 parameters:
5716 - in: path
5717 name: file_id
5718 required: true
5719 schema:
5720 type: string
5721 description: The ID of the file to use for this request.
5722 responses:
5723 "200":
5724 description: OK
5725 content:
5726 application/json:
5727 schema:
5728 $ref: "#/components/schemas/OpenAIFile"
5729 x-oaiMeta:
5730 name: Retrieve file
5731 group: files
5732 returns: The [File](/docs/api-reference/files/object) object matching the
5733 specified ID.
5734 examples:
5735 request:
5736 curl: |
5737 curl https://api.openai.com/v1/files/file-abc123 \
5738 -H "Authorization: Bearer $OPENAI_API_KEY"
5739 python: |
5740 from openai import OpenAI
5741 client = OpenAI()
5742
5743 client.files.retrieve("file-abc123")
5744 node.js: |-
5745 import OpenAI from "openai";
5746
5747 const openai = new OpenAI();
5748
5749 async function main() {
5750 const file = await openai.files.retrieve("file-abc123");
5751
5752 console.log(file);
5753 }
5754
5755 main();
5756 response: |
5757 {
5758 "id": "file-abc123",
5759 "object": "file",
5760 "bytes": 120000,
5761 "created_at": 1677610602,
5762 "filename": "mydata.jsonl",
5763 "purpose": "fine-tune",
5764 }
5765 /files/{file_id}/content:
5766 get:
5767 operationId: downloadFile
5768 tags:
5769 - Files
5770 summary: Returns the contents of the specified file.
5771 parameters:
5772 - in: path
5773 name: file_id
5774 required: true
5775 schema:
5776 type: string
5777 description: The ID of the file to use for this request.
5778 responses:
5779 "200":
5780 description: OK
5781 content:
5782 application/json:
5783 schema:
5784 type: string
5785 x-oaiMeta:
5786 name: Retrieve file content
5787 group: files
5788 returns: The file content.
5789 examples:
5790 request:
5791 curl: |
5792 curl https://api.openai.com/v1/files/file-abc123/content \
5793 -H "Authorization: Bearer $OPENAI_API_KEY" > file.jsonl
5794 python: |
5795 from openai import OpenAI
5796 client = OpenAI()
5797
5798 content = client.files.content("file-abc123")
5799 node.js: |
5800 import OpenAI from "openai";
5801
5802 const openai = new OpenAI();
5803
5804 async function main() {
5805 const file = await openai.files.content("file-abc123");
5806
5807 console.log(file);
5808 }
5809
5810 main();
5811 /fine_tuning/alpha/graders/run:
5812 post:
5813 operationId: runGrader
5814 tags:
5815 - Fine-tuning
5816 summary: |
5817 Run a grader.
5818 requestBody:
5819 required: true
5820 content:
5821 application/json:
5822 schema:
5823 $ref: "#/components/schemas/RunGraderRequest"
5824 responses:
5825 "200":
5826 description: OK
5827 content:
5828 application/json:
5829 schema:
5830 $ref: "#/components/schemas/RunGraderResponse"
5831 x-oaiMeta:
5832 name: Run grader
5833 beta: true
5834 group: graders
5835 returns: The results from the grader run.
5836 examples:
5837 request:
5838 curl: >
5839 curl -X POST
5840 https://api.openai.com/v1/fine_tuning/alpha/graders/run \
5841 -H "Content-Type: application/json" \
5842 -H "Authorization: Bearer $OPENAI_API_KEY" \
5843 -d '{
5844 "grader": {
5845 "type": "score_model",
5846 "name": "Example score model grader",
5847 "input": [
5848 {
5849 "role": "user",
5850 "content": "Score how close the reference answer is to the model answer. Score 1.0 if they are the same and 0.0 if they are different. Return just a floating point score\n\nReference answer: {{item.reference_answer}}\n\nModel answer: {{sample.output_text}}"
5851 }
5852 ],
5853 "model": "gpt-4o-2024-08-06",
5854 "sampling_params": {
5855 "temperature": 1,
5856 "top_p": 1,
5857 "seed": 42
5858 }
5859 },
5860 "item": {
5861 "reference_answer": "fuzzy wuzzy was a bear"
5862 },
5863 "model_sample": "fuzzy wuzzy was a bear"
5864 }'
5865 response: |
5866 {
5867 "reward": 1.0,
5868 "metadata": {
5869 "name": "Example score model grader",
5870 "type": "score_model",
5871 "errors": {
5872 "formula_parse_error": false,
5873 "sample_parse_error": false,
5874 "truncated_observation_error": false,
5875 "unresponsive_reward_error": false,
5876 "invalid_variable_error": false,
5877 "other_error": false,
5878 "python_grader_server_error": false,
5879 "python_grader_server_error_type": null,
5880 "python_grader_runtime_error": false,
5881 "python_grader_runtime_error_details": null,
5882 "model_grader_server_error": false,
5883 "model_grader_refusal_error": false,
5884 "model_grader_parse_error": false,
5885 "model_grader_server_error_details": null
5886 },
5887 "execution_time": 4.365238428115845,
5888 "scores": {},
5889 "token_usage": {
5890 "prompt_tokens": 190,
5891 "total_tokens": 324,
5892 "completion_tokens": 134,
5893 "cached_tokens": 0
5894 },
5895 "sampled_model_name": "gpt-4o-2024-08-06"
5896 },
5897 "sub_rewards": {},
5898 "model_grader_token_usage_per_model": {
5899 "gpt-4o-2024-08-06": {
5900 "prompt_tokens": 190,
5901 "total_tokens": 324,
5902 "completion_tokens": 134,
5903 "cached_tokens": 0
5904 }
5905 }
5906 }
5907 /fine_tuning/alpha/graders/validate:
5908 post:
5909 operationId: validateGrader
5910 tags:
5911 - Fine-tuning
5912 summary: |
5913 Validate a grader.
5914 requestBody:
5915 required: true
5916 content:
5917 application/json:
5918 schema:
5919 $ref: "#/components/schemas/ValidateGraderRequest"
5920 responses:
5921 "200":
5922 description: OK
5923 content:
5924 application/json:
5925 schema:
5926 $ref: "#/components/schemas/ValidateGraderResponse"
5927 x-oaiMeta:
5928 name: Validate grader
5929 beta: true
5930 group: graders
5931 returns: The validated grader object.
5932 examples:
5933 request:
5934 curl: >
5935 curl https://api.openai.com/v1/fine_tuning/alpha/graders/validate
5936 \
5937 -H "Authorization: Bearer $OPENAI_API_KEY" \
5938 -H "Content-Type: application/json" \
5939 -d '{
5940 "grader": {
5941 "type": "string_check",
5942 "name": "Example string check grader",
5943 "input": "{{sample.output_text}}",
5944 "reference": "{{item.label}}",
5945 "operation": "eq"
5946 }
5947 }'
5948 response: |
5949 {
5950 "grader": {
5951 "type": "string_check",
5952 "name": "Example string check grader",
5953 "input": "{{sample.output_text}}",
5954 "reference": "{{item.label}}",
5955 "operation": "eq"
5956 }
5957 }
5958 /fine_tuning/checkpoints/{fine_tuned_model_checkpoint}/permissions:
5959 get:
5960 operationId: listFineTuningCheckpointPermissions
5961 tags:
5962 - Fine-tuning
5963 summary: >
5964 **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
5965
5966
5967 Organization owners can use this endpoint to view all permissions for a
5968 fine-tuned model checkpoint.
5969 parameters:
5970 - in: path
5971 name: fine_tuned_model_checkpoint
5972 required: true
5973 schema:
5974 type: string
5975 example: ft-AF1WoRqd3aJAHsqc9NY7iL8F
5976 description: |
5977 The ID of the fine-tuned model checkpoint to get permissions for.
5978 - name: project_id
5979 in: query
5980 description: The ID of the project to get permissions for.
5981 required: false
5982 schema:
5983 type: string
5984 - name: after
5985 in: query
5986 description: Identifier for the last permission ID from the previous pagination
5987 request.
5988 required: false
5989 schema:
5990 type: string
5991 - name: limit
5992 in: query
5993 description: Number of permissions to retrieve.
5994 required: false
5995 schema:
5996 type: integer
5997 default: 10
5998 - name: order
5999 in: query
6000 description: The order in which to retrieve permissions.
6001 required: false
6002 schema:
6003 type: string
6004 enum:
6005 - ascending
6006 - descending
6007 default: descending
6008 responses:
6009 "200":
6010 description: OK
6011 content:
6012 application/json:
6013 schema:
6014 $ref: "#/components/schemas/ListFineTuningCheckpointPermissionResponse"
6015 x-oaiMeta:
6016 name: List checkpoint permissions
6017 group: fine-tuning
6018 returns: A list of fine-tuned model checkpoint [permission
6019 objects](/docs/api-reference/fine-tuning/permission-object) for a
6020 fine-tuned model checkpoint.
6021 examples:
6022 request:
6023 curl: |
6024 curl https://api.openai.com/v1/fine_tuning/checkpoints/ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd/permissions \
6025 -H "Authorization: Bearer $OPENAI_API_KEY"
6026 response: |
6027 {
6028 "object": "list",
6029 "data": [
6030 {
6031 "object": "checkpoint.permission",
6032 "id": "cp_zc4Q7MP6XxulcVzj4MZdwsAB",
6033 "created_at": 1721764867,
6034 "project_id": "proj_abGMw1llN8IrBb6SvvY5A1iH"
6035 },
6036 {
6037 "object": "checkpoint.permission",
6038 "id": "cp_enQCFmOTGj3syEpYVhBRLTSy",
6039 "created_at": 1721764800,
6040 "project_id": "proj_iqGMw1llN8IrBb6SvvY5A1oF"
6041 },
6042 ],
6043 "first_id": "cp_zc4Q7MP6XxulcVzj4MZdwsAB",
6044 "last_id": "cp_enQCFmOTGj3syEpYVhBRLTSy",
6045 "has_more": false
6046 }
6047 post:
6048 operationId: createFineTuningCheckpointPermission
6049 tags:
6050 - Fine-tuning
6051 summary: >
6052 **NOTE:** Calling this endpoint requires an [admin API
6053 key](../admin-api-keys).
6054
6055
6056 This enables organization owners to share fine-tuned models with other
6057 projects in their organization.
6058 parameters:
6059 - in: path
6060 name: fine_tuned_model_checkpoint
6061 required: true
6062 schema:
6063 type: string
6064 example: ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd
6065 description: >
6066 The ID of the fine-tuned model checkpoint to create a permission for.
6067 requestBody:
6068 required: true
6069 content:
6070 application/json:
6071 schema:
6072 $ref: "#/components/schemas/CreateFineTuningCheckpointPermissionRequest"
6073 responses:
6074 "200":
6075 description: OK
6076 content:
6077 application/json:
6078 schema:
6079 $ref: "#/components/schemas/ListFineTuningCheckpointPermissionResponse"
6080 x-oaiMeta:
6081 name: Create checkpoint permissions
6082 group: fine-tuning
6083 returns: A list of fine-tuned model checkpoint [permission
6084 objects](/docs/api-reference/fine-tuning/permission-object) for a
6085 fine-tuned model checkpoint.
6086 examples:
6087 request:
6088 curl: |
6089 curl https://api.openai.com/v1/fine_tuning/checkpoints/ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd/permissions \
6090 -H "Authorization: Bearer $OPENAI_API_KEY"
6091 -d '{"project_ids": ["proj_abGMw1llN8IrBb6SvvY5A1iH"]}'
6092 response: |
6093 {
6094 "object": "list",
6095 "data": [
6096 {
6097 "object": "checkpoint.permission",
6098 "id": "cp_zc4Q7MP6XxulcVzj4MZdwsAB",
6099 "created_at": 1721764867,
6100 "project_id": "proj_abGMw1llN8IrBb6SvvY5A1iH"
6101 }
6102 ],
6103 "first_id": "cp_zc4Q7MP6XxulcVzj4MZdwsAB",
6104 "last_id": "cp_zc4Q7MP6XxulcVzj4MZdwsAB",
6105 "has_more": false
6106 }
6107 /fine_tuning/checkpoints/{fine_tuned_model_checkpoint}/permissions/{permission_id}:
6108 delete:
6109 operationId: deleteFineTuningCheckpointPermission
6110 tags:
6111 - Fine-tuning
6112 summary: >
6113 **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
6114
6115
6116 Organization owners can use this endpoint to delete a permission for a
6117 fine-tuned model checkpoint.
6118 parameters:
6119 - in: path
6120 name: fine_tuned_model_checkpoint
6121 required: true
6122 schema:
6123 type: string
6124 example: ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd
6125 description: >
6126 The ID of the fine-tuned model checkpoint to delete a permission for.
6127 - in: path
6128 name: permission_id
6129 required: true
6130 schema:
6131 type: string
6132 example: cp_zc4Q7MP6XxulcVzj4MZdwsAB
6133 description: |
6134 The ID of the fine-tuned model checkpoint permission to delete.
6135 responses:
6136 "200":
6137 description: OK
6138 content:
6139 application/json:
6140 schema:
6141 $ref: "#/components/schemas/DeleteFineTuningCheckpointPermissionResponse"
6142 x-oaiMeta:
6143 name: Delete checkpoint permission
6144 group: fine-tuning
6145 returns: The deletion status of the fine-tuned model checkpoint [permission
6146 object](/docs/api-reference/fine-tuning/permission-object).
6147 examples:
6148 request:
6149 curl: |
6150 curl https://api.openai.com/v1/fine_tuning/checkpoints/ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd/permissions/cp_zc4Q7MP6XxulcVzj4MZdwsAB \
6151 -H "Authorization: Bearer $OPENAI_API_KEY"
6152 response: |
6153 {
6154 "object": "checkpoint.permission",
6155 "id": "cp_zc4Q7MP6XxulcVzj4MZdwsAB",
6156 "deleted": true
6157 }
6158 /fine_tuning/jobs:
6159 post:
6160 operationId: createFineTuningJob
6161 tags:
6162 - Fine-tuning
6163 summary: >
6164 Creates a fine-tuning job which begins the process of creating a new
6165 model from a given dataset.
6166
6167
6168 Response includes details of the enqueued job including job status and
6169 the name of the fine-tuned models once complete.
6170
6171
6172 [Learn more about fine-tuning](/docs/guides/model-optimization)
6173 requestBody:
6174 required: true
6175 content:
6176 application/json:
6177 schema:
6178 $ref: "#/components/schemas/CreateFineTuningJobRequest"
6179 responses:
6180 "200":
6181 description: OK
6182 content:
6183 application/json:
6184 schema:
6185 $ref: "#/components/schemas/FineTuningJob"
6186 x-oaiMeta:
6187 name: Create fine-tuning job
6188 group: fine-tuning
6189 returns: A [fine-tuning.job](/docs/api-reference/fine-tuning/object) object.
6190 examples:
6191 - title: Default
6192 request:
6193 curl: |
6194 curl https://api.openai.com/v1/fine_tuning/jobs \
6195 -H "Content-Type: application/json" \
6196 -H "Authorization: Bearer $OPENAI_API_KEY" \
6197 -d '{
6198 "training_file": "file-BK7bzQj3FfZFXr7DbL6xJwfo",
6199 "model": "gpt-4o-mini"
6200 }'
6201 python: |
6202 from openai import OpenAI
6203 client = OpenAI()
6204
6205 client.fine_tuning.jobs.create(
6206 training_file="file-abc123",
6207 model="gpt-4o-mini"
6208 )
6209 node.js: |
6210 import OpenAI from "openai";
6211
6212 const openai = new OpenAI();
6213
6214 async function main() {
6215 const fineTune = await openai.fineTuning.jobs.create({
6216 training_file: "file-abc123"
6217 });
6218
6219 console.log(fineTune);
6220 }
6221
6222 main();
6223 response: |
6224 {
6225 "object": "fine_tuning.job",
6226 "id": "ftjob-abc123",
6227 "model": "gpt-4o-mini-2024-07-18",
6228 "created_at": 1721764800,
6229 "fine_tuned_model": null,
6230 "organization_id": "org-123",
6231 "result_files": [],
6232 "status": "queued",
6233 "validation_file": null,
6234 "training_file": "file-abc123",
6235 "method": {
6236 "type": "supervised",
6237 "supervised": {
6238 "hyperparameters": {
6239 "batch_size": "auto",
6240 "learning_rate_multiplier": "auto",
6241 "n_epochs": "auto",
6242 }
6243 }
6244 },
6245 "metadata": null
6246 }
6247 - title: Epochs
6248 request:
6249 curl: |
6250 curl https://api.openai.com/v1/fine_tuning/jobs \
6251 -H "Content-Type: application/json" \
6252 -H "Authorization: Bearer $OPENAI_API_KEY" \
6253 -d '{
6254 "training_file": "file-abc123",
6255 "model": "gpt-4o-mini",
6256 "method": {
6257 "type": "supervised",
6258 "supervised": {
6259 "hyperparameters": {
6260 "n_epochs": 2
6261 }
6262 }
6263 }
6264 }'
6265 python: >
6266 from openai import OpenAI
6267
6268 from openai.types.fine_tuning import SupervisedMethod,
6269 SupervisedHyperparameters
6270
6271
6272 client = OpenAI()
6273
6274
6275 client.fine_tuning.jobs.create(
6276 training_file="file-abc123",
6277 model="gpt-4o-mini",
6278 method={
6279 "type": "supervised",
6280 "supervised": SupervisedMethod(
6281 hyperparameters=SupervisedHyperparameters(
6282 n_epochs=2
6283 )
6284 )
6285 }
6286 )
6287 node.js: >
6288 import OpenAI from "openai";
6289
6290 import { SupervisedMethod, SupervisedHyperparameters } from
6291 "openai/src/resources/fine-tuning/methods";
6292
6293
6294 const openai = new OpenAI();
6295
6296
6297 async function main() {
6298 const fineTune = await openai.fineTuning.jobs.create({
6299 training_file: "file-abc123",
6300 model: "gpt-4o-mini",
6301 method: {
6302 type: "supervised",
6303 supervised: {
6304 hyperparameters: {
6305 n_epochs: 2
6306 }
6307 }
6308 }
6309 });
6310
6311 console.log(fineTune);
6312 }
6313
6314
6315 main();
6316 response: |
6317 {
6318 "object": "fine_tuning.job",
6319 "id": "ftjob-abc123",
6320 "model": "gpt-4o-mini",
6321 "created_at": 1721764800,
6322 "fine_tuned_model": null,
6323 "organization_id": "org-123",
6324 "result_files": [],
6325 "status": "queued",
6326 "validation_file": null,
6327 "training_file": "file-abc123",
6328 "hyperparameters": {
6329 "batch_size": "auto",
6330 "learning_rate_multiplier": "auto",
6331 "n_epochs": 2
6332 },
6333 "method": {
6334 "type": "supervised",
6335 "supervised": {
6336 "hyperparameters": {
6337 "batch_size": "auto",
6338 "learning_rate_multiplier": "auto",
6339 "n_epochs": 2
6340 }
6341 }
6342 },
6343 "metadata": null,
6344 "error": {
6345 "code": null,
6346 "message": null,
6347 "param": null
6348 },
6349 "finished_at": null,
6350 "seed": 683058546,
6351 "trained_tokens": null,
6352 "estimated_finish": null,
6353 "integrations": [],
6354 "user_provided_suffix": null,
6355 "usage_metrics": null,
6356 "shared_with_openai": false
6357 }
6358 - title: DPO
6359 request:
6360 curl: |
6361 curl https://api.openai.com/v1/fine_tuning/jobs \
6362 -H "Content-Type: application/json" \
6363 -H "Authorization: Bearer $OPENAI_API_KEY" \
6364 -d '{
6365 "training_file": "file-abc123",
6366 "validation_file": "file-abc123",
6367 "model": "gpt-4o-mini",
6368 "method": {
6369 "type": "dpo",
6370 "dpo": {
6371 "hyperparameters": {
6372 "beta": 0.1
6373 }
6374 }
6375 }
6376 }'
6377 python: |
6378 from openai import OpenAI
6379 from openai.types.fine_tuning import DpoMethod, DpoHyperparameters
6380
6381 client = OpenAI()
6382
6383 client.fine_tuning.jobs.create(
6384 training_file="file-abc",
6385 validation_file="file-123",
6386 model="gpt-4o-mini",
6387 method={
6388 "type": "dpo",
6389 "dpo": DpoMethod(
6390 hyperparameters=DpoHyperparameters(beta=0.1)
6391 )
6392 }
6393 )
6394 response: |
6395 {
6396 "object": "fine_tuning.job",
6397 "id": "ftjob-abc",
6398 "model": "gpt-4o-mini",
6399 "created_at": 1746130590,
6400 "fine_tuned_model": null,
6401 "organization_id": "org-abc",
6402 "result_files": [],
6403 "status": "queued",
6404 "validation_file": "file-123",
6405 "training_file": "file-abc",
6406 "method": {
6407 "type": "dpo",
6408 "dpo": {
6409 "hyperparameters": {
6410 "beta": 0.1,
6411 "batch_size": "auto",
6412 "learning_rate_multiplier": "auto",
6413 "n_epochs": "auto"
6414 }
6415 }
6416 },
6417 "metadata": null,
6418 "error": {
6419 "code": null,
6420 "message": null,
6421 "param": null
6422 },
6423 "finished_at": null,
6424 "hyperparameters": null,
6425 "seed": 1036326793,
6426 "estimated_finish": null,
6427 "integrations": [],
6428 "user_provided_suffix": null,
6429 "usage_metrics": null,
6430 "shared_with_openai": false
6431 }
6432 - title: Reinforcement
6433 request:
6434 curl: |
6435 curl https://api.openai.com/v1/fine_tuning/jobs \
6436 -H "Content-Type: application/json" \
6437 -H "Authorization: Bearer $OPENAI_API_KEY" \
6438 -d '{
6439 "training_file": "file-abc",
6440 "validation_file": "file-123",
6441 "model": "o4-mini",
6442 "method": {
6443 "type": "reinforcement",
6444 "reinforcement": {
6445 "grader": {
6446 "type": "string_check",
6447 "name": "Example string check grader",
6448 "input": "{{sample.output_text}}",
6449 "reference": "{{item.label}}",
6450 "operation": "eq"
6451 },
6452 "hyperparameters": {
6453 "reasoning_effort": "medium"
6454 }
6455 }
6456 }
6457 }'
6458 python: >
6459 from openai import OpenAI
6460
6461 from openai.types.fine_tuning import ReinforcementMethod,
6462 ReinforcementHyperparameters
6463
6464 from openai.types.graders import StringCheckGrader
6465
6466
6467 client = OpenAI()
6468
6469
6470 client.fine_tuning.jobs.create(
6471 training_file="file-abc",
6472 validation_file="file-123",
6473 model="o4-mini",
6474 method={
6475 "type": "reinforcement",
6476 "reinforcement": ReinforcementMethod(
6477 grader=StringCheckGrader(
6478 name="Example string check grader",
6479 type="string_check",
6480 input="{{item.label}}",
6481 operation="eq",
6482 reference="{{sample.output_text}}"
6483 ),
6484 hyperparameters=ReinforcementHyperparameters(
6485 reasoning_effort="medium",
6486 )
6487 )
6488 },
6489 seed=42,
6490 )
6491 response: |+
6492 {
6493 "object": "fine_tuning.job",
6494 "id": "ftjob-abc123",
6495 "model": "o4-mini",
6496 "created_at": 1721764800,
6497 "finished_at": null,
6498 "fine_tuned_model": null,
6499 "organization_id": "org-123",
6500 "result_files": [],
6501 "status": "validating_files",
6502 "validation_file": "file-123",
6503 "training_file": "file-abc",
6504 "trained_tokens": null,
6505 "error": {},
6506 "user_provided_suffix": null,
6507 "seed": 950189191,
6508 "estimated_finish": null,
6509 "integrations": [],
6510 "method": {
6511 "type": "reinforcement",
6512 "reinforcement": {
6513 "hyperparameters": {
6514 "batch_size": "auto",
6515 "learning_rate_multiplier": "auto",
6516 "n_epochs": "auto",
6517 "eval_interval": "auto",
6518 "eval_samples": "auto",
6519 "compute_multiplier": "auto",
6520 "reasoning_effort": "medium"
6521 },
6522 "grader": {
6523 "type": "string_check",
6524 "name": "Example string check grader",
6525 "input": "{{sample.output_text}}",
6526 "reference": "{{item.label}}",
6527 "operation": "eq"
6528 },
6529 "response_format": null
6530 }
6531 },
6532 "metadata": null,
6533 "usage_metrics": null,
6534 "shared_with_openai": false
6535 }
6536
6537 - title: Validation file
6538 request:
6539 curl: |
6540 curl https://api.openai.com/v1/fine_tuning/jobs \
6541 -H "Content-Type: application/json" \
6542 -H "Authorization: Bearer $OPENAI_API_KEY" \
6543 -d '{
6544 "training_file": "file-abc123",
6545 "validation_file": "file-abc123",
6546 "model": "gpt-4o-mini"
6547 }'
6548 python: |
6549 from openai import OpenAI
6550 client = OpenAI()
6551
6552 client.fine_tuning.jobs.create(
6553 training_file="file-abc123",
6554 validation_file="file-def456",
6555 model="gpt-4o-mini"
6556 )
6557 node.js: |
6558 import OpenAI from "openai";
6559
6560 const openai = new OpenAI();
6561
6562 async function main() {
6563 const fineTune = await openai.fineTuning.jobs.create({
6564 training_file: "file-abc123",
6565 validation_file: "file-abc123"
6566 });
6567
6568 console.log(fineTune);
6569 }
6570
6571 main();
6572 response: |
6573 {
6574 "object": "fine_tuning.job",
6575 "id": "ftjob-abc123",
6576 "model": "gpt-4o-mini-2024-07-18",
6577 "created_at": 1721764800,
6578 "fine_tuned_model": null,
6579 "organization_id": "org-123",
6580 "result_files": [],
6581 "status": "queued",
6582 "validation_file": "file-abc123",
6583 "training_file": "file-abc123",
6584 "method": {
6585 "type": "supervised",
6586 "supervised": {
6587 "hyperparameters": {
6588 "batch_size": "auto",
6589 "learning_rate_multiplier": "auto",
6590 "n_epochs": "auto",
6591 }
6592 }
6593 },
6594 "metadata": null
6595 }
6596 - title: W&B Integration
6597 request:
6598 curl: |
6599 curl https://api.openai.com/v1/fine_tuning/jobs \
6600 -H "Content-Type: application/json" \
6601 -H "Authorization: Bearer $OPENAI_API_KEY" \
6602 -d '{
6603 "training_file": "file-abc123",
6604 "validation_file": "file-abc123",
6605 "model": "gpt-4o-mini",
6606 "integrations": [
6607 {
6608 "type": "wandb",
6609 "wandb": {
6610 "project": "my-wandb-project",
6611 "name": "ft-run-display-name"
6612 "tags": [
6613 "first-experiment", "v2"
6614 ]
6615 }
6616 }
6617 ]
6618 }'
6619 response: |
6620 {
6621 "object": "fine_tuning.job",
6622 "id": "ftjob-abc123",
6623 "model": "gpt-4o-mini-2024-07-18",
6624 "created_at": 1721764800,
6625 "fine_tuned_model": null,
6626 "organization_id": "org-123",
6627 "result_files": [],
6628 "status": "queued",
6629 "validation_file": "file-abc123",
6630 "training_file": "file-abc123",
6631 "integrations": [
6632 {
6633 "type": "wandb",
6634 "wandb": {
6635 "project": "my-wandb-project",
6636 "entity": None,
6637 "run_id": "ftjob-abc123"
6638 }
6639 }
6640 ],
6641 "method": {
6642 "type": "supervised",
6643 "supervised": {
6644 "hyperparameters": {
6645 "batch_size": "auto",
6646 "learning_rate_multiplier": "auto",
6647 "n_epochs": "auto",
6648 }
6649 }
6650 },
6651 "metadata": null
6652 }
6653 get:
6654 operationId: listPaginatedFineTuningJobs
6655 tags:
6656 - Fine-tuning
6657 summary: |
6658 List your organization's fine-tuning jobs
6659 parameters:
6660 - name: after
6661 in: query
6662 description: Identifier for the last job from the previous pagination request.
6663 required: false
6664 schema:
6665 type: string
6666 - name: limit
6667 in: query
6668 description: Number of fine-tuning jobs to retrieve.
6669 required: false
6670 schema:
6671 type: integer
6672 default: 20
6673 - in: query
6674 name: metadata
6675 required: false
6676 schema:
6677 type: object
6678 nullable: true
6679 additionalProperties:
6680 type: string
6681 style: deepObject
6682 explode: true
6683 description: >
6684 Optional metadata filter. To filter, use the syntax `metadata[k]=v`.
6685 Alternatively, set `metadata=null` to indicate no metadata.
6686 responses:
6687 "200":
6688 description: OK
6689 content:
6690 application/json:
6691 schema:
6692 $ref: "#/components/schemas/ListPaginatedFineTuningJobsResponse"
6693 x-oaiMeta:
6694 name: List fine-tuning jobs
6695 group: fine-tuning
6696 returns: A list of paginated [fine-tuning
6697 job](/docs/api-reference/fine-tuning/object) objects.
6698 examples:
6699 request:
6700 curl: |
6701 curl https://api.openai.com/v1/fine_tuning/jobs?limit=2&metadata[key]=value \
6702 -H "Authorization: Bearer $OPENAI_API_KEY"
6703 python: |
6704 from openai import OpenAI
6705 client = OpenAI()
6706
6707 client.fine_tuning.jobs.list()
6708 node.js: |-
6709 import OpenAI from "openai";
6710
6711 const openai = new OpenAI();
6712
6713 async function main() {
6714 const list = await openai.fineTuning.jobs.list();
6715
6716 for await (const fineTune of list) {
6717 console.log(fineTune);
6718 }
6719 }
6720
6721 main();
6722 response: |
6723 {
6724 "object": "list",
6725 "data": [
6726 {
6727 "object": "fine_tuning.job",
6728 "id": "ftjob-abc123",
6729 "model": "gpt-4o-mini-2024-07-18",
6730 "created_at": 1721764800,
6731 "fine_tuned_model": null,
6732 "organization_id": "org-123",
6733 "result_files": [],
6734 "status": "queued",
6735 "validation_file": null,
6736 "training_file": "file-abc123",
6737 "metadata": {
6738 "key": "value"
6739 }
6740 },
6741 { ... },
6742 { ... }
6743 ], "has_more": true
6744 }
6745 /fine_tuning/jobs/{fine_tuning_job_id}:
6746 get:
6747 operationId: retrieveFineTuningJob
6748 tags:
6749 - Fine-tuning
6750 summary: |
6751 Get info about a fine-tuning job.
6752
6753 [Learn more about fine-tuning](/docs/guides/model-optimization)
6754 parameters:
6755 - in: path
6756 name: fine_tuning_job_id
6757 required: true
6758 schema:
6759 type: string
6760 example: ft-AF1WoRqd3aJAHsqc9NY7iL8F
6761 description: |
6762 The ID of the fine-tuning job.
6763 responses:
6764 "200":
6765 description: OK
6766 content:
6767 application/json:
6768 schema:
6769 $ref: "#/components/schemas/FineTuningJob"
6770 x-oaiMeta:
6771 name: Retrieve fine-tuning job
6772 group: fine-tuning
6773 returns: The [fine-tuning](/docs/api-reference/fine-tuning/object) object with
6774 the given ID.
6775 examples:
6776 request:
6777 curl: |
6778 curl https://api.openai.com/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \
6779 -H "Authorization: Bearer $OPENAI_API_KEY"
6780 python: |
6781 from openai import OpenAI
6782 client = OpenAI()
6783
6784 client.fine_tuning.jobs.retrieve("ftjob-abc123")
6785 node.js: >
6786 import OpenAI from "openai";
6787
6788
6789 const openai = new OpenAI();
6790
6791
6792 async function main() {
6793 const fineTune = await openai.fineTuning.jobs.retrieve("ftjob-abc123");
6794
6795 console.log(fineTune);
6796 }
6797
6798
6799 main();
6800 response: >
6801 {
6802 "object": "fine_tuning.job",
6803 "id": "ftjob-abc123",
6804 "model": "davinci-002",
6805 "created_at": 1692661014,
6806 "finished_at": 1692661190,
6807 "fine_tuned_model": "ft:davinci-002:my-org:custom_suffix:7q8mpxmy",
6808 "organization_id": "org-123",
6809 "result_files": [
6810 "file-abc123"
6811 ],
6812 "status": "succeeded",
6813 "validation_file": null,
6814 "training_file": "file-abc123",
6815 "hyperparameters": {
6816 "n_epochs": 4,
6817 "batch_size": 1,
6818 "learning_rate_multiplier": 1.0
6819 },
6820 "trained_tokens": 5768,
6821 "integrations": [],
6822 "seed": 0,
6823 "estimated_finish": 0,
6824 "method": {
6825 "type": "supervised",
6826 "supervised": {
6827 "hyperparameters": {
6828 "n_epochs": 4,
6829 "batch_size": 1,
6830 "learning_rate_multiplier": 1.0
6831 }
6832 }
6833 }
6834 }
6835 /fine_tuning/jobs/{fine_tuning_job_id}/cancel:
6836 post:
6837 operationId: cancelFineTuningJob
6838 tags:
6839 - Fine-tuning
6840 summary: |
6841 Immediately cancel a fine-tune job.
6842 parameters:
6843 - in: path
6844 name: fine_tuning_job_id
6845 required: true
6846 schema:
6847 type: string
6848 example: ft-AF1WoRqd3aJAHsqc9NY7iL8F
6849 description: |
6850 The ID of the fine-tuning job to cancel.
6851 responses:
6852 "200":
6853 description: OK
6854 content:
6855 application/json:
6856 schema:
6857 $ref: "#/components/schemas/FineTuningJob"
6858 x-oaiMeta:
6859 name: Cancel fine-tuning
6860 group: fine-tuning
6861 returns: The cancelled [fine-tuning](/docs/api-reference/fine-tuning/object)
6862 object.
6863 examples:
6864 request:
6865 curl: >
6866 curl -X POST
6867 https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/cancel \
6868 -H "Authorization: Bearer $OPENAI_API_KEY"
6869 python: |
6870 from openai import OpenAI
6871 client = OpenAI()
6872
6873 client.fine_tuning.jobs.cancel("ftjob-abc123")
6874 node.js: >-
6875 import OpenAI from "openai";
6876
6877
6878 const openai = new OpenAI();
6879
6880
6881 async function main() {
6882 const fineTune = await openai.fineTuning.jobs.cancel("ftjob-abc123");
6883
6884 console.log(fineTune);
6885 }
6886
6887 main();
6888 response: |
6889 {
6890 "object": "fine_tuning.job",
6891 "id": "ftjob-abc123",
6892 "model": "gpt-4o-mini-2024-07-18",
6893 "created_at": 1721764800,
6894 "fine_tuned_model": null,
6895 "organization_id": "org-123",
6896 "result_files": [],
6897 "status": "cancelled",
6898 "validation_file": "file-abc123",
6899 "training_file": "file-abc123"
6900 }
6901 /fine_tuning/jobs/{fine_tuning_job_id}/checkpoints:
6902 get:
6903 operationId: listFineTuningJobCheckpoints
6904 tags:
6905 - Fine-tuning
6906 summary: |
6907 List checkpoints for a fine-tuning job.
6908 parameters:
6909 - in: path
6910 name: fine_tuning_job_id
6911 required: true
6912 schema:
6913 type: string
6914 example: ft-AF1WoRqd3aJAHsqc9NY7iL8F
6915 description: |
6916 The ID of the fine-tuning job to get checkpoints for.
6917 - name: after
6918 in: query
6919 description: Identifier for the last checkpoint ID from the previous pagination
6920 request.
6921 required: false
6922 schema:
6923 type: string
6924 - name: limit
6925 in: query
6926 description: Number of checkpoints to retrieve.
6927 required: false
6928 schema:
6929 type: integer
6930 default: 10
6931 responses:
6932 "200":
6933 description: OK
6934 content:
6935 application/json:
6936 schema:
6937 $ref: "#/components/schemas/ListFineTuningJobCheckpointsResponse"
6938 x-oaiMeta:
6939 name: List fine-tuning checkpoints
6940 group: fine-tuning
6941 returns: A list of fine-tuning [checkpoint
6942 objects](/docs/api-reference/fine-tuning/checkpoint-object) for a
6943 fine-tuning job.
6944 examples:
6945 request:
6946 curl: |
6947 curl https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/checkpoints \
6948 -H "Authorization: Bearer $OPENAI_API_KEY"
6949 response: >
6950 {
6951 "object": "list"
6952 "data": [
6953 {
6954 "object": "fine_tuning.job.checkpoint",
6955 "id": "ftckpt_zc4Q7MP6XxulcVzj4MZdwsAB",
6956 "created_at": 1721764867,
6957 "fine_tuned_model_checkpoint": "ft:gpt-4o-mini-2024-07-18:my-org:custom-suffix:96olL566:ckpt-step-2000",
6958 "metrics": {
6959 "full_valid_loss": 0.134,
6960 "full_valid_mean_token_accuracy": 0.874
6961 },
6962 "fine_tuning_job_id": "ftjob-abc123",
6963 "step_number": 2000,
6964 },
6965 {
6966 "object": "fine_tuning.job.checkpoint",
6967 "id": "ftckpt_enQCFmOTGj3syEpYVhBRLTSy",
6968 "created_at": 1721764800,
6969 "fine_tuned_model_checkpoint": "ft:gpt-4o-mini-2024-07-18:my-org:custom-suffix:7q8mpxmy:ckpt-step-1000",
6970 "metrics": {
6971 "full_valid_loss": 0.167,
6972 "full_valid_mean_token_accuracy": 0.781
6973 },
6974 "fine_tuning_job_id": "ftjob-abc123",
6975 "step_number": 1000,
6976 },
6977 ],
6978 "first_id": "ftckpt_zc4Q7MP6XxulcVzj4MZdwsAB",
6979 "last_id": "ftckpt_enQCFmOTGj3syEpYVhBRLTSy",
6980 "has_more": true
6981 }
6982 /fine_tuning/jobs/{fine_tuning_job_id}/events:
6983 get:
6984 operationId: listFineTuningEvents
6985 tags:
6986 - Fine-tuning
6987 summary: |
6988 Get status updates for a fine-tuning job.
6989 parameters:
6990 - in: path
6991 name: fine_tuning_job_id
6992 required: true
6993 schema:
6994 type: string
6995 example: ft-AF1WoRqd3aJAHsqc9NY7iL8F
6996 description: |
6997 The ID of the fine-tuning job to get events for.
6998 - name: after
6999 in: query
7000 description: Identifier for the last event from the previous pagination request.
7001 required: false
7002 schema:
7003 type: string
7004 - name: limit
7005 in: query
7006 description: Number of events to retrieve.
7007 required: false
7008 schema:
7009 type: integer
7010 default: 20
7011 responses:
7012 "200":
7013 description: OK
7014 content:
7015 application/json:
7016 schema:
7017 $ref: "#/components/schemas/ListFineTuningJobEventsResponse"
7018 x-oaiMeta:
7019 name: List fine-tuning events
7020 group: fine-tuning
7021 returns: A list of fine-tuning event objects.
7022 examples:
7023 request:
7024 curl: >
7025 curl
7026 https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/events \
7027 -H "Authorization: Bearer $OPENAI_API_KEY"
7028 python: |
7029 from openai import OpenAI
7030 client = OpenAI()
7031
7032 client.fine_tuning.jobs.list_events(
7033 fine_tuning_job_id="ftjob-abc123",
7034 limit=2
7035 )
7036 node.js: >-
7037 import OpenAI from "openai";
7038
7039
7040 const openai = new OpenAI();
7041
7042
7043 async function main() {
7044 const list = await openai.fineTuning.list_events(id="ftjob-abc123", limit=2);
7045
7046 for await (const fineTune of list) {
7047 console.log(fineTune);
7048 }
7049 }
7050
7051
7052 main();
7053 response: >
7054 {
7055 "object": "list",
7056 "data": [
7057 {
7058 "object": "fine_tuning.job.event",
7059 "id": "ft-event-ddTJfwuMVpfLXseO0Am0Gqjm",
7060 "created_at": 1721764800,
7061 "level": "info",
7062 "message": "Fine tuning job successfully completed",
7063 "data": null,
7064 "type": "message"
7065 },
7066 {
7067 "object": "fine_tuning.job.event",
7068 "id": "ft-event-tyiGuB72evQncpH87xe505Sv",
7069 "created_at": 1721764800,
7070 "level": "info",
7071 "message": "New fine-tuned model created: ft:gpt-4o-mini:openai::7p4lURel",
7072 "data": null,
7073 "type": "message"
7074 }
7075 ],
7076 "has_more": true
7077 }
7078 /fine_tuning/jobs/{fine_tuning_job_id}/pause:
7079 post:
7080 operationId: pauseFineTuningJob
7081 tags:
7082 - Fine-tuning
7083 summary: |
7084 Pause a fine-tune job.
7085 parameters:
7086 - in: path
7087 name: fine_tuning_job_id
7088 required: true
7089 schema:
7090 type: string
7091 example: ft-AF1WoRqd3aJAHsqc9NY7iL8F
7092 description: |
7093 The ID of the fine-tuning job to pause.
7094 responses:
7095 "200":
7096 description: OK
7097 content:
7098 application/json:
7099 schema:
7100 $ref: "#/components/schemas/FineTuningJob"
7101 x-oaiMeta:
7102 name: Pause fine-tuning
7103 group: fine-tuning
7104 returns: The paused [fine-tuning](/docs/api-reference/fine-tuning/object)
7105 object.
7106 examples:
7107 request:
7108 curl: >
7109 curl -X POST
7110 https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/pause \
7111 -H "Authorization: Bearer $OPENAI_API_KEY"
7112 python: |
7113 from openai import OpenAI
7114 client = OpenAI()
7115
7116 client.fine_tuning.jobs.pause("ftjob-abc123")
7117 node.js: >-
7118 import OpenAI from "openai";
7119
7120
7121 const openai = new OpenAI();
7122
7123
7124 async function main() {
7125 const fineTune = await openai.fineTuning.jobs.pause("ftjob-abc123");
7126
7127 console.log(fineTune);
7128 }
7129
7130 main();
7131 response: |
7132 {
7133 "object": "fine_tuning.job",
7134 "id": "ftjob-abc123",
7135 "model": "gpt-4o-mini-2024-07-18",
7136 "created_at": 1721764800,
7137 "fine_tuned_model": null,
7138 "organization_id": "org-123",
7139 "result_files": [],
7140 "status": "paused",
7141 "validation_file": "file-abc123",
7142 "training_file": "file-abc123"
7143 }
7144 /fine_tuning/jobs/{fine_tuning_job_id}/resume:
7145 post:
7146 operationId: resumeFineTuningJob
7147 tags:
7148 - Fine-tuning
7149 summary: |
7150 Resume a fine-tune job.
7151 parameters:
7152 - in: path
7153 name: fine_tuning_job_id
7154 required: true
7155 schema:
7156 type: string
7157 example: ft-AF1WoRqd3aJAHsqc9NY7iL8F
7158 description: |
7159 The ID of the fine-tuning job to resume.
7160 responses:
7161 "200":
7162 description: OK
7163 content:
7164 application/json:
7165 schema:
7166 $ref: "#/components/schemas/FineTuningJob"
7167 x-oaiMeta:
7168 name: Resume fine-tuning
7169 group: fine-tuning
7170 returns: The resumed [fine-tuning](/docs/api-reference/fine-tuning/object)
7171 object.
7172 examples:
7173 request:
7174 curl: >
7175 curl -X POST
7176 https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/resume \
7177 -H "Authorization: Bearer $OPENAI_API_KEY"
7178 python: |
7179 from openai import OpenAI
7180 client = OpenAI()
7181
7182 client.fine_tuning.jobs.resume("ftjob-abc123")
7183 node.js: >-
7184 import OpenAI from "openai";
7185
7186
7187 const openai = new OpenAI();
7188
7189
7190 async function main() {
7191 const fineTune = await openai.fineTuning.jobs.resume("ftjob-abc123");
7192
7193 console.log(fineTune);
7194 }
7195
7196 main();
7197 response: |
7198 {
7199 "object": "fine_tuning.job",
7200 "id": "ftjob-abc123",
7201 "model": "gpt-4o-mini-2024-07-18",
7202 "created_at": 1721764800,
7203 "fine_tuned_model": null,
7204 "organization_id": "org-123",
7205 "result_files": [],
7206 "status": "queued",
7207 "validation_file": "file-abc123",
7208 "training_file": "file-abc123"
7209 }
7210 /images/edits:
7211 post:
7212 operationId: createImageEdit
7213 tags:
7214 - Images
7215 summary: Creates an edited or extended image given one or more source images and
7216 a prompt. This endpoint only supports `gpt-image-1` and `dall-e-2`.
7217 requestBody:
7218 required: true
7219 content:
7220 multipart/form-data:
7221 schema:
7222 $ref: "#/components/schemas/CreateImageEditRequest"
7223 responses:
7224 "200":
7225 description: OK
7226 content:
7227 application/json:
7228 schema:
7229 $ref: "#/components/schemas/ImagesResponse"
7230 x-oaiMeta:
7231 name: Create image edit
7232 group: images
7233 returns: Returns a list of [image](/docs/api-reference/images/object) objects.
7234 examples:
7235 request:
7236 curl: >
7237 curl -s -D >(grep -i x-request-id >&2) \
7238 -o >(jq -r '.data[0].b64_json' | base64 --decode > gift-basket.png) \
7239 -X POST "https://api.openai.com/v1/images/edits" \
7240 -H "Authorization: Bearer $OPENAI_API_KEY" \
7241 -F "model=gpt-image-1" \
7242 -F "image[]=@body-lotion.png" \
7243 -F "image[]=@bath-bomb.png" \
7244 -F "image[]=@incense-kit.png" \
7245 -F "image[]=@soap.png" \
7246 -F 'prompt=Create a lovely gift basket with these four items in it'
7247 python: >
7248 import base64
7249
7250 from openai import OpenAI
7251
7252 client = OpenAI()
7253
7254
7255 prompt = """
7256
7257 Generate a photorealistic image of a gift basket on a white
7258 background
7259
7260 labeled 'Relax & Unwind' with a ribbon and handwriting-like font,
7261
7262 containing all the items in the reference pictures.
7263
7264 """
7265
7266
7267 result = client.images.edit(
7268 model="gpt-image-1",
7269 image=[
7270 open("body-lotion.png", "rb"),
7271 open("bath-bomb.png", "rb"),
7272 open("incense-kit.png", "rb"),
7273 open("soap.png", "rb"),
7274 ],
7275 prompt=prompt
7276 )
7277
7278
7279 image_base64 = result.data[0].b64_json
7280
7281 image_bytes = base64.b64decode(image_base64)
7282
7283
7284 # Save the image to a file
7285
7286 with open("gift-basket.png", "wb") as f:
7287 f.write(image_bytes)
7288 node.js: >
7289 import fs from "fs";
7290
7291 import OpenAI, { toFile } from "openai";
7292
7293
7294 const client = new OpenAI();
7295
7296
7297 const imageFiles = [
7298 "bath-bomb.png",
7299 "body-lotion.png",
7300 "incense-kit.png",
7301 "soap.png",
7302 ];
7303
7304
7305 const images = await Promise.all(
7306 imageFiles.map(async (file) =>
7307 await toFile(fs.createReadStream(file), null, {
7308 type: "image/png",
7309 })
7310 ),
7311 );
7312
7313
7314 const rsp = await client.images.edit({
7315 model: "gpt-image-1",
7316 image: images,
7317 prompt: "Create a lovely gift basket with these four items in it",
7318 });
7319
7320
7321 // Save the image to a file
7322
7323 const image_base64 = rsp.data[0].b64_json;
7324
7325 const image_bytes = Buffer.from(image_base64, "base64");
7326
7327 fs.writeFileSync("basket.png", image_bytes);
7328 response: |
7329 {
7330 "created": 1713833628,
7331 "data": [
7332 {
7333 "b64_json": "..."
7334 }
7335 ],
7336 "usage": {
7337 "total_tokens": 100,
7338 "input_tokens": 50,
7339 "output_tokens": 50,
7340 "input_tokens_details": {
7341 "text_tokens": 10,
7342 "image_tokens": 40
7343 }
7344 }
7345 }
7346 /images/generations:
7347 post:
7348 operationId: createImage
7349 tags:
7350 - Images
7351 summary: |
7352 Creates an image given a prompt. [Learn more](/docs/guides/images).
7353 requestBody:
7354 required: true
7355 content:
7356 application/json:
7357 schema:
7358 $ref: "#/components/schemas/CreateImageRequest"
7359 responses:
7360 "200":
7361 description: OK
7362 content:
7363 application/json:
7364 schema:
7365 $ref: "#/components/schemas/ImagesResponse"
7366 x-oaiMeta:
7367 name: Create image
7368 group: images
7369 returns: Returns a list of [image](/docs/api-reference/images/object) objects.
7370 examples:
7371 request:
7372 curl: |
7373 curl https://api.openai.com/v1/images/generations \
7374 -H "Content-Type: application/json" \
7375 -H "Authorization: Bearer $OPENAI_API_KEY" \
7376 -d '{
7377 "model": "gpt-image-1",
7378 "prompt": "A cute baby sea otter",
7379 "n": 1,
7380 "size": "1024x1024"
7381 }'
7382 python: |
7383 import base64
7384 from openai import OpenAI
7385 client = OpenAI()
7386
7387 img = client.images.generate(
7388 model="gpt-image-1",
7389 prompt="A cute baby sea otter",
7390 n=1,
7391 size="1024x1024"
7392 )
7393
7394 image_bytes = base64.b64decode(img.data[0].b64_json)
7395 with open("output.png", "wb") as f:
7396 f.write(image_bytes)
7397 node.js: |
7398 import OpenAI from "openai";
7399 import { writeFile } from "fs/promises";
7400
7401 const client = new OpenAI();
7402
7403 const img = await client.images.generate({
7404 model: "gpt-image-1",
7405 prompt: "A cute baby sea otter",
7406 n: 1,
7407 size: "1024x1024"
7408 });
7409
7410 const imageBuffer = Buffer.from(img.data[0].b64_json, "base64");
7411 await writeFile("output.png", imageBuffer);
7412 response: |
7413 {
7414 "created": 1713833628,
7415 "data": [
7416 {
7417 "b64_json": "..."
7418 }
7419 ],
7420 "usage": {
7421 "total_tokens": 100,
7422 "input_tokens": 50,
7423 "output_tokens": 50,
7424 "input_tokens_details": {
7425 "text_tokens": 10,
7426 "image_tokens": 40
7427 }
7428 }
7429 }
7430 /images/variations:
7431 post:
7432 operationId: createImageVariation
7433 tags:
7434 - Images
7435 summary: Creates a variation of a given image. This endpoint only supports
7436 `dall-e-2`.
7437 requestBody:
7438 required: true
7439 content:
7440 multipart/form-data:
7441 schema:
7442 $ref: "#/components/schemas/CreateImageVariationRequest"
7443 responses:
7444 "200":
7445 description: OK
7446 content:
7447 application/json:
7448 schema:
7449 $ref: "#/components/schemas/ImagesResponse"
7450 x-oaiMeta:
7451 name: Create image variation
7452 group: images
7453 returns: Returns a list of [image](/docs/api-reference/images/object) objects.
7454 examples:
7455 request:
7456 curl: |
7457 curl https://api.openai.com/v1/images/variations \
7458 -H "Authorization: Bearer $OPENAI_API_KEY" \
7459 -F image="@otter.png" \
7460 -F n=2 \
7461 -F size="1024x1024"
7462 python: |
7463 from openai import OpenAI
7464 client = OpenAI()
7465
7466 response = client.images.create_variation(
7467 image=open("image_edit_original.png", "rb"),
7468 n=2,
7469 size="1024x1024"
7470 )
7471 node.js: |-
7472 import fs from "fs";
7473 import OpenAI from "openai";
7474
7475 const openai = new OpenAI();
7476
7477 async function main() {
7478 const image = await openai.images.createVariation({
7479 image: fs.createReadStream("otter.png"),
7480 });
7481
7482 console.log(image.data);
7483 }
7484 main();
7485 csharp: >
7486 using System;
7487
7488
7489 using OpenAI.Images;
7490
7491
7492 ImageClient client = new(
7493 model: "dall-e-2",
7494 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
7495 );
7496
7497
7498 GeneratedImage image =
7499 client.GenerateImageVariation(imageFilePath: "otter.png");
7500
7501
7502 Console.WriteLine(image.ImageUri);
7503 response: |
7504 {
7505 "created": 1589478378,
7506 "data": [
7507 {
7508 "url": "https://..."
7509 },
7510 {
7511 "url": "https://..."
7512 }
7513 ]
7514 }
7515 /models:
7516 get:
7517 operationId: listModels
7518 tags:
7519 - Models
7520 summary: Lists the currently available models, and provides basic information
7521 about each one such as the owner and availability.
7522 responses:
7523 "200":
7524 description: OK
7525 content:
7526 application/json:
7527 schema:
7528 $ref: "#/components/schemas/ListModelsResponse"
7529 x-oaiMeta:
7530 name: List models
7531 group: models
7532 returns: A list of [model](/docs/api-reference/models/object) objects.
7533 examples:
7534 request:
7535 curl: |
7536 curl https://api.openai.com/v1/models \
7537 -H "Authorization: Bearer $OPENAI_API_KEY"
7538 python: |
7539 from openai import OpenAI
7540 client = OpenAI()
7541
7542 client.models.list()
7543 node.js: |-
7544 import OpenAI from "openai";
7545
7546 const openai = new OpenAI();
7547
7548 async function main() {
7549 const list = await openai.models.list();
7550
7551 for await (const model of list) {
7552 console.log(model);
7553 }
7554 }
7555 main();
7556 csharp: |
7557 using System;
7558
7559 using OpenAI.Models;
7560
7561 OpenAIModelClient client = new(
7562 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
7563 );
7564
7565 foreach (var model in client.GetModels().Value)
7566 {
7567 Console.WriteLine(model.Id);
7568 }
7569 response: |
7570 {
7571 "object": "list",
7572 "data": [
7573 {
7574 "id": "model-id-0",
7575 "object": "model",
7576 "created": 1686935002,
7577 "owned_by": "organization-owner"
7578 },
7579 {
7580 "id": "model-id-1",
7581 "object": "model",
7582 "created": 1686935002,
7583 "owned_by": "organization-owner",
7584 },
7585 {
7586 "id": "model-id-2",
7587 "object": "model",
7588 "created": 1686935002,
7589 "owned_by": "openai"
7590 },
7591 ],
7592 "object": "list"
7593 }
7594 /models/{model}:
7595 get:
7596 operationId: retrieveModel
7597 tags:
7598 - Models
7599 summary: Retrieves a model instance, providing basic information about the model
7600 such as the owner and permissioning.
7601 parameters:
7602 - in: path
7603 name: model
7604 required: true
7605 schema:
7606 type: string
7607 example: gpt-4o-mini
7608 description: The ID of the model to use for this request
7609 responses:
7610 "200":
7611 description: OK
7612 content:
7613 application/json:
7614 schema:
7615 $ref: "#/components/schemas/Model"
7616 x-oaiMeta:
7617 name: Retrieve model
7618 group: models
7619 returns: The [model](/docs/api-reference/models/object) object matching the
7620 specified ID.
7621 examples:
7622 request:
7623 curl: |
7624 curl https://api.openai.com/v1/models/VAR_chat_model_id \
7625 -H "Authorization: Bearer $OPENAI_API_KEY"
7626 python: |
7627 from openai import OpenAI
7628 client = OpenAI()
7629
7630 client.models.retrieve("VAR_chat_model_id")
7631 node.js: |-
7632 import OpenAI from "openai";
7633
7634 const openai = new OpenAI();
7635
7636 async function main() {
7637 const model = await openai.models.retrieve("VAR_chat_model_id");
7638
7639 console.log(model);
7640 }
7641
7642 main();
7643 csharp: |
7644 using System;
7645 using System.ClientModel;
7646
7647 using OpenAI.Models;
7648
7649 OpenAIModelClient client = new(
7650 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
7651 );
7652
7653 ClientResult<OpenAIModel> model = client.GetModel("babbage-002");
7654 Console.WriteLine(model.Value.Id);
7655 response: |
7656 {
7657 "id": "VAR_chat_model_id",
7658 "object": "model",
7659 "created": 1686935002,
7660 "owned_by": "openai"
7661 }
7662 delete:
7663 operationId: deleteModel
7664 tags:
7665 - Models
7666 summary: Delete a fine-tuned model. You must have the Owner role in your
7667 organization to delete a model.
7668 parameters:
7669 - in: path
7670 name: model
7671 required: true
7672 schema:
7673 type: string
7674 example: ft:gpt-4o-mini:acemeco:suffix:abc123
7675 description: The model to delete
7676 responses:
7677 "200":
7678 description: OK
7679 content:
7680 application/json:
7681 schema:
7682 $ref: "#/components/schemas/DeleteModelResponse"
7683 x-oaiMeta:
7684 name: Delete a fine-tuned model
7685 group: models
7686 returns: Deletion status.
7687 examples:
7688 request:
7689 curl: |
7690 curl https://api.openai.com/v1/models/ft:gpt-4o-mini:acemeco:suffix:abc123 \
7691 -X DELETE \
7692 -H "Authorization: Bearer $OPENAI_API_KEY"
7693 python: |
7694 from openai import OpenAI
7695 client = OpenAI()
7696
7697 client.models.delete("ft:gpt-4o-mini:acemeco:suffix:abc123")
7698 node.js: >-
7699 import OpenAI from "openai";
7700
7701
7702 const openai = new OpenAI();
7703
7704
7705 async function main() {
7706 const model = await openai.models.del("ft:gpt-4o-mini:acemeco:suffix:abc123");
7707
7708 console.log(model);
7709 }
7710
7711 main();
7712 csharp: >
7713 using System;
7714
7715 using System.ClientModel;
7716
7717
7718 using OpenAI.Models;
7719
7720
7721 OpenAIModelClient client = new(
7722 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
7723 );
7724
7725
7726 ClientResult success =
7727 client.DeleteModel("ft:gpt-4o-mini:acemeco:suffix:abc123");
7728
7729 Console.WriteLine(success);
7730 response: |
7731 {
7732 "id": "ft:gpt-4o-mini:acemeco:suffix:abc123",
7733 "object": "model",
7734 "deleted": true
7735 }
7736 /moderations:
7737 post:
7738 operationId: createModeration
7739 tags:
7740 - Moderations
7741 summary: |
7742 Classifies if text and/or image inputs are potentially harmful. Learn
7743 more in the [moderation guide](/docs/guides/moderation).
7744 requestBody:
7745 required: true
7746 content:
7747 application/json:
7748 schema:
7749 $ref: "#/components/schemas/CreateModerationRequest"
7750 responses:
7751 "200":
7752 description: OK
7753 content:
7754 application/json:
7755 schema:
7756 $ref: "#/components/schemas/CreateModerationResponse"
7757 x-oaiMeta:
7758 name: Create moderation
7759 group: moderations
7760 returns: A [moderation](/docs/api-reference/moderations/object) object.
7761 examples:
7762 - title: Single string
7763 request:
7764 curl: |
7765 curl https://api.openai.com/v1/moderations \
7766 -H "Content-Type: application/json" \
7767 -H "Authorization: Bearer $OPENAI_API_KEY" \
7768 -d '{
7769 "input": "I want to kill them."
7770 }'
7771 python: >
7772 from openai import OpenAI
7773
7774 client = OpenAI()
7775
7776
7777 moderation = client.moderations.create(input="I want to kill
7778 them.")
7779
7780 print(moderation)
7781 node.js: >
7782 import OpenAI from "openai";
7783
7784
7785 const openai = new OpenAI();
7786
7787
7788 async function main() {
7789 const moderation = await openai.moderations.create({ input: "I want to kill them." });
7790
7791 console.log(moderation);
7792 }
7793
7794 main();
7795 csharp: >
7796 using System;
7797
7798 using System.ClientModel;
7799
7800
7801 using OpenAI.Moderations;
7802
7803
7804 ModerationClient client = new(
7805 model: "omni-moderation-latest",
7806 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
7807 );
7808
7809
7810 ClientResult<ModerationResult> moderation =
7811 client.ClassifyText("I want to kill them.");
7812 response: |
7813 {
7814 "id": "modr-AB8CjOTu2jiq12hp1AQPfeqFWaORR",
7815 "model": "text-moderation-007",
7816 "results": [
7817 {
7818 "flagged": true,
7819 "categories": {
7820 "sexual": false,
7821 "hate": false,
7822 "harassment": true,
7823 "self-harm": false,
7824 "sexual/minors": false,
7825 "hate/threatening": false,
7826 "violence/graphic": false,
7827 "self-harm/intent": false,
7828 "self-harm/instructions": false,
7829 "harassment/threatening": true,
7830 "violence": true
7831 },
7832 "category_scores": {
7833 "sexual": 0.000011726012417057063,
7834 "hate": 0.22706663608551025,
7835 "harassment": 0.5215635299682617,
7836 "self-harm": 2.227119921371923e-6,
7837 "sexual/minors": 7.107352217872176e-8,
7838 "hate/threatening": 0.023547329008579254,
7839 "violence/graphic": 0.00003391829886822961,
7840 "self-harm/intent": 1.646940972932498e-6,
7841 "self-harm/instructions": 1.1198755256458526e-9,
7842 "harassment/threatening": 0.5694745779037476,
7843 "violence": 0.9971134662628174
7844 }
7845 }
7846 ]
7847 }
7848 - title: Image and text
7849 request:
7850 curl: >
7851 curl https://api.openai.com/v1/moderations \
7852 -X POST \
7853 -H "Content-Type: application/json" \
7854 -H "Authorization: Bearer $OPENAI_API_KEY" \
7855 -d '{
7856 "model": "omni-moderation-latest",
7857 "input": [
7858 { "type": "text", "text": "...text to classify goes here..." },
7859 {
7860 "type": "image_url",
7861 "image_url": {
7862 "url": "https://example.com/image.png"
7863 }
7864 }
7865 ]
7866 }'
7867 python: >
7868 from openai import OpenAI
7869
7870 client = OpenAI()
7871
7872
7873 response = client.moderations.create(
7874 model="omni-moderation-latest",
7875 input=[
7876 {"type": "text", "text": "...text to classify goes here..."},
7877 {
7878 "type": "image_url",
7879 "image_url": {
7880 "url": "https://example.com/image.png",
7881 # can also use base64 encoded image URLs
7882 # "url": "data:image/jpeg;base64,abcdefg..."
7883 }
7884 },
7885 ],
7886 )
7887
7888
7889 print(response)
7890 node.js: >
7891 import OpenAI from "openai";
7892
7893 const openai = new OpenAI();
7894
7895
7896 const moderation = await openai.moderations.create({
7897 model: "omni-moderation-latest",
7898 input: [
7899 { type: "text", text: "...text to classify goes here..." },
7900 {
7901 type: "image_url",
7902 image_url: {
7903 url: "https://example.com/image.png"
7904 // can also use base64 encoded image URLs
7905 // url: "data:image/jpeg;base64,abcdefg..."
7906 }
7907 }
7908 ],
7909 });
7910
7911
7912 console.log(moderation);
7913 response: |
7914 {
7915 "id": "modr-0d9740456c391e43c445bf0f010940c7",
7916 "model": "omni-moderation-latest",
7917 "results": [
7918 {
7919 "flagged": true,
7920 "categories": {
7921 "harassment": true,
7922 "harassment/threatening": true,
7923 "sexual": false,
7924 "hate": false,
7925 "hate/threatening": false,
7926 "illicit": false,
7927 "illicit/violent": false,
7928 "self-harm/intent": false,
7929 "self-harm/instructions": false,
7930 "self-harm": false,
7931 "sexual/minors": false,
7932 "violence": true,
7933 "violence/graphic": true
7934 },
7935 "category_scores": {
7936 "harassment": 0.8189693396524255,
7937 "harassment/threatening": 0.804985420696006,
7938 "sexual": 1.573112165348997e-6,
7939 "hate": 0.007562942636942845,
7940 "hate/threatening": 0.004208854591835476,
7941 "illicit": 0.030535955153511665,
7942 "illicit/violent": 0.008925306722380033,
7943 "self-harm/intent": 0.00023023930975076432,
7944 "self-harm/instructions": 0.0002293869201073356,
7945 "self-harm": 0.012598046106750154,
7946 "sexual/minors": 2.212566909570261e-8,
7947 "violence": 0.9999992735124786,
7948 "violence/graphic": 0.843064871157054
7949 },
7950 "category_applied_input_types": {
7951 "harassment": [
7952 "text"
7953 ],
7954 "harassment/threatening": [
7955 "text"
7956 ],
7957 "sexual": [
7958 "text",
7959 "image"
7960 ],
7961 "hate": [
7962 "text"
7963 ],
7964 "hate/threatening": [
7965 "text"
7966 ],
7967 "illicit": [
7968 "text"
7969 ],
7970 "illicit/violent": [
7971 "text"
7972 ],
7973 "self-harm/intent": [
7974 "text",
7975 "image"
7976 ],
7977 "self-harm/instructions": [
7978 "text",
7979 "image"
7980 ],
7981 "self-harm": [
7982 "text",
7983 "image"
7984 ],
7985 "sexual/minors": [
7986 "text"
7987 ],
7988 "violence": [
7989 "text",
7990 "image"
7991 ],
7992 "violence/graphic": [
7993 "text",
7994 "image"
7995 ]
7996 }
7997 }
7998 ]
7999 }
8000 /organization/admin_api_keys:
8001 get:
8002 summary: List organization API keys
8003 operationId: admin-api-keys-list
8004 description: Retrieve a paginated list of organization admin API keys.
8005 parameters:
8006 - in: query
8007 name: after
8008 required: false
8009 schema:
8010 type: string
8011 nullable: true
8012 description: Return keys with IDs that come after this ID in the pagination
8013 order.
8014 - in: query
8015 name: order
8016 required: false
8017 schema:
8018 type: string
8019 enum:
8020 - asc
8021 - desc
8022 default: asc
8023 description: Order results by creation time, ascending or descending.
8024 - in: query
8025 name: limit
8026 required: false
8027 schema:
8028 type: integer
8029 default: 20
8030 description: Maximum number of keys to return.
8031 responses:
8032 "200":
8033 description: A list of organization API keys.
8034 content:
8035 application/json:
8036 schema:
8037 $ref: "#/components/schemas/ApiKeyList"
8038 x-oaiMeta:
8039 name: List all organization and project API keys.
8040 group: administration
8041 returns: A list of admin and project API key objects.
8042 examples:
8043 request:
8044 curl: |
8045 curl https://api.openai.com/v1/organization/admin_api_keys?after=key_abc&limit=20 \
8046 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
8047 -H "Content-Type: application/json"
8048 response: |
8049 {
8050 "object": "list",
8051 "data": [
8052 {
8053 "object": "organization.admin_api_key",
8054 "id": "key_abc",
8055 "name": "Main Admin Key",
8056 "redacted_value": "sk-admin...def",
8057 "created_at": 1711471533,
8058 "last_used_at": 1711471534,
8059 "owner": {
8060 "type": "service_account",
8061 "object": "organization.service_account",
8062 "id": "sa_456",
8063 "name": "My Service Account",
8064 "created_at": 1711471533,
8065 "role": "member"
8066 }
8067 }
8068 ],
8069 "first_id": "key_abc",
8070 "last_id": "key_abc",
8071 "has_more": false
8072 }
8073 post:
8074 summary: Create an organization admin API key
8075 operationId: admin-api-keys-create
8076 description: Create a new admin-level API key for the organization.
8077 requestBody:
8078 required: true
8079 content:
8080 application/json:
8081 schema:
8082 type: object
8083 required:
8084 - name
8085 properties:
8086 name:
8087 type: string
8088 example: New Admin Key
8089 responses:
8090 "200":
8091 description: The newly created admin API key.
8092 content:
8093 application/json:
8094 schema:
8095 $ref: "#/components/schemas/AdminApiKey"
8096 x-oaiMeta:
8097 name: Create admin API key
8098 group: administration
8099 returns: The created [AdminApiKey](/docs/api-reference/admin-api-keys/object)
8100 object.
8101 examples:
8102 request:
8103 curl: >
8104 curl -X POST https://api.openai.com/v1/organization/admin_api_keys
8105 \
8106 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
8107 -H "Content-Type: application/json" \
8108 -d '{
8109 "name": "New Admin Key"
8110 }'
8111 response: |
8112 {
8113 "object": "organization.admin_api_key",
8114 "id": "key_xyz",
8115 "name": "New Admin Key",
8116 "redacted_value": "sk-admin...xyz",
8117 "created_at": 1711471533,
8118 "last_used_at": 1711471534,
8119 "owner": {
8120 "type": "user",
8121 "object": "organization.user",
8122 "id": "user_123",
8123 "name": "John Doe",
8124 "created_at": 1711471533,
8125 "role": "owner"
8126 },
8127 "value": "sk-admin-1234abcd"
8128 }
8129 /organization/admin_api_keys/{key_id}:
8130 get:
8131 summary: Retrieve a single organization API key
8132 operationId: admin-api-keys-get
8133 description: Get details for a specific organization API key by its ID.
8134 parameters:
8135 - in: path
8136 name: key_id
8137 required: true
8138 schema:
8139 type: string
8140 description: The ID of the API key.
8141 responses:
8142 "200":
8143 description: Details of the requested API key.
8144 content:
8145 application/json:
8146 schema:
8147 $ref: "#/components/schemas/AdminApiKey"
8148 x-oaiMeta:
8149 name: Retrieve admin API key
8150 group: administration
8151 returns: The requested [AdminApiKey](/docs/api-reference/admin-api-keys/object)
8152 object.
8153 examples:
8154 request:
8155 curl: >
8156 curl https://api.openai.com/v1/organization/admin_api_keys/key_abc
8157 \
8158 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
8159 -H "Content-Type: application/json"
8160 response: |
8161 {
8162 "object": "organization.admin_api_key",
8163 "id": "key_abc",
8164 "name": "Main Admin Key",
8165 "redacted_value": "sk-admin...xyz",
8166 "created_at": 1711471533,
8167 "last_used_at": 1711471534,
8168 "owner": {
8169 "type": "user",
8170 "object": "organization.user",
8171 "id": "user_123",
8172 "name": "John Doe",
8173 "created_at": 1711471533,
8174 "role": "owner"
8175 }
8176 }
8177 delete:
8178 summary: Delete an organization admin API key
8179 operationId: admin-api-keys-delete
8180 description: Delete the specified admin API key.
8181 parameters:
8182 - in: path
8183 name: key_id
8184 required: true
8185 schema:
8186 type: string
8187 description: The ID of the API key to be deleted.
8188 responses:
8189 "200":
8190 description: Confirmation that the API key was deleted.
8191 content:
8192 application/json:
8193 schema:
8194 type: object
8195 properties:
8196 id:
8197 type: string
8198 example: key_abc
8199 object:
8200 type: string
8201 example: organization.admin_api_key.deleted
8202 deleted:
8203 type: boolean
8204 example: true
8205 x-oaiMeta:
8206 name: Delete admin API key
8207 group: administration
8208 returns: A confirmation object indicating the key was deleted.
8209 examples:
8210 request:
8211 curl: >
8212 curl -X DELETE
8213 https://api.openai.com/v1/organization/admin_api_keys/key_abc \
8214 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
8215 -H "Content-Type: application/json"
8216 response: |
8217 {
8218 "id": "key_abc",
8219 "object": "organization.admin_api_key.deleted",
8220 "deleted": true
8221 }
8222 /organization/audit_logs:
8223 get:
8224 summary: List user actions and configuration changes within this organization.
8225 operationId: list-audit-logs
8226 tags:
8227 - Audit Logs
8228 parameters:
8229 - name: effective_at
8230 in: query
8231 description: Return only events whose `effective_at` (Unix seconds) is in this
8232 range.
8233 required: false
8234 schema:
8235 type: object
8236 properties:
8237 gt:
8238 type: integer
8239 description: Return only events whose `effective_at` (Unix seconds) is greater
8240 than this value.
8241 gte:
8242 type: integer
8243 description: Return only events whose `effective_at` (Unix seconds) is greater
8244 than or equal to this value.
8245 lt:
8246 type: integer
8247 description: Return only events whose `effective_at` (Unix seconds) is less than
8248 this value.
8249 lte:
8250 type: integer
8251 description: Return only events whose `effective_at` (Unix seconds) is less than
8252 or equal to this value.
8253 - name: project_ids[]
8254 in: query
8255 description: Return only events for these projects.
8256 required: false
8257 schema:
8258 type: array
8259 items:
8260 type: string
8261 - name: event_types[]
8262 in: query
8263 description: Return only events with a `type` in one of these values. For
8264 example, `project.created`. For all options, see the documentation
8265 for the [audit log object](/docs/api-reference/audit-logs/object).
8266 required: false
8267 schema:
8268 type: array
8269 items:
8270 $ref: "#/components/schemas/AuditLogEventType"
8271 - name: actor_ids[]
8272 in: query
8273 description: Return only events performed by these actors. Can be a user ID, a
8274 service account ID, or an api key tracking ID.
8275 required: false
8276 schema:
8277 type: array
8278 items:
8279 type: string
8280 - name: actor_emails[]
8281 in: query
8282 description: Return only events performed by users with these emails.
8283 required: false
8284 schema:
8285 type: array
8286 items:
8287 type: string
8288 - name: resource_ids[]
8289 in: query
8290 description: Return only events performed on these targets. For example, a
8291 project ID updated.
8292 required: false
8293 schema:
8294 type: array
8295 items:
8296 type: string
8297 - name: limit
8298 in: query
8299 description: >
8300 A limit on the number of objects to be returned. Limit can range
8301 between 1 and 100, and the default is 20.
8302 required: false
8303 schema:
8304 type: integer
8305 default: 20
8306 - name: after
8307 in: query
8308 description: >
8309 A cursor for use in pagination. `after` is an object ID that defines
8310 your place in the list. For instance, if you make a list request and
8311 receive 100 objects, ending with obj_foo, your subsequent call can
8312 include after=obj_foo in order to fetch the next page of the list.
8313 schema:
8314 type: string
8315 - name: before
8316 in: query
8317 description: >
8318 A cursor for use in pagination. `before` is an object ID that
8319 defines your place in the list. For instance, if you make a list
8320 request and receive 100 objects, starting with obj_foo, your
8321 subsequent call can include before=obj_foo in order to fetch the
8322 previous page of the list.
8323 schema:
8324 type: string
8325 responses:
8326 "200":
8327 description: Audit logs listed successfully.
8328 content:
8329 application/json:
8330 schema:
8331 $ref: "#/components/schemas/ListAuditLogsResponse"
8332 x-oaiMeta:
8333 name: List audit logs
8334 group: audit-logs
8335 returns: A list of paginated [Audit Log](/docs/api-reference/audit-logs/object)
8336 objects.
8337 examples:
8338 request:
8339 curl: |
8340 curl https://api.openai.com/v1/organization/audit_logs \
8341 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
8342 -H "Content-Type: application/json"
8343 response: >
8344 {
8345 "object": "list",
8346 "data": [
8347 {
8348 "id": "audit_log-xxx_yyyymmdd",
8349 "type": "project.archived",
8350 "effective_at": 1722461446,
8351 "actor": {
8352 "type": "api_key",
8353 "api_key": {
8354 "type": "user",
8355 "user": {
8356 "id": "user-xxx",
8357 "email": "user@example.com"
8358 }
8359 }
8360 },
8361 "project.archived": {
8362 "id": "proj_abc"
8363 },
8364 },
8365 {
8366 "id": "audit_log-yyy__20240101",
8367 "type": "api_key.updated",
8368 "effective_at": 1720804190,
8369 "actor": {
8370 "type": "session",
8371 "session": {
8372 "user": {
8373 "id": "user-xxx",
8374 "email": "user@example.com"
8375 },
8376 "ip_address": "127.0.0.1",
8377 "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
8378 "ja3": "a497151ce4338a12c4418c44d375173e",
8379 "ja4": "q13d0313h3_55b375c5d22e_c7319ce65786",
8380 "ip_address_details": {
8381 "country": "US",
8382 "city": "San Francisco",
8383 "region": "California",
8384 "region_code": "CA",
8385 "asn": "1234",
8386 "latitude": "37.77490",
8387 "longitude": "-122.41940"
8388 }
8389 }
8390 },
8391 "api_key.updated": {
8392 "id": "key_xxxx",
8393 "data": {
8394 "scopes": ["resource_2.operation_2"]
8395 }
8396 },
8397 }
8398 ],
8399 "first_id": "audit_log-xxx__20240101",
8400 "last_id": "audit_log_yyy__20240101",
8401 "has_more": true
8402 }
8403 /organization/certificates:
8404 get:
8405 summary: List uploaded certificates for this organization.
8406 operationId: listOrganizationCertificates
8407 tags:
8408 - Certificates
8409 parameters:
8410 - name: limit
8411 in: query
8412 description: >
8413 A limit on the number of objects to be returned. Limit can range
8414 between 1 and 100, and the default is 20.
8415 required: false
8416 schema:
8417 type: integer
8418 default: 20
8419 - name: after
8420 in: query
8421 description: >
8422 A cursor for use in pagination. `after` is an object ID that defines
8423 your place in the list. For instance, if you make a list request and
8424 receive 100 objects, ending with obj_foo, your subsequent call can
8425 include after=obj_foo in order to fetch the next page of the list.
8426 required: false
8427 schema:
8428 type: string
8429 - name: order
8430 in: query
8431 description: >
8432 Sort order by the `created_at` timestamp of the objects. `asc` for
8433 ascending order and `desc` for descending order.
8434 schema:
8435 type: string
8436 default: desc
8437 enum:
8438 - asc
8439 - desc
8440 responses:
8441 "200":
8442 description: Certificates listed successfully.
8443 content:
8444 application/json:
8445 schema:
8446 $ref: "#/components/schemas/ListCertificatesResponse"
8447 x-oaiMeta:
8448 name: List organization certificates
8449 group: administration
8450 returns: A list of [Certificate](/docs/api-reference/certificates/object)
8451 objects.
8452 examples:
8453 request:
8454 curl: |
8455 curl https://api.openai.com/v1/organization/certificates \
8456 -H "Authorization: Bearer $OPENAI_ADMIN_KEY"
8457 response: |
8458 {
8459 "object": "list",
8460 "data": [
8461 {
8462 "object": "organization.certificate",
8463 "id": "cert_abc",
8464 "name": "My Example Certificate",
8465 "active": true,
8466 "created_at": 1234567,
8467 "certificate_details": {
8468 "valid_at": 12345667,
8469 "expires_at": 12345678
8470 }
8471 },
8472 ],
8473 "first_id": "cert_abc",
8474 "last_id": "cert_abc",
8475 "has_more": false
8476 }
8477 post:
8478 summary: >
8479 Upload a certificate to the organization. This does **not**
8480 automatically activate the certificate.
8481
8482
8483 Organizations can upload up to 50 certificates.
8484 operationId: uploadCertificate
8485 tags:
8486 - Certificates
8487 requestBody:
8488 description: The certificate upload payload.
8489 required: true
8490 content:
8491 application/json:
8492 schema:
8493 $ref: "#/components/schemas/UploadCertificateRequest"
8494 responses:
8495 "200":
8496 description: Certificate uploaded successfully.
8497 content:
8498 application/json:
8499 schema:
8500 $ref: "#/components/schemas/Certificate"
8501 x-oaiMeta:
8502 name: Upload certificate
8503 group: administration
8504 returns: A single [Certificate](/docs/api-reference/certificates/object) object.
8505 examples:
8506 request:
8507 curl: >
8508 curl -X POST https://api.openai.com/v1/organization/certificates \
8509
8510 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
8511
8512 -H "Content-Type: application/json" \
8513
8514 -d '{
8515 "name": "My Example Certificate",
8516 "certificate": "-----BEGIN CERTIFICATE-----\\nMIIDeT...\\n-----END CERTIFICATE-----"
8517 }'
8518 response: |
8519 {
8520 "object": "certificate",
8521 "id": "cert_abc",
8522 "name": "My Example Certificate",
8523 "created_at": 1234567,
8524 "certificate_details": {
8525 "valid_at": 12345667,
8526 "expires_at": 12345678
8527 }
8528 }
8529 /organization/certificates/activate:
8530 post:
8531 summary: >
8532 Activate certificates at the organization level.
8533
8534
8535 You can atomically and idempotently activate up to 10 certificates at a
8536 time.
8537 operationId: activateOrganizationCertificates
8538 tags:
8539 - Certificates
8540 requestBody:
8541 description: The certificate activation payload.
8542 required: true
8543 content:
8544 application/json:
8545 schema:
8546 $ref: "#/components/schemas/ToggleCertificatesRequest"
8547 responses:
8548 "200":
8549 description: Certificates activated successfully.
8550 content:
8551 application/json:
8552 schema:
8553 $ref: "#/components/schemas/ListCertificatesResponse"
8554 x-oaiMeta:
8555 name: Activate certificates for organization
8556 group: administration
8557 returns: A list of [Certificate](/docs/api-reference/certificates/object)
8558 objects that were activated.
8559 examples:
8560 request:
8561 curl: >
8562 curl https://api.openai.com/v1/organization/certificates/activate
8563 \
8564
8565 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
8566
8567 -H "Content-Type: application/json" \
8568
8569 -d '{
8570 "data": ["cert_abc", "cert_def"]
8571 }'
8572 response: |
8573 {
8574 "object": "organization.certificate.activation",
8575 "data": [
8576 {
8577 "object": "organization.certificate",
8578 "id": "cert_abc",
8579 "name": "My Example Certificate",
8580 "active": true,
8581 "created_at": 1234567,
8582 "certificate_details": {
8583 "valid_at": 12345667,
8584 "expires_at": 12345678
8585 }
8586 },
8587 {
8588 "object": "organization.certificate",
8589 "id": "cert_def",
8590 "name": "My Example Certificate 2",
8591 "active": true,
8592 "created_at": 1234567,
8593 "certificate_details": {
8594 "valid_at": 12345667,
8595 "expires_at": 12345678
8596 }
8597 },
8598 ],
8599 }
8600 /organization/certificates/deactivate:
8601 post:
8602 summary: >
8603 Deactivate certificates at the organization level.
8604
8605
8606 You can atomically and idempotently deactivate up to 10 certificates at
8607 a time.
8608 operationId: deactivateOrganizationCertificates
8609 tags:
8610 - Certificates
8611 requestBody:
8612 description: The certificate deactivation payload.
8613 required: true
8614 content:
8615 application/json:
8616 schema:
8617 $ref: "#/components/schemas/ToggleCertificatesRequest"
8618 responses:
8619 "200":
8620 description: Certificates deactivated successfully.
8621 content:
8622 application/json:
8623 schema:
8624 $ref: "#/components/schemas/ListCertificatesResponse"
8625 x-oaiMeta:
8626 name: Deactivate certificates for organization
8627 group: administration
8628 returns: A list of [Certificate](/docs/api-reference/certificates/object)
8629 objects that were deactivated.
8630 examples:
8631 request:
8632 curl: >
8633 curl
8634 https://api.openai.com/v1/organization/certificates/deactivate \
8635
8636 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
8637
8638 -H "Content-Type: application/json" \
8639
8640 -d '{
8641 "data": ["cert_abc", "cert_def"]
8642 }'
8643 response: |
8644 {
8645 "object": "organization.certificate.deactivation",
8646 "data": [
8647 {
8648 "object": "organization.certificate",
8649 "id": "cert_abc",
8650 "name": "My Example Certificate",
8651 "active": false,
8652 "created_at": 1234567,
8653 "certificate_details": {
8654 "valid_at": 12345667,
8655 "expires_at": 12345678
8656 }
8657 },
8658 {
8659 "object": "organization.certificate",
8660 "id": "cert_def",
8661 "name": "My Example Certificate 2",
8662 "active": false,
8663 "created_at": 1234567,
8664 "certificate_details": {
8665 "valid_at": 12345667,
8666 "expires_at": 12345678
8667 }
8668 },
8669 ],
8670 }
8671 /organization/certificates/{certificate_id}:
8672 get:
8673 summary: |
8674 Get a certificate that has been uploaded to the organization.
8675
8676 You can get a certificate regardless of whether it is active or not.
8677 operationId: getCertificate
8678 tags:
8679 - Certificates
8680 parameters:
8681 - name: certificate_id
8682 in: path
8683 description: Unique ID of the certificate to retrieve.
8684 required: true
8685 schema:
8686 type: string
8687 - name: include
8688 in: query
8689 description: A list of additional fields to include in the response. Currently
8690 the only supported value is `content` to fetch the PEM content of
8691 the certificate.
8692 required: false
8693 schema:
8694 type: array
8695 items:
8696 type: string
8697 enum:
8698 - content
8699 responses:
8700 "200":
8701 description: Certificate retrieved successfully.
8702 content:
8703 application/json:
8704 schema:
8705 $ref: "#/components/schemas/Certificate"
8706 x-oaiMeta:
8707 name: Get certificate
8708 group: administration
8709 returns: A single [Certificate](/docs/api-reference/certificates/object) object.
8710 examples:
8711 request:
8712 curl: |
8713 curl "https://api.openai.com/v1/organization/certificates/cert_abc?include[]=content" \
8714 -H "Authorization: Bearer $OPENAI_ADMIN_KEY"
8715 response: >
8716 {
8717 "object": "certificate",
8718 "id": "cert_abc",
8719 "name": "My Example Certificate",
8720 "created_at": 1234567,
8721 "certificate_details": {
8722 "valid_at": 1234567,
8723 "expires_at": 12345678,
8724 "content": "-----BEGIN CERTIFICATE-----MIIDeT...-----END CERTIFICATE-----"
8725 }
8726 }
8727 post:
8728 summary: |
8729 Modify a certificate. Note that only the name can be modified.
8730 operationId: modifyCertificate
8731 tags:
8732 - Certificates
8733 requestBody:
8734 description: The certificate modification payload.
8735 required: true
8736 content:
8737 application/json:
8738 schema:
8739 $ref: "#/components/schemas/ModifyCertificateRequest"
8740 responses:
8741 "200":
8742 description: Certificate modified successfully.
8743 content:
8744 application/json:
8745 schema:
8746 $ref: "#/components/schemas/Certificate"
8747 x-oaiMeta:
8748 name: Modify certificate
8749 group: administration
8750 returns: The updated [Certificate](/docs/api-reference/certificates/object)
8751 object.
8752 examples:
8753 request:
8754 curl: >
8755 curl -X POST
8756 https://api.openai.com/v1/organization/certificates/cert_abc \
8757
8758 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
8759
8760 -H "Content-Type: application/json" \
8761
8762 -d '{
8763 "name": "Renamed Certificate"
8764 }'
8765 response: |
8766 {
8767 "object": "certificate",
8768 "id": "cert_abc",
8769 "name": "Renamed Certificate",
8770 "created_at": 1234567,
8771 "certificate_details": {
8772 "valid_at": 12345667,
8773 "expires_at": 12345678
8774 }
8775 }
8776 delete:
8777 summary: |
8778 Delete a certificate from the organization.
8779
8780 The certificate must be inactive for the organization and all projects.
8781 operationId: deleteCertificate
8782 tags:
8783 - Certificates
8784 responses:
8785 "200":
8786 description: Certificate deleted successfully.
8787 content:
8788 application/json:
8789 schema:
8790 $ref: "#/components/schemas/DeleteCertificateResponse"
8791 x-oaiMeta:
8792 name: Delete certificate
8793 group: administration
8794 returns: A confirmation object indicating the certificate was deleted.
8795 examples:
8796 request:
8797 curl: >
8798 curl -X DELETE
8799 https://api.openai.com/v1/organization/certificates/cert_abc \
8800
8801 -H "Authorization: Bearer $OPENAI_ADMIN_KEY"
8802 response: |
8803 {
8804 "object": "certificate.deleted",
8805 "id": "cert_abc"
8806 }
8807 /organization/costs:
8808 get:
8809 summary: Get costs details for the organization.
8810 operationId: usage-costs
8811 tags:
8812 - Usage
8813 parameters:
8814 - name: start_time
8815 in: query
8816 description: Start time (Unix seconds) of the query time range, inclusive.
8817 required: true
8818 schema:
8819 type: integer
8820 - name: end_time
8821 in: query
8822 description: End time (Unix seconds) of the query time range, exclusive.
8823 required: false
8824 schema:
8825 type: integer
8826 - name: bucket_width
8827 in: query
8828 description: Width of each time bucket in response. Currently only `1d` is
8829 supported, default to `1d`.
8830 required: false
8831 schema:
8832 type: string
8833 enum:
8834 - 1d
8835 default: 1d
8836 - name: project_ids
8837 in: query
8838 description: Return only costs for these projects.
8839 required: false
8840 schema:
8841 type: array
8842 items:
8843 type: string
8844 - name: group_by
8845 in: query
8846 description: Group the costs by the specified fields. Support fields include
8847 `project_id`, `line_item` and any combination of them.
8848 required: false
8849 schema:
8850 type: array
8851 items:
8852 type: string
8853 enum:
8854 - project_id
8855 - line_item
8856 - name: limit
8857 in: query
8858 description: >
8859 A limit on the number of buckets to be returned. Limit can range
8860 between 1 and 180, and the default is 7.
8861 required: false
8862 schema:
8863 type: integer
8864 default: 7
8865 - name: page
8866 in: query
8867 description: A cursor for use in pagination. Corresponding to the `next_page`
8868 field from the previous response.
8869 schema:
8870 type: string
8871 responses:
8872 "200":
8873 description: Costs data retrieved successfully.
8874 content:
8875 application/json:
8876 schema:
8877 $ref: "#/components/schemas/UsageResponse"
8878 x-oaiMeta:
8879 name: Costs
8880 group: usage-costs
8881 returns: A list of paginated, time bucketed
8882 [Costs](/docs/api-reference/usage/costs_object) objects.
8883 examples:
8884 request:
8885 curl: |
8886 curl "https://api.openai.com/v1/organization/costs?start_time=1730419200&limit=1" \
8887 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
8888 -H "Content-Type: application/json"
8889 response: |
8890 {
8891 "object": "page",
8892 "data": [
8893 {
8894 "object": "bucket",
8895 "start_time": 1730419200,
8896 "end_time": 1730505600,
8897 "results": [
8898 {
8899 "object": "organization.costs.result",
8900 "amount": {
8901 "value": 0.06,
8902 "currency": "usd"
8903 },
8904 "line_item": null,
8905 "project_id": null
8906 }
8907 ]
8908 }
8909 ],
8910 "has_more": false,
8911 "next_page": null
8912 }
8913 /organization/invites:
8914 get:
8915 summary: Returns a list of invites in the organization.
8916 operationId: list-invites
8917 tags:
8918 - Invites
8919 parameters:
8920 - name: limit
8921 in: query
8922 description: >
8923 A limit on the number of objects to be returned. Limit can range
8924 between 1 and 100, and the default is 20.
8925 required: false
8926 schema:
8927 type: integer
8928 default: 20
8929 - name: after
8930 in: query
8931 description: >
8932 A cursor for use in pagination. `after` is an object ID that defines
8933 your place in the list. For instance, if you make a list request and
8934 receive 100 objects, ending with obj_foo, your subsequent call can
8935 include after=obj_foo in order to fetch the next page of the list.
8936 required: false
8937 schema:
8938 type: string
8939 responses:
8940 "200":
8941 description: Invites listed successfully.
8942 content:
8943 application/json:
8944 schema:
8945 $ref: "#/components/schemas/InviteListResponse"
8946 x-oaiMeta:
8947 name: List invites
8948 group: administration
8949 returns: A list of [Invite](/docs/api-reference/invite/object) objects.
8950 examples:
8951 request:
8952 curl: |
8953 curl https://api.openai.com/v1/organization/invites?after=invite-abc&limit=20 \
8954 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
8955 -H "Content-Type: application/json"
8956 response: |
8957 {
8958 "object": "list",
8959 "data": [
8960 {
8961 "object": "organization.invite",
8962 "id": "invite-abc",
8963 "email": "user@example.com",
8964 "role": "owner",
8965 "status": "accepted",
8966 "invited_at": 1711471533,
8967 "expires_at": 1711471533,
8968 "accepted_at": 1711471533
8969 }
8970 ],
8971 "first_id": "invite-abc",
8972 "last_id": "invite-abc",
8973 "has_more": false
8974 }
8975 post:
8976 summary: Create an invite for a user to the organization. The invite must be
8977 accepted by the user before they have access to the organization.
8978 operationId: inviteUser
8979 tags:
8980 - Invites
8981 requestBody:
8982 description: The invite request payload.
8983 required: true
8984 content:
8985 application/json:
8986 schema:
8987 $ref: "#/components/schemas/InviteRequest"
8988 responses:
8989 "200":
8990 description: User invited successfully.
8991 content:
8992 application/json:
8993 schema:
8994 $ref: "#/components/schemas/Invite"
8995 x-oaiMeta:
8996 name: Create invite
8997 group: administration
8998 returns: The created [Invite](/docs/api-reference/invite/object) object.
8999 examples:
9000 request:
9001 curl: |
9002 curl -X POST https://api.openai.com/v1/organization/invites \
9003 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
9004 -H "Content-Type: application/json" \
9005 -d '{
9006 "email": "anotheruser@example.com",
9007 "role": "reader",
9008 "projects": [
9009 {
9010 "id": "project-xyz",
9011 "role": "member"
9012 },
9013 {
9014 "id": "project-abc",
9015 "role": "owner"
9016 }
9017 ]
9018 }'
9019 response: |
9020 {
9021 "object": "organization.invite",
9022 "id": "invite-def",
9023 "email": "anotheruser@example.com",
9024 "role": "reader",
9025 "status": "pending",
9026 "invited_at": 1711471533,
9027 "expires_at": 1711471533,
9028 "accepted_at": null,
9029 "projects": [
9030 {
9031 "id": "project-xyz",
9032 "role": "member"
9033 },
9034 {
9035 "id": "project-abc",
9036 "role": "owner"
9037 }
9038 ]
9039 }
9040 /organization/invites/{invite_id}:
9041 get:
9042 summary: Retrieves an invite.
9043 operationId: retrieve-invite
9044 tags:
9045 - Invites
9046 parameters:
9047 - in: path
9048 name: invite_id
9049 required: true
9050 schema:
9051 type: string
9052 description: The ID of the invite to retrieve.
9053 responses:
9054 "200":
9055 description: Invite retrieved successfully.
9056 content:
9057 application/json:
9058 schema:
9059 $ref: "#/components/schemas/Invite"
9060 x-oaiMeta:
9061 name: Retrieve invite
9062 group: administration
9063 returns: The [Invite](/docs/api-reference/invite/object) object matching the
9064 specified ID.
9065 examples:
9066 request:
9067 curl: |
9068 curl https://api.openai.com/v1/organization/invites/invite-abc \
9069 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
9070 -H "Content-Type: application/json"
9071 response: |
9072 {
9073 "object": "organization.invite",
9074 "id": "invite-abc",
9075 "email": "user@example.com",
9076 "role": "owner",
9077 "status": "accepted",
9078 "invited_at": 1711471533,
9079 "expires_at": 1711471533,
9080 "accepted_at": 1711471533
9081 }
9082 delete:
9083 summary: Delete an invite. If the invite has already been accepted, it cannot be
9084 deleted.
9085 operationId: delete-invite
9086 tags:
9087 - Invites
9088 parameters:
9089 - in: path
9090 name: invite_id
9091 required: true
9092 schema:
9093 type: string
9094 description: The ID of the invite to delete.
9095 responses:
9096 "200":
9097 description: Invite deleted successfully.
9098 content:
9099 application/json:
9100 schema:
9101 $ref: "#/components/schemas/InviteDeleteResponse"
9102 x-oaiMeta:
9103 name: Delete invite
9104 group: administration
9105 returns: Confirmation that the invite has been deleted
9106 examples:
9107 request:
9108 curl: >
9109 curl -X DELETE
9110 https://api.openai.com/v1/organization/invites/invite-abc \
9111 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
9112 -H "Content-Type: application/json"
9113 response: |
9114 {
9115 "object": "organization.invite.deleted",
9116 "id": "invite-abc",
9117 "deleted": true
9118 }
9119 /organization/projects:
9120 get:
9121 summary: Returns a list of projects.
9122 operationId: list-projects
9123 tags:
9124 - Projects
9125 parameters:
9126 - name: limit
9127 in: query
9128 description: >
9129 A limit on the number of objects to be returned. Limit can range
9130 between 1 and 100, and the default is 20.
9131 required: false
9132 schema:
9133 type: integer
9134 default: 20
9135 - name: after
9136 in: query
9137 description: >
9138 A cursor for use in pagination. `after` is an object ID that defines
9139 your place in the list. For instance, if you make a list request and
9140 receive 100 objects, ending with obj_foo, your subsequent call can
9141 include after=obj_foo in order to fetch the next page of the list.
9142 required: false
9143 schema:
9144 type: string
9145 - name: include_archived
9146 in: query
9147 schema:
9148 type: boolean
9149 default: false
9150 description: If `true` returns all projects including those that have been
9151 `archived`. Archived projects are not included by default.
9152 responses:
9153 "200":
9154 description: Projects listed successfully.
9155 content:
9156 application/json:
9157 schema:
9158 $ref: "#/components/schemas/ProjectListResponse"
9159 x-oaiMeta:
9160 name: List projects
9161 group: administration
9162 returns: A list of [Project](/docs/api-reference/projects/object) objects.
9163 examples:
9164 request:
9165 curl: |
9166 curl https://api.openai.com/v1/organization/projects?after=proj_abc&limit=20&include_archived=false \
9167 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
9168 -H "Content-Type: application/json"
9169 response: |
9170 {
9171 "object": "list",
9172 "data": [
9173 {
9174 "id": "proj_abc",
9175 "object": "organization.project",
9176 "name": "Project example",
9177 "created_at": 1711471533,
9178 "archived_at": null,
9179 "status": "active"
9180 }
9181 ],
9182 "first_id": "proj-abc",
9183 "last_id": "proj-xyz",
9184 "has_more": false
9185 }
9186 post:
9187 summary: Create a new project in the organization. Projects can be created and
9188 archived, but cannot be deleted.
9189 operationId: create-project
9190 tags:
9191 - Projects
9192 requestBody:
9193 description: The project create request payload.
9194 required: true
9195 content:
9196 application/json:
9197 schema:
9198 $ref: "#/components/schemas/ProjectCreateRequest"
9199 responses:
9200 "200":
9201 description: Project created successfully.
9202 content:
9203 application/json:
9204 schema:
9205 $ref: "#/components/schemas/Project"
9206 x-oaiMeta:
9207 name: Create project
9208 group: administration
9209 returns: The created [Project](/docs/api-reference/projects/object) object.
9210 examples:
9211 request:
9212 curl: |
9213 curl -X POST https://api.openai.com/v1/organization/projects \
9214 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
9215 -H "Content-Type: application/json" \
9216 -d '{
9217 "name": "Project ABC"
9218 }'
9219 response: |
9220 {
9221 "id": "proj_abc",
9222 "object": "organization.project",
9223 "name": "Project ABC",
9224 "created_at": 1711471533,
9225 "archived_at": null,
9226 "status": "active"
9227 }
9228 /organization/projects/{project_id}:
9229 get:
9230 summary: Retrieves a project.
9231 operationId: retrieve-project
9232 tags:
9233 - Projects
9234 parameters:
9235 - name: project_id
9236 in: path
9237 description: The ID of the project.
9238 required: true
9239 schema:
9240 type: string
9241 responses:
9242 "200":
9243 description: Project retrieved successfully.
9244 content:
9245 application/json:
9246 schema:
9247 $ref: "#/components/schemas/Project"
9248 x-oaiMeta:
9249 name: Retrieve project
9250 group: administration
9251 description: Retrieve a project.
9252 returns: The [Project](/docs/api-reference/projects/object) object matching the
9253 specified ID.
9254 examples:
9255 request:
9256 curl: |
9257 curl https://api.openai.com/v1/organization/projects/proj_abc \
9258 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
9259 -H "Content-Type: application/json"
9260 response: |
9261 {
9262 "id": "proj_abc",
9263 "object": "organization.project",
9264 "name": "Project example",
9265 "created_at": 1711471533,
9266 "archived_at": null,
9267 "status": "active"
9268 }
9269 post:
9270 summary: Modifies a project in the organization.
9271 operationId: modify-project
9272 tags:
9273 - Projects
9274 parameters:
9275 - name: project_id
9276 in: path
9277 description: The ID of the project.
9278 required: true
9279 schema:
9280 type: string
9281 requestBody:
9282 description: The project update request payload.
9283 required: true
9284 content:
9285 application/json:
9286 schema:
9287 $ref: "#/components/schemas/ProjectUpdateRequest"
9288 responses:
9289 "200":
9290 description: Project updated successfully.
9291 content:
9292 application/json:
9293 schema:
9294 $ref: "#/components/schemas/Project"
9295 "400":
9296 description: Error response when updating the default project.
9297 content:
9298 application/json:
9299 schema:
9300 $ref: "#/components/schemas/ErrorResponse"
9301 x-oaiMeta:
9302 name: Modify project
9303 group: administration
9304 returns: The updated [Project](/docs/api-reference/projects/object) object.
9305 examples:
9306 request:
9307 curl: >
9308 curl -X POST
9309 https://api.openai.com/v1/organization/projects/proj_abc \
9310 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
9311 -H "Content-Type: application/json" \
9312 -d '{
9313 "name": "Project DEF"
9314 }'
9315 /organization/projects/{project_id}/api_keys:
9316 get:
9317 summary: Returns a list of API keys in the project.
9318 operationId: list-project-api-keys
9319 tags:
9320 - Projects
9321 parameters:
9322 - name: project_id
9323 in: path
9324 description: The ID of the project.
9325 required: true
9326 schema:
9327 type: string
9328 - name: limit
9329 in: query
9330 description: >
9331 A limit on the number of objects to be returned. Limit can range
9332 between 1 and 100, and the default is 20.
9333 required: false
9334 schema:
9335 type: integer
9336 default: 20
9337 - name: after
9338 in: query
9339 description: >
9340 A cursor for use in pagination. `after` is an object ID that defines
9341 your place in the list. For instance, if you make a list request and
9342 receive 100 objects, ending with obj_foo, your subsequent call can
9343 include after=obj_foo in order to fetch the next page of the list.
9344 required: false
9345 schema:
9346 type: string
9347 responses:
9348 "200":
9349 description: Project API keys listed successfully.
9350 content:
9351 application/json:
9352 schema:
9353 $ref: "#/components/schemas/ProjectApiKeyListResponse"
9354 x-oaiMeta:
9355 name: List project API keys
9356 group: administration
9357 returns: A list of [ProjectApiKey](/docs/api-reference/project-api-keys/object)
9358 objects.
9359 examples:
9360 request:
9361 curl: |
9362 curl https://api.openai.com/v1/organization/projects/proj_abc/api_keys?after=key_abc&limit=20 \
9363 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
9364 -H "Content-Type: application/json"
9365 response: |
9366 {
9367 "object": "list",
9368 "data": [
9369 {
9370 "object": "organization.project.api_key",
9371 "redacted_value": "sk-abc...def",
9372 "name": "My API Key",
9373 "created_at": 1711471533,
9374 "last_used_at": 1711471534,
9375 "id": "key_abc",
9376 "owner": {
9377 "type": "user",
9378 "user": {
9379 "object": "organization.project.user",
9380 "id": "user_abc",
9381 "name": "First Last",
9382 "email": "user@example.com",
9383 "role": "owner",
9384 "added_at": 1711471533
9385 }
9386 }
9387 }
9388 ],
9389 "first_id": "key_abc",
9390 "last_id": "key_xyz",
9391 "has_more": false
9392 }
9393 /organization/projects/{project_id}/api_keys/{key_id}:
9394 get:
9395 summary: Retrieves an API key in the project.
9396 operationId: retrieve-project-api-key
9397 tags:
9398 - Projects
9399 parameters:
9400 - name: project_id
9401 in: path
9402 description: The ID of the project.
9403 required: true
9404 schema:
9405 type: string
9406 - name: key_id
9407 in: path
9408 description: The ID of the API key.
9409 required: true
9410 schema:
9411 type: string
9412 responses:
9413 "200":
9414 description: Project API key retrieved successfully.
9415 content:
9416 application/json:
9417 schema:
9418 $ref: "#/components/schemas/ProjectApiKey"
9419 x-oaiMeta:
9420 name: Retrieve project API key
9421 group: administration
9422 returns: The [ProjectApiKey](/docs/api-reference/project-api-keys/object) object
9423 matching the specified ID.
9424 examples:
9425 request:
9426 curl: |
9427 curl https://api.openai.com/v1/organization/projects/proj_abc/api_keys/key_abc \
9428 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
9429 -H "Content-Type: application/json"
9430 response: |
9431 {
9432 "object": "organization.project.api_key",
9433 "redacted_value": "sk-abc...def",
9434 "name": "My API Key",
9435 "created_at": 1711471533,
9436 "last_used_at": 1711471534,
9437 "id": "key_abc",
9438 "owner": {
9439 "type": "user",
9440 "user": {
9441 "object": "organization.project.user",
9442 "id": "user_abc",
9443 "name": "First Last",
9444 "email": "user@example.com",
9445 "role": "owner",
9446 "added_at": 1711471533
9447 }
9448 }
9449 }
9450 delete:
9451 summary: Deletes an API key from the project.
9452 operationId: delete-project-api-key
9453 tags:
9454 - Projects
9455 parameters:
9456 - name: project_id
9457 in: path
9458 description: The ID of the project.
9459 required: true
9460 schema:
9461 type: string
9462 - name: key_id
9463 in: path
9464 description: The ID of the API key.
9465 required: true
9466 schema:
9467 type: string
9468 responses:
9469 "200":
9470 description: Project API key deleted successfully.
9471 content:
9472 application/json:
9473 schema:
9474 $ref: "#/components/schemas/ProjectApiKeyDeleteResponse"
9475 "400":
9476 description: Error response for various conditions.
9477 content:
9478 application/json:
9479 schema:
9480 $ref: "#/components/schemas/ErrorResponse"
9481 x-oaiMeta:
9482 name: Delete project API key
9483 group: administration
9484 returns: Confirmation of the key's deletion or an error if the key belonged to a
9485 service account
9486 examples:
9487 request:
9488 curl: |
9489 curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc/api_keys/key_abc \
9490 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
9491 -H "Content-Type: application/json"
9492 response: |
9493 {
9494 "object": "organization.project.api_key.deleted",
9495 "id": "key_abc",
9496 "deleted": true
9497 }
9498 /organization/projects/{project_id}/archive:
9499 post:
9500 summary: Archives a project in the organization. Archived projects cannot be
9501 used or updated.
9502 operationId: archive-project
9503 tags:
9504 - Projects
9505 parameters:
9506 - name: project_id
9507 in: path
9508 description: The ID of the project.
9509 required: true
9510 schema:
9511 type: string
9512 responses:
9513 "200":
9514 description: Project archived successfully.
9515 content:
9516 application/json:
9517 schema:
9518 $ref: "#/components/schemas/Project"
9519 x-oaiMeta:
9520 name: Archive project
9521 group: administration
9522 returns: The archived [Project](/docs/api-reference/projects/object) object.
9523 examples:
9524 request:
9525 curl: >
9526 curl -X POST
9527 https://api.openai.com/v1/organization/projects/proj_abc/archive \
9528 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
9529 -H "Content-Type: application/json"
9530 response: |
9531 {
9532 "id": "proj_abc",
9533 "object": "organization.project",
9534 "name": "Project DEF",
9535 "created_at": 1711471533,
9536 "archived_at": 1711471533,
9537 "status": "archived"
9538 }
9539 /organization/projects/{project_id}/certificates:
9540 parameters:
9541 - name: project_id
9542 in: path
9543 description: The ID of the project.
9544 required: true
9545 schema:
9546 type: string
9547 get:
9548 summary: List certificates for this project.
9549 operationId: listProjectCertificates
9550 tags:
9551 - Certificates
9552 parameters:
9553 - name: project_id
9554 in: path
9555 description: The ID of the project.
9556 required: true
9557 schema:
9558 type: string
9559 - name: limit
9560 in: query
9561 description: >
9562 A limit on the number of objects to be returned. Limit can range
9563 between 1 and 100, and the default is 20.
9564 required: false
9565 schema:
9566 type: integer
9567 default: 20
9568 - name: after
9569 in: query
9570 description: >
9571 A cursor for use in pagination. `after` is an object ID that defines
9572 your place in the list. For instance, if you make a list request and
9573 receive 100 objects, ending with obj_foo, your subsequent call can
9574 include after=obj_foo in order to fetch the next page of the list.
9575 required: false
9576 schema:
9577 type: string
9578 - name: order
9579 in: query
9580 description: >
9581 Sort order by the `created_at` timestamp of the objects. `asc` for
9582 ascending order and `desc` for descending order.
9583 schema:
9584 type: string
9585 default: desc
9586 enum:
9587 - asc
9588 - desc
9589 responses:
9590 "200":
9591 description: Certificates listed successfully.
9592 content:
9593 application/json:
9594 schema:
9595 $ref: "#/components/schemas/ListCertificatesResponse"
9596 x-oaiMeta:
9597 name: List project certificates
9598 group: administration
9599 returns: A list of [Certificate](/docs/api-reference/certificates/object)
9600 objects.
9601 examples:
9602 request:
9603 curl: |
9604 curl https://api.openai.com/v1/organization/projects/proj_abc/certificates \
9605 -H "Authorization: Bearer $OPENAI_ADMIN_KEY"
9606 response: |
9607 {
9608 "object": "list",
9609 "data": [
9610 {
9611 "object": "organization.project.certificate",
9612 "id": "cert_abc",
9613 "name": "My Example Certificate",
9614 "active": true,
9615 "created_at": 1234567,
9616 "certificate_details": {
9617 "valid_at": 12345667,
9618 "expires_at": 12345678
9619 }
9620 },
9621 ],
9622 "first_id": "cert_abc",
9623 "last_id": "cert_abc",
9624 "has_more": false
9625 }
9626 /organization/projects/{project_id}/certificates/activate:
9627 parameters:
9628 - name: project_id
9629 in: path
9630 description: The ID of the project.
9631 required: true
9632 schema:
9633 type: string
9634 post:
9635 summary: >
9636 Activate certificates at the project level.
9637
9638
9639 You can atomically and idempotently activate up to 10 certificates at a
9640 time.
9641 operationId: activateProjectCertificates
9642 tags:
9643 - Certificates
9644 parameters:
9645 - name: project_id
9646 in: path
9647 description: The ID of the project.
9648 required: true
9649 schema:
9650 type: string
9651 requestBody:
9652 description: The certificate activation payload.
9653 required: true
9654 content:
9655 application/json:
9656 schema:
9657 $ref: "#/components/schemas/ToggleCertificatesRequest"
9658 responses:
9659 "200":
9660 description: Certificates activated successfully.
9661 content:
9662 application/json:
9663 schema:
9664 $ref: "#/components/schemas/ListCertificatesResponse"
9665 x-oaiMeta:
9666 name: Activate certificates for project
9667 group: administration
9668 returns: A list of [Certificate](/docs/api-reference/certificates/object)
9669 objects that were activated.
9670 examples:
9671 request:
9672 curl: |
9673 curl https://api.openai.com/v1/organization/projects/proj_abc/certificates/activate \
9674 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
9675 -H "Content-Type: application/json" \
9676 -d '{
9677 "data": ["cert_abc", "cert_def"]
9678 }'
9679 response: |
9680 {
9681 "object": "organization.project.certificate.activation",
9682 "data": [
9683 {
9684 "object": "organization.project.certificate",
9685 "id": "cert_abc",
9686 "name": "My Example Certificate",
9687 "active": true,
9688 "created_at": 1234567,
9689 "certificate_details": {
9690 "valid_at": 12345667,
9691 "expires_at": 12345678
9692 }
9693 },
9694 {
9695 "object": "organization.project.certificate",
9696 "id": "cert_def",
9697 "name": "My Example Certificate 2",
9698 "active": true,
9699 "created_at": 1234567,
9700 "certificate_details": {
9701 "valid_at": 12345667,
9702 "expires_at": 12345678
9703 }
9704 },
9705 ],
9706 }
9707 /organization/projects/{project_id}/certificates/deactivate:
9708 parameters:
9709 - name: project_id
9710 in: path
9711 description: The ID of the project.
9712 required: true
9713 schema:
9714 type: string
9715 post:
9716 summary: |
9717 Deactivate certificates at the project level. You can atomically and
9718 idempotently deactivate up to 10 certificates at a time.
9719 operationId: deactivateProjectCertificates
9720 tags:
9721 - Certificates
9722 parameters:
9723 - name: project_id
9724 in: path
9725 description: The ID of the project.
9726 required: true
9727 schema:
9728 type: string
9729 requestBody:
9730 description: The certificate deactivation payload.
9731 required: true
9732 content:
9733 application/json:
9734 schema:
9735 $ref: "#/components/schemas/ToggleCertificatesRequest"
9736 responses:
9737 "200":
9738 description: Certificates deactivated successfully.
9739 content:
9740 application/json:
9741 schema:
9742 $ref: "#/components/schemas/ListCertificatesResponse"
9743 x-oaiMeta:
9744 name: Deactivate certificates for project
9745 group: administration
9746 returns: A list of [Certificate](/docs/api-reference/certificates/object)
9747 objects that were deactivated.
9748 examples:
9749 request:
9750 curl: |
9751 curl https://api.openai.com/v1/organization/projects/proj_abc/certificates/deactivate \
9752 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
9753 -H "Content-Type: application/json" \
9754 -d '{
9755 "data": ["cert_abc", "cert_def"]
9756 }'
9757 response: |
9758 {
9759 "object": "organization.project.certificate.deactivation",
9760 "data": [
9761 {
9762 "object": "organization.project.certificate",
9763 "id": "cert_abc",
9764 "name": "My Example Certificate",
9765 "active": false,
9766 "created_at": 1234567,
9767 "certificate_details": {
9768 "valid_at": 12345667,
9769 "expires_at": 12345678
9770 }
9771 },
9772 {
9773 "object": "organization.project.certificate",
9774 "id": "cert_def",
9775 "name": "My Example Certificate 2",
9776 "active": false,
9777 "created_at": 1234567,
9778 "certificate_details": {
9779 "valid_at": 12345667,
9780 "expires_at": 12345678
9781 }
9782 },
9783 ],
9784 }
9785 /organization/projects/{project_id}/rate_limits:
9786 get:
9787 summary: Returns the rate limits per model for a project.
9788 operationId: list-project-rate-limits
9789 tags:
9790 - Projects
9791 parameters:
9792 - name: project_id
9793 in: path
9794 description: The ID of the project.
9795 required: true
9796 schema:
9797 type: string
9798 - name: limit
9799 in: query
9800 description: |
9801 A limit on the number of objects to be returned. The default is 100.
9802 required: false
9803 schema:
9804 type: integer
9805 default: 100
9806 - name: after
9807 in: query
9808 description: >
9809 A cursor for use in pagination. `after` is an object ID that defines
9810 your place in the list. For instance, if you make a list request and
9811 receive 100 objects, ending with obj_foo, your subsequent call can
9812 include after=obj_foo in order to fetch the next page of the list.
9813 required: false
9814 schema:
9815 type: string
9816 - name: before
9817 in: query
9818 description: >
9819 A cursor for use in pagination. `before` is an object ID that
9820 defines your place in the list. For instance, if you make a list
9821 request and receive 100 objects, beginning with obj_foo, your
9822 subsequent call can include before=obj_foo in order to fetch the
9823 previous page of the list.
9824 required: false
9825 schema:
9826 type: string
9827 responses:
9828 "200":
9829 description: Project rate limits listed successfully.
9830 content:
9831 application/json:
9832 schema:
9833 $ref: "#/components/schemas/ProjectRateLimitListResponse"
9834 x-oaiMeta:
9835 name: List project rate limits
9836 group: administration
9837 returns: A list of
9838 [ProjectRateLimit](/docs/api-reference/project-rate-limits/object)
9839 objects.
9840 examples:
9841 request:
9842 curl: |
9843 curl https://api.openai.com/v1/organization/projects/proj_abc/rate_limits?after=rl_xxx&limit=20 \
9844 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
9845 -H "Content-Type: application/json"
9846 response: |
9847 {
9848 "object": "list",
9849 "data": [
9850 {
9851 "object": "project.rate_limit",
9852 "id": "rl-ada",
9853 "model": "ada",
9854 "max_requests_per_1_minute": 600,
9855 "max_tokens_per_1_minute": 150000,
9856 "max_images_per_1_minute": 10
9857 }
9858 ],
9859 "first_id": "rl-ada",
9860 "last_id": "rl-ada",
9861 "has_more": false
9862 }
9863 error_response: |
9864 {
9865 "code": 404,
9866 "message": "The project {project_id} was not found"
9867 }
9868 /organization/projects/{project_id}/rate_limits/{rate_limit_id}:
9869 post:
9870 summary: Updates a project rate limit.
9871 operationId: update-project-rate-limits
9872 tags:
9873 - Projects
9874 parameters:
9875 - name: project_id
9876 in: path
9877 description: The ID of the project.
9878 required: true
9879 schema:
9880 type: string
9881 - name: rate_limit_id
9882 in: path
9883 description: The ID of the rate limit.
9884 required: true
9885 schema:
9886 type: string
9887 requestBody:
9888 description: The project rate limit update request payload.
9889 required: true
9890 content:
9891 application/json:
9892 schema:
9893 $ref: "#/components/schemas/ProjectRateLimitUpdateRequest"
9894 responses:
9895 "200":
9896 description: Project rate limit updated successfully.
9897 content:
9898 application/json:
9899 schema:
9900 $ref: "#/components/schemas/ProjectRateLimit"
9901 "400":
9902 description: Error response for various conditions.
9903 content:
9904 application/json:
9905 schema:
9906 $ref: "#/components/schemas/ErrorResponse"
9907 x-oaiMeta:
9908 name: Modify project rate limit
9909 group: administration
9910 returns: The updated
9911 [ProjectRateLimit](/docs/api-reference/project-rate-limits/object)
9912 object.
9913 examples:
9914 request:
9915 curl: |
9916 curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/rate_limits/rl_xxx \
9917 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
9918 -H "Content-Type: application/json" \
9919 -d '{
9920 "max_requests_per_1_minute": 500
9921 }'
9922 response: |
9923 {
9924 "object": "project.rate_limit",
9925 "id": "rl-ada",
9926 "model": "ada",
9927 "max_requests_per_1_minute": 600,
9928 "max_tokens_per_1_minute": 150000,
9929 "max_images_per_1_minute": 10
9930 }
9931 error_response: |
9932 {
9933 "code": 404,
9934 "message": "The project {project_id} was not found"
9935 }
9936 /organization/projects/{project_id}/service_accounts:
9937 get:
9938 summary: Returns a list of service accounts in the project.
9939 operationId: list-project-service-accounts
9940 tags:
9941 - Projects
9942 parameters:
9943 - name: project_id
9944 in: path
9945 description: The ID of the project.
9946 required: true
9947 schema:
9948 type: string
9949 - name: limit
9950 in: query
9951 description: >
9952 A limit on the number of objects to be returned. Limit can range
9953 between 1 and 100, and the default is 20.
9954 required: false
9955 schema:
9956 type: integer
9957 default: 20
9958 - name: after
9959 in: query
9960 description: >
9961 A cursor for use in pagination. `after` is an object ID that defines
9962 your place in the list. For instance, if you make a list request and
9963 receive 100 objects, ending with obj_foo, your subsequent call can
9964 include after=obj_foo in order to fetch the next page of the list.
9965 required: false
9966 schema:
9967 type: string
9968 responses:
9969 "200":
9970 description: Project service accounts listed successfully.
9971 content:
9972 application/json:
9973 schema:
9974 $ref: "#/components/schemas/ProjectServiceAccountListResponse"
9975 "400":
9976 description: Error response when project is archived.
9977 content:
9978 application/json:
9979 schema:
9980 $ref: "#/components/schemas/ErrorResponse"
9981 x-oaiMeta:
9982 name: List project service accounts
9983 group: administration
9984 returns: A list of
9985 [ProjectServiceAccount](/docs/api-reference/project-service-accounts/object)
9986 objects.
9987 examples:
9988 request:
9989 curl: |
9990 curl https://api.openai.com/v1/organization/projects/proj_abc/service_accounts?after=custom_id&limit=20 \
9991 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
9992 -H "Content-Type: application/json"
9993 response: |
9994 {
9995 "object": "list",
9996 "data": [
9997 {
9998 "object": "organization.project.service_account",
9999 "id": "svc_acct_abc",
10000 "name": "Service Account",
10001 "role": "owner",
10002 "created_at": 1711471533
10003 }
10004 ],
10005 "first_id": "svc_acct_abc",
10006 "last_id": "svc_acct_xyz",
10007 "has_more": false
10008 }
10009 post:
10010 summary: Creates a new service account in the project. This also returns an
10011 unredacted API key for the service account.
10012 operationId: create-project-service-account
10013 tags:
10014 - Projects
10015 parameters:
10016 - name: project_id
10017 in: path
10018 description: The ID of the project.
10019 required: true
10020 schema:
10021 type: string
10022 requestBody:
10023 description: The project service account create request payload.
10024 required: true
10025 content:
10026 application/json:
10027 schema:
10028 $ref: "#/components/schemas/ProjectServiceAccountCreateRequest"
10029 responses:
10030 "200":
10031 description: Project service account created successfully.
10032 content:
10033 application/json:
10034 schema:
10035 $ref: "#/components/schemas/ProjectServiceAccountCreateResponse"
10036 "400":
10037 description: Error response when project is archived.
10038 content:
10039 application/json:
10040 schema:
10041 $ref: "#/components/schemas/ErrorResponse"
10042 x-oaiMeta:
10043 name: Create project service account
10044 group: administration
10045 returns: The created
10046 [ProjectServiceAccount](/docs/api-reference/project-service-accounts/object)
10047 object.
10048 examples:
10049 request:
10050 curl: |
10051 curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/service_accounts \
10052 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
10053 -H "Content-Type: application/json" \
10054 -d '{
10055 "name": "Production App"
10056 }'
10057 response: |
10058 {
10059 "object": "organization.project.service_account",
10060 "id": "svc_acct_abc",
10061 "name": "Production App",
10062 "role": "member",
10063 "created_at": 1711471533,
10064 "api_key": {
10065 "object": "organization.project.service_account.api_key",
10066 "value": "sk-abcdefghijklmnop123",
10067 "name": "Secret Key",
10068 "created_at": 1711471533,
10069 "id": "key_abc"
10070 }
10071 }
10072 /organization/projects/{project_id}/service_accounts/{service_account_id}:
10073 get:
10074 summary: Retrieves a service account in the project.
10075 operationId: retrieve-project-service-account
10076 tags:
10077 - Projects
10078 parameters:
10079 - name: project_id
10080 in: path
10081 description: The ID of the project.
10082 required: true
10083 schema:
10084 type: string
10085 - name: service_account_id
10086 in: path
10087 description: The ID of the service account.
10088 required: true
10089 schema:
10090 type: string
10091 responses:
10092 "200":
10093 description: Project service account retrieved successfully.
10094 content:
10095 application/json:
10096 schema:
10097 $ref: "#/components/schemas/ProjectServiceAccount"
10098 x-oaiMeta:
10099 name: Retrieve project service account
10100 group: administration
10101 returns: The
10102 [ProjectServiceAccount](/docs/api-reference/project-service-accounts/object)
10103 object matching the specified ID.
10104 examples:
10105 request:
10106 curl: |
10107 curl https://api.openai.com/v1/organization/projects/proj_abc/service_accounts/svc_acct_abc \
10108 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
10109 -H "Content-Type: application/json"
10110 response: |
10111 {
10112 "object": "organization.project.service_account",
10113 "id": "svc_acct_abc",
10114 "name": "Service Account",
10115 "role": "owner",
10116 "created_at": 1711471533
10117 }
10118 delete:
10119 summary: Deletes a service account from the project.
10120 operationId: delete-project-service-account
10121 tags:
10122 - Projects
10123 parameters:
10124 - name: project_id
10125 in: path
10126 description: The ID of the project.
10127 required: true
10128 schema:
10129 type: string
10130 - name: service_account_id
10131 in: path
10132 description: The ID of the service account.
10133 required: true
10134 schema:
10135 type: string
10136 responses:
10137 "200":
10138 description: Project service account deleted successfully.
10139 content:
10140 application/json:
10141 schema:
10142 $ref: "#/components/schemas/ProjectServiceAccountDeleteResponse"
10143 x-oaiMeta:
10144 name: Delete project service account
10145 group: administration
10146 returns: Confirmation of service account being deleted, or an error in case of
10147 an archived project, which has no service accounts
10148 examples:
10149 request:
10150 curl: |
10151 curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc/service_accounts/svc_acct_abc \
10152 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
10153 -H "Content-Type: application/json"
10154 response: |
10155 {
10156 "object": "organization.project.service_account.deleted",
10157 "id": "svc_acct_abc",
10158 "deleted": true
10159 }
10160 /organization/projects/{project_id}/users:
10161 get:
10162 summary: Returns a list of users in the project.
10163 operationId: list-project-users
10164 tags:
10165 - Projects
10166 parameters:
10167 - name: project_id
10168 in: path
10169 description: The ID of the project.
10170 required: true
10171 schema:
10172 type: string
10173 - name: limit
10174 in: query
10175 description: >
10176 A limit on the number of objects to be returned. Limit can range
10177 between 1 and 100, and the default is 20.
10178 required: false
10179 schema:
10180 type: integer
10181 default: 20
10182 - name: after
10183 in: query
10184 description: >
10185 A cursor for use in pagination. `after` is an object ID that defines
10186 your place in the list. For instance, if you make a list request and
10187 receive 100 objects, ending with obj_foo, your subsequent call can
10188 include after=obj_foo in order to fetch the next page of the list.
10189 required: false
10190 schema:
10191 type: string
10192 responses:
10193 "200":
10194 description: Project users listed successfully.
10195 content:
10196 application/json:
10197 schema:
10198 $ref: "#/components/schemas/ProjectUserListResponse"
10199 "400":
10200 description: Error response when project is archived.
10201 content:
10202 application/json:
10203 schema:
10204 $ref: "#/components/schemas/ErrorResponse"
10205 x-oaiMeta:
10206 name: List project users
10207 group: administration
10208 returns: A list of [ProjectUser](/docs/api-reference/project-users/object)
10209 objects.
10210 examples:
10211 request:
10212 curl: |
10213 curl https://api.openai.com/v1/organization/projects/proj_abc/users?after=user_abc&limit=20 \
10214 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
10215 -H "Content-Type: application/json"
10216 response: |
10217 {
10218 "object": "list",
10219 "data": [
10220 {
10221 "object": "organization.project.user",
10222 "id": "user_abc",
10223 "name": "First Last",
10224 "email": "user@example.com",
10225 "role": "owner",
10226 "added_at": 1711471533
10227 }
10228 ],
10229 "first_id": "user-abc",
10230 "last_id": "user-xyz",
10231 "has_more": false
10232 }
10233 post:
10234 summary: Adds a user to the project. Users must already be members of the
10235 organization to be added to a project.
10236 operationId: create-project-user
10237 parameters:
10238 - name: project_id
10239 in: path
10240 description: The ID of the project.
10241 required: true
10242 schema:
10243 type: string
10244 tags:
10245 - Projects
10246 requestBody:
10247 description: The project user create request payload.
10248 required: true
10249 content:
10250 application/json:
10251 schema:
10252 $ref: "#/components/schemas/ProjectUserCreateRequest"
10253 responses:
10254 "200":
10255 description: User added to project successfully.
10256 content:
10257 application/json:
10258 schema:
10259 $ref: "#/components/schemas/ProjectUser"
10260 "400":
10261 description: Error response for various conditions.
10262 content:
10263 application/json:
10264 schema:
10265 $ref: "#/components/schemas/ErrorResponse"
10266 x-oaiMeta:
10267 name: Create project user
10268 group: administration
10269 returns: The created [ProjectUser](/docs/api-reference/project-users/object)
10270 object.
10271 examples:
10272 request:
10273 curl: >
10274 curl -X POST
10275 https://api.openai.com/v1/organization/projects/proj_abc/users \
10276 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
10277 -H "Content-Type: application/json" \
10278 -d '{
10279 "user_id": "user_abc",
10280 "role": "member"
10281 }'
10282 response: |
10283 {
10284 "object": "organization.project.user",
10285 "id": "user_abc",
10286 "email": "user@example.com",
10287 "role": "owner",
10288 "added_at": 1711471533
10289 }
10290 /organization/projects/{project_id}/users/{user_id}:
10291 get:
10292 summary: Retrieves a user in the project.
10293 operationId: retrieve-project-user
10294 tags:
10295 - Projects
10296 parameters:
10297 - name: project_id
10298 in: path
10299 description: The ID of the project.
10300 required: true
10301 schema:
10302 type: string
10303 - name: user_id
10304 in: path
10305 description: The ID of the user.
10306 required: true
10307 schema:
10308 type: string
10309 responses:
10310 "200":
10311 description: Project user retrieved successfully.
10312 content:
10313 application/json:
10314 schema:
10315 $ref: "#/components/schemas/ProjectUser"
10316 x-oaiMeta:
10317 name: Retrieve project user
10318 group: administration
10319 returns: The [ProjectUser](/docs/api-reference/project-users/object) object
10320 matching the specified ID.
10321 examples:
10322 request:
10323 curl: |
10324 curl https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc \
10325 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
10326 -H "Content-Type: application/json"
10327 response: |
10328 {
10329 "object": "organization.project.user",
10330 "id": "user_abc",
10331 "name": "First Last",
10332 "email": "user@example.com",
10333 "role": "owner",
10334 "added_at": 1711471533
10335 }
10336 post:
10337 summary: Modifies a user's role in the project.
10338 operationId: modify-project-user
10339 tags:
10340 - Projects
10341 parameters:
10342 - name: project_id
10343 in: path
10344 description: The ID of the project.
10345 required: true
10346 schema:
10347 type: string
10348 - name: user_id
10349 in: path
10350 description: The ID of the user.
10351 required: true
10352 schema:
10353 type: string
10354 requestBody:
10355 description: The project user update request payload.
10356 required: true
10357 content:
10358 application/json:
10359 schema:
10360 $ref: "#/components/schemas/ProjectUserUpdateRequest"
10361 responses:
10362 "200":
10363 description: Project user's role updated successfully.
10364 content:
10365 application/json:
10366 schema:
10367 $ref: "#/components/schemas/ProjectUser"
10368 "400":
10369 description: Error response for various conditions.
10370 content:
10371 application/json:
10372 schema:
10373 $ref: "#/components/schemas/ErrorResponse"
10374 x-oaiMeta:
10375 name: Modify project user
10376 group: administration
10377 returns: The updated [ProjectUser](/docs/api-reference/project-users/object)
10378 object.
10379 examples:
10380 request:
10381 curl: |
10382 curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc \
10383 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
10384 -H "Content-Type: application/json" \
10385 -d '{
10386 "role": "owner"
10387 }'
10388 response: |
10389 {
10390 "object": "organization.project.user",
10391 "id": "user_abc",
10392 "name": "First Last",
10393 "email": "user@example.com",
10394 "role": "owner",
10395 "added_at": 1711471533
10396 }
10397 delete:
10398 summary: Deletes a user from the project.
10399 operationId: delete-project-user
10400 tags:
10401 - Projects
10402 parameters:
10403 - name: project_id
10404 in: path
10405 description: The ID of the project.
10406 required: true
10407 schema:
10408 type: string
10409 - name: user_id
10410 in: path
10411 description: The ID of the user.
10412 required: true
10413 schema:
10414 type: string
10415 responses:
10416 "200":
10417 description: Project user deleted successfully.
10418 content:
10419 application/json:
10420 schema:
10421 $ref: "#/components/schemas/ProjectUserDeleteResponse"
10422 "400":
10423 description: Error response for various conditions.
10424 content:
10425 application/json:
10426 schema:
10427 $ref: "#/components/schemas/ErrorResponse"
10428 x-oaiMeta:
10429 name: Delete project user
10430 group: administration
10431 returns: Confirmation that project has been deleted or an error in case of an
10432 archived project, which has no users
10433 examples:
10434 request:
10435 curl: |
10436 curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc \
10437 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
10438 -H "Content-Type: application/json"
10439 response: |
10440 {
10441 "object": "organization.project.user.deleted",
10442 "id": "user_abc",
10443 "deleted": true
10444 }
10445 /organization/usage/audio_speeches:
10446 get:
10447 summary: Get audio speeches usage details for the organization.
10448 operationId: usage-audio-speeches
10449 tags:
10450 - Usage
10451 parameters:
10452 - name: start_time
10453 in: query
10454 description: Start time (Unix seconds) of the query time range, inclusive.
10455 required: true
10456 schema:
10457 type: integer
10458 - name: end_time
10459 in: query
10460 description: End time (Unix seconds) of the query time range, exclusive.
10461 required: false
10462 schema:
10463 type: integer
10464 - name: bucket_width
10465 in: query
10466 description: Width of each time bucket in response. Currently `1m`, `1h` and
10467 `1d` are supported, default to `1d`.
10468 required: false
10469 schema:
10470 type: string
10471 enum:
10472 - 1m
10473 - 1h
10474 - 1d
10475 default: 1d
10476 - name: project_ids
10477 in: query
10478 description: Return only usage for these projects.
10479 required: false
10480 schema:
10481 type: array
10482 items:
10483 type: string
10484 - name: user_ids
10485 in: query
10486 description: Return only usage for these users.
10487 required: false
10488 schema:
10489 type: array
10490 items:
10491 type: string
10492 - name: api_key_ids
10493 in: query
10494 description: Return only usage for these API keys.
10495 required: false
10496 schema:
10497 type: array
10498 items:
10499 type: string
10500 - name: models
10501 in: query
10502 description: Return only usage for these models.
10503 required: false
10504 schema:
10505 type: array
10506 items:
10507 type: string
10508 - name: group_by
10509 in: query
10510 description: Group the usage data by the specified fields. Support fields
10511 include `project_id`, `user_id`, `api_key_id`, `model` or any
10512 combination of them.
10513 required: false
10514 schema:
10515 type: array
10516 items:
10517 type: string
10518 enum:
10519 - project_id
10520 - user_id
10521 - api_key_id
10522 - model
10523 - name: limit
10524 in: query
10525 description: |
10526 Specifies the number of buckets to return.
10527 - `bucket_width=1d`: default: 7, max: 31
10528 - `bucket_width=1h`: default: 24, max: 168
10529 - `bucket_width=1m`: default: 60, max: 1440
10530 required: false
10531 schema:
10532 type: integer
10533 - name: page
10534 in: query
10535 description: A cursor for use in pagination. Corresponding to the `next_page`
10536 field from the previous response.
10537 schema:
10538 type: string
10539 responses:
10540 "200":
10541 description: Usage data retrieved successfully.
10542 content:
10543 application/json:
10544 schema:
10545 $ref: "#/components/schemas/UsageResponse"
10546 x-oaiMeta:
10547 name: Audio speeches
10548 group: usage-audio-speeches
10549 returns: A list of paginated, time bucketed [Audio speeches
10550 usage](/docs/api-reference/usage/audio_speeches_object) objects.
10551 examples:
10552 request:
10553 curl: |
10554 curl "https://api.openai.com/v1/organization/usage/audio_speeches?start_time=1730419200&limit=1" \
10555 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
10556 -H "Content-Type: application/json"
10557 response: >
10558 {
10559 "object": "page",
10560 "data": [
10561 {
10562 "object": "bucket",
10563 "start_time": 1730419200,
10564 "end_time": 1730505600,
10565 "results": [
10566 {
10567 "object": "organization.usage.audio_speeches.result",
10568 "characters": 45,
10569 "num_model_requests": 1,
10570 "project_id": null,
10571 "user_id": null,
10572 "api_key_id": null,
10573 "model": null
10574 }
10575 ]
10576 }
10577 ],
10578 "has_more": false,
10579 "next_page": null
10580 }
10581 /organization/usage/audio_transcriptions:
10582 get:
10583 summary: Get audio transcriptions usage details for the organization.
10584 operationId: usage-audio-transcriptions
10585 tags:
10586 - Usage
10587 parameters:
10588 - name: start_time
10589 in: query
10590 description: Start time (Unix seconds) of the query time range, inclusive.
10591 required: true
10592 schema:
10593 type: integer
10594 - name: end_time
10595 in: query
10596 description: End time (Unix seconds) of the query time range, exclusive.
10597 required: false
10598 schema:
10599 type: integer
10600 - name: bucket_width
10601 in: query
10602 description: Width of each time bucket in response. Currently `1m`, `1h` and
10603 `1d` are supported, default to `1d`.
10604 required: false
10605 schema:
10606 type: string
10607 enum:
10608 - 1m
10609 - 1h
10610 - 1d
10611 default: 1d
10612 - name: project_ids
10613 in: query
10614 description: Return only usage for these projects.
10615 required: false
10616 schema:
10617 type: array
10618 items:
10619 type: string
10620 - name: user_ids
10621 in: query
10622 description: Return only usage for these users.
10623 required: false
10624 schema:
10625 type: array
10626 items:
10627 type: string
10628 - name: api_key_ids
10629 in: query
10630 description: Return only usage for these API keys.
10631 required: false
10632 schema:
10633 type: array
10634 items:
10635 type: string
10636 - name: models
10637 in: query
10638 description: Return only usage for these models.
10639 required: false
10640 schema:
10641 type: array
10642 items:
10643 type: string
10644 - name: group_by
10645 in: query
10646 description: Group the usage data by the specified fields. Support fields
10647 include `project_id`, `user_id`, `api_key_id`, `model` or any
10648 combination of them.
10649 required: false
10650 schema:
10651 type: array
10652 items:
10653 type: string
10654 enum:
10655 - project_id
10656 - user_id
10657 - api_key_id
10658 - model
10659 - name: limit
10660 in: query
10661 description: |
10662 Specifies the number of buckets to return.
10663 - `bucket_width=1d`: default: 7, max: 31
10664 - `bucket_width=1h`: default: 24, max: 168
10665 - `bucket_width=1m`: default: 60, max: 1440
10666 required: false
10667 schema:
10668 type: integer
10669 - name: page
10670 in: query
10671 description: A cursor for use in pagination. Corresponding to the `next_page`
10672 field from the previous response.
10673 schema:
10674 type: string
10675 responses:
10676 "200":
10677 description: Usage data retrieved successfully.
10678 content:
10679 application/json:
10680 schema:
10681 $ref: "#/components/schemas/UsageResponse"
10682 x-oaiMeta:
10683 name: Audio transcriptions
10684 group: usage-audio-transcriptions
10685 returns: A list of paginated, time bucketed [Audio transcriptions
10686 usage](/docs/api-reference/usage/audio_transcriptions_object) objects.
10687 examples:
10688 request:
10689 curl: |
10690 curl "https://api.openai.com/v1/organization/usage/audio_transcriptions?start_time=1730419200&limit=1" \
10691 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
10692 -H "Content-Type: application/json"
10693 response: >
10694 {
10695 "object": "page",
10696 "data": [
10697 {
10698 "object": "bucket",
10699 "start_time": 1730419200,
10700 "end_time": 1730505600,
10701 "results": [
10702 {
10703 "object": "organization.usage.audio_transcriptions.result",
10704 "seconds": 20,
10705 "num_model_requests": 1,
10706 "project_id": null,
10707 "user_id": null,
10708 "api_key_id": null,
10709 "model": null
10710 }
10711 ]
10712 }
10713 ],
10714 "has_more": false,
10715 "next_page": null
10716 }
10717 /organization/usage/code_interpreter_sessions:
10718 get:
10719 summary: Get code interpreter sessions usage details for the organization.
10720 operationId: usage-code-interpreter-sessions
10721 tags:
10722 - Usage
10723 parameters:
10724 - name: start_time
10725 in: query
10726 description: Start time (Unix seconds) of the query time range, inclusive.
10727 required: true
10728 schema:
10729 type: integer
10730 - name: end_time
10731 in: query
10732 description: End time (Unix seconds) of the query time range, exclusive.
10733 required: false
10734 schema:
10735 type: integer
10736 - name: bucket_width
10737 in: query
10738 description: Width of each time bucket in response. Currently `1m`, `1h` and
10739 `1d` are supported, default to `1d`.
10740 required: false
10741 schema:
10742 type: string
10743 enum:
10744 - 1m
10745 - 1h
10746 - 1d
10747 default: 1d
10748 - name: project_ids
10749 in: query
10750 description: Return only usage for these projects.
10751 required: false
10752 schema:
10753 type: array
10754 items:
10755 type: string
10756 - name: group_by
10757 in: query
10758 description: Group the usage data by the specified fields. Support fields
10759 include `project_id`.
10760 required: false
10761 schema:
10762 type: array
10763 items:
10764 type: string
10765 enum:
10766 - project_id
10767 - name: limit
10768 in: query
10769 description: |
10770 Specifies the number of buckets to return.
10771 - `bucket_width=1d`: default: 7, max: 31
10772 - `bucket_width=1h`: default: 24, max: 168
10773 - `bucket_width=1m`: default: 60, max: 1440
10774 required: false
10775 schema:
10776 type: integer
10777 - name: page
10778 in: query
10779 description: A cursor for use in pagination. Corresponding to the `next_page`
10780 field from the previous response.
10781 schema:
10782 type: string
10783 responses:
10784 "200":
10785 description: Usage data retrieved successfully.
10786 content:
10787 application/json:
10788 schema:
10789 $ref: "#/components/schemas/UsageResponse"
10790 x-oaiMeta:
10791 name: Code interpreter sessions
10792 group: usage-code-interpreter-sessions
10793 returns: A list of paginated, time bucketed [Code interpreter sessions
10794 usage](/docs/api-reference/usage/code_interpreter_sessions_object)
10795 objects.
10796 examples:
10797 request:
10798 curl: |
10799 curl "https://api.openai.com/v1/organization/usage/code_interpreter_sessions?start_time=1730419200&limit=1" \
10800 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
10801 -H "Content-Type: application/json"
10802 response: >
10803 {
10804 "object": "page",
10805 "data": [
10806 {
10807 "object": "bucket",
10808 "start_time": 1730419200,
10809 "end_time": 1730505600,
10810 "results": [
10811 {
10812 "object": "organization.usage.code_interpreter_sessions.result",
10813 "num_sessions": 1,
10814 "project_id": null
10815 }
10816 ]
10817 }
10818 ],
10819 "has_more": false,
10820 "next_page": null
10821 }
10822 /organization/usage/completions:
10823 get:
10824 summary: Get completions usage details for the organization.
10825 operationId: usage-completions
10826 tags:
10827 - Usage
10828 parameters:
10829 - name: start_time
10830 in: query
10831 description: Start time (Unix seconds) of the query time range, inclusive.
10832 required: true
10833 schema:
10834 type: integer
10835 - name: end_time
10836 in: query
10837 description: End time (Unix seconds) of the query time range, exclusive.
10838 required: false
10839 schema:
10840 type: integer
10841 - name: bucket_width
10842 in: query
10843 description: Width of each time bucket in response. Currently `1m`, `1h` and
10844 `1d` are supported, default to `1d`.
10845 required: false
10846 schema:
10847 type: string
10848 enum:
10849 - 1m
10850 - 1h
10851 - 1d
10852 default: 1d
10853 - name: project_ids
10854 in: query
10855 description: Return only usage for these projects.
10856 required: false
10857 schema:
10858 type: array
10859 items:
10860 type: string
10861 - name: user_ids
10862 in: query
10863 description: Return only usage for these users.
10864 required: false
10865 schema:
10866 type: array
10867 items:
10868 type: string
10869 - name: api_key_ids
10870 in: query
10871 description: Return only usage for these API keys.
10872 required: false
10873 schema:
10874 type: array
10875 items:
10876 type: string
10877 - name: models
10878 in: query
10879 description: Return only usage for these models.
10880 required: false
10881 schema:
10882 type: array
10883 items:
10884 type: string
10885 - name: batch
10886 in: query
10887 description: >
10888 If `true`, return batch jobs only. If `false`, return non-batch jobs
10889 only. By default, return both.
10890 required: false
10891 schema:
10892 type: boolean
10893 - name: group_by
10894 in: query
10895 description: Group the usage data by the specified fields. Support fields
10896 include `project_id`, `user_id`, `api_key_id`, `model`, `batch` or
10897 any combination of them.
10898 required: false
10899 schema:
10900 type: array
10901 items:
10902 type: string
10903 enum:
10904 - project_id
10905 - user_id
10906 - api_key_id
10907 - model
10908 - batch
10909 - name: limit
10910 in: query
10911 description: |
10912 Specifies the number of buckets to return.
10913 - `bucket_width=1d`: default: 7, max: 31
10914 - `bucket_width=1h`: default: 24, max: 168
10915 - `bucket_width=1m`: default: 60, max: 1440
10916 required: false
10917 schema:
10918 type: integer
10919 - name: page
10920 in: query
10921 description: A cursor for use in pagination. Corresponding to the `next_page`
10922 field from the previous response.
10923 schema:
10924 type: string
10925 responses:
10926 "200":
10927 description: Usage data retrieved successfully.
10928 content:
10929 application/json:
10930 schema:
10931 $ref: "#/components/schemas/UsageResponse"
10932 x-oaiMeta:
10933 name: Completions
10934 group: usage-completions
10935 returns: A list of paginated, time bucketed [Completions
10936 usage](/docs/api-reference/usage/completions_object) objects.
10937 examples:
10938 request:
10939 curl: |
10940 curl "https://api.openai.com/v1/organization/usage/completions?start_time=1730419200&limit=1" \
10941 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
10942 -H "Content-Type: application/json"
10943 response: >
10944 {
10945 "object": "page",
10946 "data": [
10947 {
10948 "object": "bucket",
10949 "start_time": 1730419200,
10950 "end_time": 1730505600,
10951 "results": [
10952 {
10953 "object": "organization.usage.completions.result",
10954 "input_tokens": 1000,
10955 "output_tokens": 500,
10956 "input_cached_tokens": 800,
10957 "input_audio_tokens": 0,
10958 "output_audio_tokens": 0,
10959 "num_model_requests": 5,
10960 "project_id": null,
10961 "user_id": null,
10962 "api_key_id": null,
10963 "model": null,
10964 "batch": null
10965 }
10966 ]
10967 }
10968 ],
10969 "has_more": true,
10970 "next_page": "page_AAAAAGdGxdEiJdKOAAAAAGcqsYA="
10971 }
10972 /organization/usage/embeddings:
10973 get:
10974 summary: Get embeddings usage details for the organization.
10975 operationId: usage-embeddings
10976 tags:
10977 - Usage
10978 parameters:
10979 - name: start_time
10980 in: query
10981 description: Start time (Unix seconds) of the query time range, inclusive.
10982 required: true
10983 schema:
10984 type: integer
10985 - name: end_time
10986 in: query
10987 description: End time (Unix seconds) of the query time range, exclusive.
10988 required: false
10989 schema:
10990 type: integer
10991 - name: bucket_width
10992 in: query
10993 description: Width of each time bucket in response. Currently `1m`, `1h` and
10994 `1d` are supported, default to `1d`.
10995 required: false
10996 schema:
10997 type: string
10998 enum:
10999 - 1m
11000 - 1h
11001 - 1d
11002 default: 1d
11003 - name: project_ids
11004 in: query
11005 description: Return only usage for these projects.
11006 required: false
11007 schema:
11008 type: array
11009 items:
11010 type: string
11011 - name: user_ids
11012 in: query
11013 description: Return only usage for these users.
11014 required: false
11015 schema:
11016 type: array
11017 items:
11018 type: string
11019 - name: api_key_ids
11020 in: query
11021 description: Return only usage for these API keys.
11022 required: false
11023 schema:
11024 type: array
11025 items:
11026 type: string
11027 - name: models
11028 in: query
11029 description: Return only usage for these models.
11030 required: false
11031 schema:
11032 type: array
11033 items:
11034 type: string
11035 - name: group_by
11036 in: query
11037 description: Group the usage data by the specified fields. Support fields
11038 include `project_id`, `user_id`, `api_key_id`, `model` or any
11039 combination of them.
11040 required: false
11041 schema:
11042 type: array
11043 items:
11044 type: string
11045 enum:
11046 - project_id
11047 - user_id
11048 - api_key_id
11049 - model
11050 - name: limit
11051 in: query
11052 description: |
11053 Specifies the number of buckets to return.
11054 - `bucket_width=1d`: default: 7, max: 31
11055 - `bucket_width=1h`: default: 24, max: 168
11056 - `bucket_width=1m`: default: 60, max: 1440
11057 required: false
11058 schema:
11059 type: integer
11060 - name: page
11061 in: query
11062 description: A cursor for use in pagination. Corresponding to the `next_page`
11063 field from the previous response.
11064 schema:
11065 type: string
11066 responses:
11067 "200":
11068 description: Usage data retrieved successfully.
11069 content:
11070 application/json:
11071 schema:
11072 $ref: "#/components/schemas/UsageResponse"
11073 x-oaiMeta:
11074 name: Embeddings
11075 group: usage-embeddings
11076 returns: A list of paginated, time bucketed [Embeddings
11077 usage](/docs/api-reference/usage/embeddings_object) objects.
11078 examples:
11079 request:
11080 curl: |
11081 curl "https://api.openai.com/v1/organization/usage/embeddings?start_time=1730419200&limit=1" \
11082 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
11083 -H "Content-Type: application/json"
11084 response: >
11085 {
11086 "object": "page",
11087 "data": [
11088 {
11089 "object": "bucket",
11090 "start_time": 1730419200,
11091 "end_time": 1730505600,
11092 "results": [
11093 {
11094 "object": "organization.usage.embeddings.result",
11095 "input_tokens": 16,
11096 "num_model_requests": 2,
11097 "project_id": null,
11098 "user_id": null,
11099 "api_key_id": null,
11100 "model": null
11101 }
11102 ]
11103 }
11104 ],
11105 "has_more": false,
11106 "next_page": null
11107 }
11108 /organization/usage/images:
11109 get:
11110 summary: Get images usage details for the organization.
11111 operationId: usage-images
11112 tags:
11113 - Usage
11114 parameters:
11115 - name: start_time
11116 in: query
11117 description: Start time (Unix seconds) of the query time range, inclusive.
11118 required: true
11119 schema:
11120 type: integer
11121 - name: end_time
11122 in: query
11123 description: End time (Unix seconds) of the query time range, exclusive.
11124 required: false
11125 schema:
11126 type: integer
11127 - name: bucket_width
11128 in: query
11129 description: Width of each time bucket in response. Currently `1m`, `1h` and
11130 `1d` are supported, default to `1d`.
11131 required: false
11132 schema:
11133 type: string
11134 enum:
11135 - 1m
11136 - 1h
11137 - 1d
11138 default: 1d
11139 - name: sources
11140 in: query
11141 description: Return only usages for these sources. Possible values are
11142 `image.generation`, `image.edit`, `image.variation` or any
11143 combination of them.
11144 required: false
11145 schema:
11146 type: array
11147 items:
11148 type: string
11149 enum:
11150 - image.generation
11151 - image.edit
11152 - image.variation
11153 - name: sizes
11154 in: query
11155 description: Return only usages for these image sizes. Possible values are
11156 `256x256`, `512x512`, `1024x1024`, `1792x1792`, `1024x1792` or any
11157 combination of them.
11158 required: false
11159 schema:
11160 type: array
11161 items:
11162 type: string
11163 enum:
11164 - 256x256
11165 - 512x512
11166 - 1024x1024
11167 - 1792x1792
11168 - 1024x1792
11169 - name: project_ids
11170 in: query
11171 description: Return only usage for these projects.
11172 required: false
11173 schema:
11174 type: array
11175 items:
11176 type: string
11177 - name: user_ids
11178 in: query
11179 description: Return only usage for these users.
11180 required: false
11181 schema:
11182 type: array
11183 items:
11184 type: string
11185 - name: api_key_ids
11186 in: query
11187 description: Return only usage for these API keys.
11188 required: false
11189 schema:
11190 type: array
11191 items:
11192 type: string
11193 - name: models
11194 in: query
11195 description: Return only usage for these models.
11196 required: false
11197 schema:
11198 type: array
11199 items:
11200 type: string
11201 - name: group_by
11202 in: query
11203 description: Group the usage data by the specified fields. Support fields
11204 include `project_id`, `user_id`, `api_key_id`, `model`, `size`,
11205 `source` or any combination of them.
11206 required: false
11207 schema:
11208 type: array
11209 items:
11210 type: string
11211 enum:
11212 - project_id
11213 - user_id
11214 - api_key_id
11215 - model
11216 - size
11217 - source
11218 - name: limit
11219 in: query
11220 description: |
11221 Specifies the number of buckets to return.
11222 - `bucket_width=1d`: default: 7, max: 31
11223 - `bucket_width=1h`: default: 24, max: 168
11224 - `bucket_width=1m`: default: 60, max: 1440
11225 required: false
11226 schema:
11227 type: integer
11228 - name: page
11229 in: query
11230 description: A cursor for use in pagination. Corresponding to the `next_page`
11231 field from the previous response.
11232 schema:
11233 type: string
11234 responses:
11235 "200":
11236 description: Usage data retrieved successfully.
11237 content:
11238 application/json:
11239 schema:
11240 $ref: "#/components/schemas/UsageResponse"
11241 x-oaiMeta:
11242 name: Images
11243 group: usage-images
11244 returns: A list of paginated, time bucketed [Images
11245 usage](/docs/api-reference/usage/images_object) objects.
11246 examples:
11247 request:
11248 curl: |
11249 curl "https://api.openai.com/v1/organization/usage/images?start_time=1730419200&limit=1" \
11250 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
11251 -H "Content-Type: application/json"
11252 response: |
11253 {
11254 "object": "page",
11255 "data": [
11256 {
11257 "object": "bucket",
11258 "start_time": 1730419200,
11259 "end_time": 1730505600,
11260 "results": [
11261 {
11262 "object": "organization.usage.images.result",
11263 "images": 2,
11264 "num_model_requests": 2,
11265 "size": null,
11266 "source": null,
11267 "project_id": null,
11268 "user_id": null,
11269 "api_key_id": null,
11270 "model": null
11271 }
11272 ]
11273 }
11274 ],
11275 "has_more": false,
11276 "next_page": null
11277 }
11278 /organization/usage/moderations:
11279 get:
11280 summary: Get moderations usage details for the organization.
11281 operationId: usage-moderations
11282 tags:
11283 - Usage
11284 parameters:
11285 - name: start_time
11286 in: query
11287 description: Start time (Unix seconds) of the query time range, inclusive.
11288 required: true
11289 schema:
11290 type: integer
11291 - name: end_time
11292 in: query
11293 description: End time (Unix seconds) of the query time range, exclusive.
11294 required: false
11295 schema:
11296 type: integer
11297 - name: bucket_width
11298 in: query
11299 description: Width of each time bucket in response. Currently `1m`, `1h` and
11300 `1d` are supported, default to `1d`.
11301 required: false
11302 schema:
11303 type: string
11304 enum:
11305 - 1m
11306 - 1h
11307 - 1d
11308 default: 1d
11309 - name: project_ids
11310 in: query
11311 description: Return only usage for these projects.
11312 required: false
11313 schema:
11314 type: array
11315 items:
11316 type: string
11317 - name: user_ids
11318 in: query
11319 description: Return only usage for these users.
11320 required: false
11321 schema:
11322 type: array
11323 items:
11324 type: string
11325 - name: api_key_ids
11326 in: query
11327 description: Return only usage for these API keys.
11328 required: false
11329 schema:
11330 type: array
11331 items:
11332 type: string
11333 - name: models
11334 in: query
11335 description: Return only usage for these models.
11336 required: false
11337 schema:
11338 type: array
11339 items:
11340 type: string
11341 - name: group_by
11342 in: query
11343 description: Group the usage data by the specified fields. Support fields
11344 include `project_id`, `user_id`, `api_key_id`, `model` or any
11345 combination of them.
11346 required: false
11347 schema:
11348 type: array
11349 items:
11350 type: string
11351 enum:
11352 - project_id
11353 - user_id
11354 - api_key_id
11355 - model
11356 - name: limit
11357 in: query
11358 description: |
11359 Specifies the number of buckets to return.
11360 - `bucket_width=1d`: default: 7, max: 31
11361 - `bucket_width=1h`: default: 24, max: 168
11362 - `bucket_width=1m`: default: 60, max: 1440
11363 required: false
11364 schema:
11365 type: integer
11366 - name: page
11367 in: query
11368 description: A cursor for use in pagination. Corresponding to the `next_page`
11369 field from the previous response.
11370 schema:
11371 type: string
11372 responses:
11373 "200":
11374 description: Usage data retrieved successfully.
11375 content:
11376 application/json:
11377 schema:
11378 $ref: "#/components/schemas/UsageResponse"
11379 x-oaiMeta:
11380 name: Moderations
11381 group: usage-moderations
11382 returns: A list of paginated, time bucketed [Moderations
11383 usage](/docs/api-reference/usage/moderations_object) objects.
11384 examples:
11385 request:
11386 curl: |
11387 curl "https://api.openai.com/v1/organization/usage/moderations?start_time=1730419200&limit=1" \
11388 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
11389 -H "Content-Type: application/json"
11390 response: >
11391 {
11392 "object": "page",
11393 "data": [
11394 {
11395 "object": "bucket",
11396 "start_time": 1730419200,
11397 "end_time": 1730505600,
11398 "results": [
11399 {
11400 "object": "organization.usage.moderations.result",
11401 "input_tokens": 16,
11402 "num_model_requests": 2,
11403 "project_id": null,
11404 "user_id": null,
11405 "api_key_id": null,
11406 "model": null
11407 }
11408 ]
11409 }
11410 ],
11411 "has_more": false,
11412 "next_page": null
11413 }
11414 /organization/usage/vector_stores:
11415 get:
11416 summary: Get vector stores usage details for the organization.
11417 operationId: usage-vector-stores
11418 tags:
11419 - Usage
11420 parameters:
11421 - name: start_time
11422 in: query
11423 description: Start time (Unix seconds) of the query time range, inclusive.
11424 required: true
11425 schema:
11426 type: integer
11427 - name: end_time
11428 in: query
11429 description: End time (Unix seconds) of the query time range, exclusive.
11430 required: false
11431 schema:
11432 type: integer
11433 - name: bucket_width
11434 in: query
11435 description: Width of each time bucket in response. Currently `1m`, `1h` and
11436 `1d` are supported, default to `1d`.
11437 required: false
11438 schema:
11439 type: string
11440 enum:
11441 - 1m
11442 - 1h
11443 - 1d
11444 default: 1d
11445 - name: project_ids
11446 in: query
11447 description: Return only usage for these projects.
11448 required: false
11449 schema:
11450 type: array
11451 items:
11452 type: string
11453 - name: group_by
11454 in: query
11455 description: Group the usage data by the specified fields. Support fields
11456 include `project_id`.
11457 required: false
11458 schema:
11459 type: array
11460 items:
11461 type: string
11462 enum:
11463 - project_id
11464 - name: limit
11465 in: query
11466 description: |
11467 Specifies the number of buckets to return.
11468 - `bucket_width=1d`: default: 7, max: 31
11469 - `bucket_width=1h`: default: 24, max: 168
11470 - `bucket_width=1m`: default: 60, max: 1440
11471 required: false
11472 schema:
11473 type: integer
11474 - name: page
11475 in: query
11476 description: A cursor for use in pagination. Corresponding to the `next_page`
11477 field from the previous response.
11478 schema:
11479 type: string
11480 responses:
11481 "200":
11482 description: Usage data retrieved successfully.
11483 content:
11484 application/json:
11485 schema:
11486 $ref: "#/components/schemas/UsageResponse"
11487 x-oaiMeta:
11488 name: Vector stores
11489 group: usage-vector-stores
11490 returns: A list of paginated, time bucketed [Vector stores
11491 usage](/docs/api-reference/usage/vector_stores_object) objects.
11492 examples:
11493 request:
11494 curl: |
11495 curl "https://api.openai.com/v1/organization/usage/vector_stores?start_time=1730419200&limit=1" \
11496 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
11497 -H "Content-Type: application/json"
11498 response: >
11499 {
11500 "object": "page",
11501 "data": [
11502 {
11503 "object": "bucket",
11504 "start_time": 1730419200,
11505 "end_time": 1730505600,
11506 "results": [
11507 {
11508 "object": "organization.usage.vector_stores.result",
11509 "usage_bytes": 1024,
11510 "project_id": null
11511 }
11512 ]
11513 }
11514 ],
11515 "has_more": false,
11516 "next_page": null
11517 }
11518 /organization/users:
11519 get:
11520 summary: Lists all of the users in the organization.
11521 operationId: list-users
11522 tags:
11523 - Users
11524 parameters:
11525 - name: limit
11526 in: query
11527 description: >
11528 A limit on the number of objects to be returned. Limit can range
11529 between 1 and 100, and the default is 20.
11530 required: false
11531 schema:
11532 type: integer
11533 default: 20
11534 - name: after
11535 in: query
11536 description: >
11537 A cursor for use in pagination. `after` is an object ID that defines
11538 your place in the list. For instance, if you make a list request and
11539 receive 100 objects, ending with obj_foo, your subsequent call can
11540 include after=obj_foo in order to fetch the next page of the list.
11541 required: false
11542 schema:
11543 type: string
11544 - name: emails
11545 in: query
11546 description: Filter by the email address of users.
11547 required: false
11548 schema:
11549 type: array
11550 items:
11551 type: string
11552 responses:
11553 "200":
11554 description: Users listed successfully.
11555 content:
11556 application/json:
11557 schema:
11558 $ref: "#/components/schemas/UserListResponse"
11559 x-oaiMeta:
11560 name: List users
11561 group: administration
11562 returns: A list of [User](/docs/api-reference/users/object) objects.
11563 examples:
11564 request:
11565 curl: |
11566 curl https://api.openai.com/v1/organization/users?after=user_abc&limit=20 \
11567 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
11568 -H "Content-Type: application/json"
11569 response: |
11570 {
11571 "object": "list",
11572 "data": [
11573 {
11574 "object": "organization.user",
11575 "id": "user_abc",
11576 "name": "First Last",
11577 "email": "user@example.com",
11578 "role": "owner",
11579 "added_at": 1711471533
11580 }
11581 ],
11582 "first_id": "user-abc",
11583 "last_id": "user-xyz",
11584 "has_more": false
11585 }
11586 /organization/users/{user_id}:
11587 get:
11588 summary: Retrieves a user by their identifier.
11589 operationId: retrieve-user
11590 tags:
11591 - Users
11592 parameters:
11593 - name: user_id
11594 in: path
11595 description: The ID of the user.
11596 required: true
11597 schema:
11598 type: string
11599 responses:
11600 "200":
11601 description: User retrieved successfully.
11602 content:
11603 application/json:
11604 schema:
11605 $ref: "#/components/schemas/User"
11606 x-oaiMeta:
11607 name: Retrieve user
11608 group: administration
11609 returns: The [User](/docs/api-reference/users/object) object matching the
11610 specified ID.
11611 examples:
11612 request:
11613 curl: |
11614 curl https://api.openai.com/v1/organization/users/user_abc \
11615 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
11616 -H "Content-Type: application/json"
11617 response: |
11618 {
11619 "object": "organization.user",
11620 "id": "user_abc",
11621 "name": "First Last",
11622 "email": "user@example.com",
11623 "role": "owner",
11624 "added_at": 1711471533
11625 }
11626 post:
11627 summary: Modifies a user's role in the organization.
11628 operationId: modify-user
11629 tags:
11630 - Users
11631 parameters:
11632 - name: user_id
11633 in: path
11634 description: The ID of the user.
11635 required: true
11636 schema:
11637 type: string
11638 requestBody:
11639 description: The new user role to modify. This must be one of `owner` or `member`.
11640 required: true
11641 content:
11642 application/json:
11643 schema:
11644 $ref: "#/components/schemas/UserRoleUpdateRequest"
11645 responses:
11646 "200":
11647 description: User role updated successfully.
11648 content:
11649 application/json:
11650 schema:
11651 $ref: "#/components/schemas/User"
11652 x-oaiMeta:
11653 name: Modify user
11654 group: administration
11655 returns: The updated [User](/docs/api-reference/users/object) object.
11656 examples:
11657 request:
11658 curl: >
11659 curl -X POST https://api.openai.com/v1/organization/users/user_abc
11660 \
11661 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
11662 -H "Content-Type: application/json" \
11663 -d '{
11664 "role": "owner"
11665 }'
11666 response: |
11667 {
11668 "object": "organization.user",
11669 "id": "user_abc",
11670 "name": "First Last",
11671 "email": "user@example.com",
11672 "role": "owner",
11673 "added_at": 1711471533
11674 }
11675 delete:
11676 summary: Deletes a user from the organization.
11677 operationId: delete-user
11678 tags:
11679 - Users
11680 parameters:
11681 - name: user_id
11682 in: path
11683 description: The ID of the user.
11684 required: true
11685 schema:
11686 type: string
11687 responses:
11688 "200":
11689 description: User deleted successfully.
11690 content:
11691 application/json:
11692 schema:
11693 $ref: "#/components/schemas/UserDeleteResponse"
11694 x-oaiMeta:
11695 name: Delete user
11696 group: administration
11697 returns: Confirmation of the deleted user
11698 examples:
11699 request:
11700 curl: >
11701 curl -X DELETE
11702 https://api.openai.com/v1/organization/users/user_abc \
11703 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
11704 -H "Content-Type: application/json"
11705 response: |
11706 {
11707 "object": "organization.user.deleted",
11708 "id": "user_abc",
11709 "deleted": true
11710 }
11711 /realtime/sessions:
11712 post:
11713 summary: >
11714 Create an ephemeral API token for use in client-side applications with
11715 the
11716
11717 Realtime API. Can be configured with the same session parameters as the
11718
11719 `session.update` client event.
11720
11721
11722 It responds with a session object, plus a `client_secret` key which
11723 contains
11724
11725 a usable ephemeral API token that can be used to authenticate browser
11726 clients
11727
11728 for the Realtime API.
11729 operationId: create-realtime-session
11730 tags:
11731 - Realtime
11732 requestBody:
11733 description: Create an ephemeral API key with the given session configuration.
11734 required: true
11735 content:
11736 application/json:
11737 schema:
11738 $ref: "#/components/schemas/RealtimeSessionCreateRequest"
11739 responses:
11740 "200":
11741 description: Session created successfully.
11742 content:
11743 application/json:
11744 schema:
11745 $ref: "#/components/schemas/RealtimeSessionCreateResponse"
11746 x-oaiMeta:
11747 name: Create session
11748 group: realtime
11749 returns: The created Realtime session object, plus an ephemeral key
11750 examples:
11751 request:
11752 curl: |
11753 curl -X POST https://api.openai.com/v1/realtime/sessions \
11754 -H "Authorization: Bearer $OPENAI_API_KEY" \
11755 -H "Content-Type: application/json" \
11756 -d '{
11757 "model": "gpt-4o-realtime-preview",
11758 "modalities": ["audio", "text"],
11759 "instructions": "You are a friendly assistant."
11760 }'
11761 response: |
11762 {
11763 "id": "sess_001",
11764 "object": "realtime.session",
11765 "model": "gpt-4o-realtime-preview",
11766 "modalities": ["audio", "text"],
11767 "instructions": "You are a friendly assistant.",
11768 "voice": "alloy",
11769 "input_audio_format": "pcm16",
11770 "output_audio_format": "pcm16",
11771 "input_audio_transcription": {
11772 "model": "whisper-1"
11773 },
11774 "turn_detection": null,
11775 "tools": [],
11776 "tool_choice": "none",
11777 "temperature": 0.7,
11778 "max_response_output_tokens": 200,
11779 "speed": 1.1,
11780 "tracing": "auto",
11781 "client_secret": {
11782 "value": "ek_abc123",
11783 "expires_at": 1234567890
11784 }
11785 }
11786 /realtime/transcription_sessions:
11787 post:
11788 summary: >
11789 Create an ephemeral API token for use in client-side applications with
11790 the
11791
11792 Realtime API specifically for realtime transcriptions.
11793
11794 Can be configured with the same session parameters as the
11795 `transcription_session.update` client event.
11796
11797
11798 It responds with a session object, plus a `client_secret` key which
11799 contains
11800
11801 a usable ephemeral API token that can be used to authenticate browser
11802 clients
11803
11804 for the Realtime API.
11805 operationId: create-realtime-transcription-session
11806 tags:
11807 - Realtime
11808 requestBody:
11809 description: Create an ephemeral API key with the given session configuration.
11810 required: true
11811 content:
11812 application/json:
11813 schema:
11814 $ref: "#/components/schemas/RealtimeTranscriptionSessionCreateRequest"
11815 responses:
11816 "200":
11817 description: Session created successfully.
11818 content:
11819 application/json:
11820 schema:
11821 $ref: "#/components/schemas/RealtimeTranscriptionSessionCreateResponse"
11822 x-oaiMeta:
11823 name: Create transcription session
11824 group: realtime
11825 returns: The created [Realtime transcription session
11826 object](/docs/api-reference/realtime-sessions/transcription_session_object),
11827 plus an ephemeral key
11828 examples:
11829 request:
11830 curl: >
11831 curl -X POST
11832 https://api.openai.com/v1/realtime/transcription_sessions \
11833 -H "Authorization: Bearer $OPENAI_API_KEY" \
11834 -H "Content-Type: application/json" \
11835 -d '{}'
11836 response: |
11837 {
11838 "id": "sess_BBwZc7cFV3XizEyKGDCGL",
11839 "object": "realtime.transcription_session",
11840 "modalities": ["audio", "text"],
11841 "turn_detection": {
11842 "type": "server_vad",
11843 "threshold": 0.5,
11844 "prefix_padding_ms": 300,
11845 "silence_duration_ms": 200
11846 },
11847 "input_audio_format": "pcm16",
11848 "input_audio_transcription": {
11849 "model": "gpt-4o-transcribe",
11850 "language": null,
11851 "prompt": ""
11852 },
11853 "client_secret": null
11854 }
11855 /responses:
11856 post:
11857 operationId: createResponse
11858 tags:
11859 - Responses
11860 summary: >
11861 Creates a model response. Provide [text](/docs/guides/text) or
11862
11863 [image](/docs/guides/images) inputs to generate
11864 [text](/docs/guides/text)
11865
11866 or [JSON](/docs/guides/structured-outputs) outputs. Have the model call
11867
11868 your own [custom code](/docs/guides/function-calling) or use built-in
11869
11870 [tools](/docs/guides/tools) like [web
11871 search](/docs/guides/tools-web-search)
11872
11873 or [file search](/docs/guides/tools-file-search) to use your own data
11874
11875 as input for the model's response.
11876 requestBody:
11877 required: true
11878 content:
11879 application/json:
11880 schema:
11881 $ref: "#/components/schemas/CreateResponse"
11882 responses:
11883 "200":
11884 description: OK
11885 content:
11886 application/json:
11887 schema:
11888 $ref: "#/components/schemas/Response"
11889 text/event-stream:
11890 schema:
11891 $ref: "#/components/schemas/ResponseStreamEvent"
11892 x-oaiMeta:
11893 name: Create a model response
11894 group: responses
11895 returns: |
11896 Returns a [Response](/docs/api-reference/responses/object) object.
11897 path: create
11898 examples:
11899 - title: Text input
11900 request:
11901 curl: >
11902 curl https://api.openai.com/v1/responses \
11903 -H "Content-Type: application/json" \
11904 -H "Authorization: Bearer $OPENAI_API_KEY" \
11905 -d '{
11906 "model": "gpt-4.1",
11907 "input": "Tell me a three sentence bedtime story about a unicorn."
11908 }'
11909 javascript: >
11910 import OpenAI from "openai";
11911
11912
11913 const openai = new OpenAI();
11914
11915
11916 const response = await openai.responses.create({
11917 model: "gpt-4.1",
11918 input: "Tell me a three sentence bedtime story about a unicorn."
11919 });
11920
11921
11922 console.log(response);
11923 python: >
11924 from openai import OpenAI
11925
11926
11927 client = OpenAI()
11928
11929
11930 response = client.responses.create(
11931 model="gpt-4.1",
11932 input="Tell me a three sentence bedtime story about a unicorn."
11933 )
11934
11935
11936 print(response)
11937 csharp: >
11938 using System;
11939
11940 using OpenAI.Responses;
11941
11942
11943 OpenAIResponseClient client = new(
11944 model: "gpt-4.1",
11945 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
11946 );
11947
11948
11949 OpenAIResponse response = client.CreateResponse("Tell me a three
11950 sentence bedtime story about a unicorn.");
11951
11952
11953 Console.WriteLine(response.GetOutputText());
11954 response: >
11955 {
11956 "id": "resp_67ccd2bed1ec8190b14f964abc0542670bb6a6b452d3795b",
11957 "object": "response",
11958 "created_at": 1741476542,
11959 "status": "completed",
11960 "error": null,
11961 "incomplete_details": null,
11962 "instructions": null,
11963 "max_output_tokens": null,
11964 "model": "gpt-4.1-2025-04-14",
11965 "output": [
11966 {
11967 "type": "message",
11968 "id": "msg_67ccd2bf17f0819081ff3bb2cf6508e60bb6a6b452d3795b",
11969 "status": "completed",
11970 "role": "assistant",
11971 "content": [
11972 {
11973 "type": "output_text",
11974 "text": "In a peaceful grove beneath a silver moon, a unicorn named Lumina discovered a hidden pool that reflected the stars. As she dipped her horn into the water, the pool began to shimmer, revealing a pathway to a magical realm of endless night skies. Filled with wonder, Lumina whispered a wish for all who dream to find their own hidden magic, and as she glanced back, her hoofprints sparkled like stardust.",
11975 "annotations": []
11976 }
11977 ]
11978 }
11979 ],
11980 "parallel_tool_calls": true,
11981 "previous_response_id": null,
11982 "reasoning": {
11983 "effort": null,
11984 "summary": null
11985 },
11986 "store": true,
11987 "temperature": 1.0,
11988 "text": {
11989 "format": {
11990 "type": "text"
11991 }
11992 },
11993 "tool_choice": "auto",
11994 "tools": [],
11995 "top_p": 1.0,
11996 "truncation": "disabled",
11997 "usage": {
11998 "input_tokens": 36,
11999 "input_tokens_details": {
12000 "cached_tokens": 0
12001 },
12002 "output_tokens": 87,
12003 "output_tokens_details": {
12004 "reasoning_tokens": 0
12005 },
12006 "total_tokens": 123
12007 },
12008 "user": null,
12009 "metadata": {}
12010 }
12011 - title: Image input
12012 request:
12013 curl: >
12014 curl https://api.openai.com/v1/responses \
12015 -H "Content-Type: application/json" \
12016 -H "Authorization: Bearer $OPENAI_API_KEY" \
12017 -d '{
12018 "model": "gpt-4.1",
12019 "input": [
12020 {
12021 "role": "user",
12022 "content": [
12023 {"type": "input_text", "text": "what is in this image?"},
12024 {
12025 "type": "input_image",
12026 "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"
12027 }
12028 ]
12029 }
12030 ]
12031 }'
12032 javascript: >
12033 import OpenAI from "openai";
12034
12035
12036 const openai = new OpenAI();
12037
12038
12039 const response = await openai.responses.create({
12040 model: "gpt-4.1",
12041 input: [
12042 {
12043 role: "user",
12044 content: [
12045 { type: "input_text", text: "what is in this image?" },
12046 {
12047 type: "input_image",
12048 image_url:
12049 "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
12050 },
12051 ],
12052 },
12053 ],
12054 });
12055
12056
12057 console.log(response);
12058 python: >
12059 from openai import OpenAI
12060
12061
12062 client = OpenAI()
12063
12064
12065 response = client.responses.create(
12066 model="gpt-4.1",
12067 input=[
12068 {
12069 "role": "user",
12070 "content": [
12071 { "type": "input_text", "text": "what is in this image?" },
12072 {
12073 "type": "input_image",
12074 "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"
12075 }
12076 ]
12077 }
12078 ]
12079 )
12080
12081
12082 print(response)
12083 csharp: >
12084 using System;
12085
12086 using System.Collections.Generic;
12087
12088
12089 using OpenAI.Responses;
12090
12091
12092 OpenAIResponseClient client = new(
12093 model: "gpt-4.1",
12094 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
12095 );
12096
12097
12098 List<ResponseItem> inputItems =
12099
12100 [
12101 ResponseItem.CreateUserMessageItem(
12102 [
12103 ResponseContentPart.CreateInputTextPart("What is in this image?"),
12104 ResponseContentPart.CreateInputImagePart(new Uri("https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"))
12105 ]
12106 )
12107 ];
12108
12109
12110 OpenAIResponse response = client.CreateResponse(inputItems);
12111
12112
12113 Console.WriteLine(response.GetOutputText());
12114 response: >
12115 {
12116 "id": "resp_67ccd3a9da748190baa7f1570fe91ac604becb25c45c1d41",
12117 "object": "response",
12118 "created_at": 1741476777,
12119 "status": "completed",
12120 "error": null,
12121 "incomplete_details": null,
12122 "instructions": null,
12123 "max_output_tokens": null,
12124 "model": "gpt-4.1-2025-04-14",
12125 "output": [
12126 {
12127 "type": "message",
12128 "id": "msg_67ccd3acc8d48190a77525dc6de64b4104becb25c45c1d41",
12129 "status": "completed",
12130 "role": "assistant",
12131 "content": [
12132 {
12133 "type": "output_text",
12134 "text": "The image depicts a scenic landscape with a wooden boardwalk or pathway leading through lush, green grass under a blue sky with some clouds. The setting suggests a peaceful natural area, possibly a park or nature reserve. There are trees and shrubs in the background.",
12135 "annotations": []
12136 }
12137 ]
12138 }
12139 ],
12140 "parallel_tool_calls": true,
12141 "previous_response_id": null,
12142 "reasoning": {
12143 "effort": null,
12144 "summary": null
12145 },
12146 "store": true,
12147 "temperature": 1.0,
12148 "text": {
12149 "format": {
12150 "type": "text"
12151 }
12152 },
12153 "tool_choice": "auto",
12154 "tools": [],
12155 "top_p": 1.0,
12156 "truncation": "disabled",
12157 "usage": {
12158 "input_tokens": 328,
12159 "input_tokens_details": {
12160 "cached_tokens": 0
12161 },
12162 "output_tokens": 52,
12163 "output_tokens_details": {
12164 "reasoning_tokens": 0
12165 },
12166 "total_tokens": 380
12167 },
12168 "user": null,
12169 "metadata": {}
12170 }
12171 - title: Web search
12172 request:
12173 curl: |
12174 curl https://api.openai.com/v1/responses \
12175 -H "Content-Type: application/json" \
12176 -H "Authorization: Bearer $OPENAI_API_KEY" \
12177 -d '{
12178 "model": "gpt-4.1",
12179 "tools": [{ "type": "web_search_preview" }],
12180 "input": "What was a positive news story from today?"
12181 }'
12182 javascript: |
12183 import OpenAI from "openai";
12184
12185 const openai = new OpenAI();
12186
12187 const response = await openai.responses.create({
12188 model: "gpt-4.1",
12189 tools: [{ type: "web_search_preview" }],
12190 input: "What was a positive news story from today?",
12191 });
12192
12193 console.log(response);
12194 python: |
12195 from openai import OpenAI
12196
12197 client = OpenAI()
12198
12199 response = client.responses.create(
12200 model="gpt-4.1",
12201 tools=[{ "type": "web_search_preview" }],
12202 input="What was a positive news story from today?",
12203 )
12204
12205 print(response)
12206 csharp: >
12207 using System;
12208
12209
12210 using OpenAI.Responses;
12211
12212
12213 OpenAIResponseClient client = new(
12214 model: "gpt-4.1",
12215 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
12216 );
12217
12218
12219 string userInputText = "What was a positive news story from
12220 today?";
12221
12222
12223 ResponseCreationOptions options = new()
12224
12225 {
12226 Tools =
12227 {
12228 ResponseTool.CreateWebSearchTool()
12229 },
12230 };
12231
12232
12233 OpenAIResponse response = client.CreateResponse(userInputText,
12234 options);
12235
12236
12237 Console.WriteLine(response.GetOutputText());
12238 response: >
12239 {
12240 "id": "resp_67ccf18ef5fc8190b16dbee19bc54e5f087bb177ab789d5c",
12241 "object": "response",
12242 "created_at": 1741484430,
12243 "status": "completed",
12244 "error": null,
12245 "incomplete_details": null,
12246 "instructions": null,
12247 "max_output_tokens": null,
12248 "model": "gpt-4.1-2025-04-14",
12249 "output": [
12250 {
12251 "type": "web_search_call",
12252 "id": "ws_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c",
12253 "status": "completed"
12254 },
12255 {
12256 "type": "message",
12257 "id": "msg_67ccf190ca3881909d433c50b1f6357e087bb177ab789d5c",
12258 "status": "completed",
12259 "role": "assistant",
12260 "content": [
12261 {
12262 "type": "output_text",
12263 "text": "As of today, March 9, 2025, one notable positive news story...",
12264 "annotations": [
12265 {
12266 "type": "url_citation",
12267 "start_index": 442,
12268 "end_index": 557,
12269 "url": "https://.../?utm_source=chatgpt.com",
12270 "title": "..."
12271 },
12272 {
12273 "type": "url_citation",
12274 "start_index": 962,
12275 "end_index": 1077,
12276 "url": "https://.../?utm_source=chatgpt.com",
12277 "title": "..."
12278 },
12279 {
12280 "type": "url_citation",
12281 "start_index": 1336,
12282 "end_index": 1451,
12283 "url": "https://.../?utm_source=chatgpt.com",
12284 "title": "..."
12285 }
12286 ]
12287 }
12288 ]
12289 }
12290 ],
12291 "parallel_tool_calls": true,
12292 "previous_response_id": null,
12293 "reasoning": {
12294 "effort": null,
12295 "summary": null
12296 },
12297 "store": true,
12298 "temperature": 1.0,
12299 "text": {
12300 "format": {
12301 "type": "text"
12302 }
12303 },
12304 "tool_choice": "auto",
12305 "tools": [
12306 {
12307 "type": "web_search_preview",
12308 "domains": [],
12309 "search_context_size": "medium",
12310 "user_location": {
12311 "type": "approximate",
12312 "city": null,
12313 "country": "US",
12314 "region": null,
12315 "timezone": null
12316 }
12317 }
12318 ],
12319 "top_p": 1.0,
12320 "truncation": "disabled",
12321 "usage": {
12322 "input_tokens": 328,
12323 "input_tokens_details": {
12324 "cached_tokens": 0
12325 },
12326 "output_tokens": 356,
12327 "output_tokens_details": {
12328 "reasoning_tokens": 0
12329 },
12330 "total_tokens": 684
12331 },
12332 "user": null,
12333 "metadata": {}
12334 }
12335 - title: File search
12336 request:
12337 curl: >
12338 curl https://api.openai.com/v1/responses \
12339 -H "Content-Type: application/json" \
12340 -H "Authorization: Bearer $OPENAI_API_KEY" \
12341 -d '{
12342 "model": "gpt-4.1",
12343 "tools": [{
12344 "type": "file_search",
12345 "vector_store_ids": ["vs_1234567890"],
12346 "max_num_results": 20
12347 }],
12348 "input": "What are the attributes of an ancient brown dragon?"
12349 }'
12350 javascript: >
12351 import OpenAI from "openai";
12352
12353
12354 const openai = new OpenAI();
12355
12356
12357 const response = await openai.responses.create({
12358 model: "gpt-4.1",
12359 tools: [{
12360 type: "file_search",
12361 vector_store_ids: ["vs_1234567890"],
12362 max_num_results: 20
12363 }],
12364 input: "What are the attributes of an ancient brown dragon?",
12365 });
12366
12367
12368 console.log(response);
12369 python: |
12370 from openai import OpenAI
12371
12372 client = OpenAI()
12373
12374 response = client.responses.create(
12375 model="gpt-4.1",
12376 tools=[{
12377 "type": "file_search",
12378 "vector_store_ids": ["vs_1234567890"],
12379 "max_num_results": 20
12380 }],
12381 input="What are the attributes of an ancient brown dragon?",
12382 )
12383
12384 print(response)
12385 csharp: >
12386 using System;
12387
12388
12389 using OpenAI.Responses;
12390
12391
12392 OpenAIResponseClient client = new(
12393 model: "gpt-4.1",
12394 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
12395 );
12396
12397
12398 string userInputText = "What are the attributes of an ancient
12399 brown dragon?";
12400
12401
12402 ResponseCreationOptions options = new()
12403
12404 {
12405 Tools =
12406 {
12407 ResponseTool.CreateFileSearchTool(
12408 vectorStoreIds: ["vs_1234567890"],
12409 maxResultCount: 20
12410 )
12411 },
12412 };
12413
12414
12415 OpenAIResponse response = client.CreateResponse(userInputText,
12416 options);
12417
12418
12419 Console.WriteLine(response.GetOutputText());
12420 response: >
12421 {
12422 "id": "resp_67ccf4c55fc48190b71bd0463ad3306d09504fb6872380d7",
12423 "object": "response",
12424 "created_at": 1741485253,
12425 "status": "completed",
12426 "error": null,
12427 "incomplete_details": null,
12428 "instructions": null,
12429 "max_output_tokens": null,
12430 "model": "gpt-4.1-2025-04-14",
12431 "output": [
12432 {
12433 "type": "file_search_call",
12434 "id": "fs_67ccf4c63cd08190887ef6464ba5681609504fb6872380d7",
12435 "status": "completed",
12436 "queries": [
12437 "attributes of an ancient brown dragon"
12438 ],
12439 "results": null
12440 },
12441 {
12442 "type": "message",
12443 "id": "msg_67ccf4c93e5c81909d595b369351a9d309504fb6872380d7",
12444 "status": "completed",
12445 "role": "assistant",
12446 "content": [
12447 {
12448 "type": "output_text",
12449 "text": "The attributes of an ancient brown dragon include...",
12450 "annotations": [
12451 {
12452 "type": "file_citation",
12453 "index": 320,
12454 "file_id": "file-4wDz5b167pAf72nx1h9eiN",
12455 "filename": "dragons.pdf"
12456 },
12457 {
12458 "type": "file_citation",
12459 "index": 576,
12460 "file_id": "file-4wDz5b167pAf72nx1h9eiN",
12461 "filename": "dragons.pdf"
12462 },
12463 {
12464 "type": "file_citation",
12465 "index": 815,
12466 "file_id": "file-4wDz5b167pAf72nx1h9eiN",
12467 "filename": "dragons.pdf"
12468 },
12469 {
12470 "type": "file_citation",
12471 "index": 815,
12472 "file_id": "file-4wDz5b167pAf72nx1h9eiN",
12473 "filename": "dragons.pdf"
12474 },
12475 {
12476 "type": "file_citation",
12477 "index": 1030,
12478 "file_id": "file-4wDz5b167pAf72nx1h9eiN",
12479 "filename": "dragons.pdf"
12480 },
12481 {
12482 "type": "file_citation",
12483 "index": 1030,
12484 "file_id": "file-4wDz5b167pAf72nx1h9eiN",
12485 "filename": "dragons.pdf"
12486 },
12487 {
12488 "type": "file_citation",
12489 "index": 1156,
12490 "file_id": "file-4wDz5b167pAf72nx1h9eiN",
12491 "filename": "dragons.pdf"
12492 },
12493 {
12494 "type": "file_citation",
12495 "index": 1225,
12496 "file_id": "file-4wDz5b167pAf72nx1h9eiN",
12497 "filename": "dragons.pdf"
12498 }
12499 ]
12500 }
12501 ]
12502 }
12503 ],
12504 "parallel_tool_calls": true,
12505 "previous_response_id": null,
12506 "reasoning": {
12507 "effort": null,
12508 "summary": null
12509 },
12510 "store": true,
12511 "temperature": 1.0,
12512 "text": {
12513 "format": {
12514 "type": "text"
12515 }
12516 },
12517 "tool_choice": "auto",
12518 "tools": [
12519 {
12520 "type": "file_search",
12521 "filters": null,
12522 "max_num_results": 20,
12523 "ranking_options": {
12524 "ranker": "auto",
12525 "score_threshold": 0.0
12526 },
12527 "vector_store_ids": [
12528 "vs_1234567890"
12529 ]
12530 }
12531 ],
12532 "top_p": 1.0,
12533 "truncation": "disabled",
12534 "usage": {
12535 "input_tokens": 18307,
12536 "input_tokens_details": {
12537 "cached_tokens": 0
12538 },
12539 "output_tokens": 348,
12540 "output_tokens_details": {
12541 "reasoning_tokens": 0
12542 },
12543 "total_tokens": 18655
12544 },
12545 "user": null,
12546 "metadata": {}
12547 }
12548 - title: Streaming
12549 request:
12550 curl: |
12551 curl https://api.openai.com/v1/responses \
12552 -H "Content-Type: application/json" \
12553 -H "Authorization: Bearer $OPENAI_API_KEY" \
12554 -d '{
12555 "model": "gpt-4.1",
12556 "instructions": "You are a helpful assistant.",
12557 "input": "Hello!",
12558 "stream": true
12559 }'
12560 python: |
12561 from openai import OpenAI
12562
12563 client = OpenAI()
12564
12565 response = client.responses.create(
12566 model="gpt-4.1",
12567 instructions="You are a helpful assistant.",
12568 input="Hello!",
12569 stream=True
12570 )
12571
12572 for event in response:
12573 print(event)
12574 javascript: |
12575 import OpenAI from "openai";
12576
12577 const openai = new OpenAI();
12578
12579 const response = await openai.responses.create({
12580 model: "gpt-4.1",
12581 instructions: "You are a helpful assistant.",
12582 input: "Hello!",
12583 stream: true,
12584 });
12585
12586 for await (const event of response) {
12587 console.log(event);
12588 }
12589 csharp: >
12590 using System;
12591
12592 using System.ClientModel;
12593
12594 using System.Threading.Tasks;
12595
12596
12597 using OpenAI.Responses;
12598
12599
12600 OpenAIResponseClient client = new(
12601 model: "gpt-4.1",
12602 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
12603 );
12604
12605
12606 string userInputText = "Hello!";
12607
12608
12609 ResponseCreationOptions options = new()
12610
12611 {
12612 Instructions = "You are a helpful assistant.",
12613 };
12614
12615
12616 AsyncCollectionResult<StreamingResponseUpdate> responseUpdates =
12617 client.CreateResponseStreamingAsync(userInputText, options);
12618
12619
12620 await foreach (StreamingResponseUpdate responseUpdate in
12621 responseUpdates)
12622
12623 {
12624 if (responseUpdate is StreamingResponseOutputTextDeltaUpdate outputTextDeltaUpdate)
12625 {
12626 Console.Write(outputTextDeltaUpdate.Delta);
12627 }
12628 }
12629 response: |
12630 event: response.created
12631 data: {"type":"response.created","response":{"id":"resp_67c9fdcecf488190bdd9a0409de3a1ec07b8b0ad4e5eb654","object":"response","created_at":1741290958,"status":"in_progress","error":null,"incomplete_details":null,"instructions":"You are a helpful assistant.","max_output_tokens":null,"model":"gpt-4.1-2025-04-14","output":[],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"summary":null},"store":true,"temperature":1.0,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":null,"user":null,"metadata":{}}}
12632
12633 event: response.in_progress
12634 data: {"type":"response.in_progress","response":{"id":"resp_67c9fdcecf488190bdd9a0409de3a1ec07b8b0ad4e5eb654","object":"response","created_at":1741290958,"status":"in_progress","error":null,"incomplete_details":null,"instructions":"You are a helpful assistant.","max_output_tokens":null,"model":"gpt-4.1-2025-04-14","output":[],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"summary":null},"store":true,"temperature":1.0,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":null,"user":null,"metadata":{}}}
12635
12636 event: response.output_item.added
12637 data: {"type":"response.output_item.added","output_index":0,"item":{"id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","type":"message","status":"in_progress","role":"assistant","content":[]}}
12638
12639 event: response.content_part.added
12640 data: {"type":"response.content_part.added","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"part":{"type":"output_text","text":"","annotations":[]}}
12641
12642 event: response.output_text.delta
12643 data: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":"Hi"}
12644
12645 ...
12646
12647 event: response.output_text.done
12648 data: {"type":"response.output_text.done","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"text":"Hi there! How can I assist you today?"}
12649
12650 event: response.content_part.done
12651 data: {"type":"response.content_part.done","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"part":{"type":"output_text","text":"Hi there! How can I assist you today?","annotations":[]}}
12652
12653 event: response.output_item.done
12654 data: {"type":"response.output_item.done","output_index":0,"item":{"id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","type":"message","status":"completed","role":"assistant","content":[{"type":"output_text","text":"Hi there! How can I assist you today?","annotations":[]}]}}
12655
12656 event: response.completed
12657 data: {"type":"response.completed","response":{"id":"resp_67c9fdcecf488190bdd9a0409de3a1ec07b8b0ad4e5eb654","object":"response","created_at":1741290958,"status":"completed","error":null,"incomplete_details":null,"instructions":"You are a helpful assistant.","max_output_tokens":null,"model":"gpt-4.1-2025-04-14","output":[{"id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","type":"message","status":"completed","role":"assistant","content":[{"type":"output_text","text":"Hi there! How can I assist you today?","annotations":[]}]}],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"summary":null},"store":true,"temperature":1.0,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":{"input_tokens":37,"output_tokens":11,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":48},"user":null,"metadata":{}}}
12658 - title: Functions
12659 request:
12660 curl: >
12661 curl https://api.openai.com/v1/responses \
12662 -H "Content-Type: application/json" \
12663 -H "Authorization: Bearer $OPENAI_API_KEY" \
12664 -d '{
12665 "model": "gpt-4.1",
12666 "input": "What is the weather like in Boston today?",
12667 "tools": [
12668 {
12669 "type": "function",
12670 "name": "get_current_weather",
12671 "description": "Get the current weather in a given location",
12672 "parameters": {
12673 "type": "object",
12674 "properties": {
12675 "location": {
12676 "type": "string",
12677 "description": "The city and state, e.g. San Francisco, CA"
12678 },
12679 "unit": {
12680 "type": "string",
12681 "enum": ["celsius", "fahrenheit"]
12682 }
12683 },
12684 "required": ["location", "unit"]
12685 }
12686 }
12687 ],
12688 "tool_choice": "auto"
12689 }'
12690 python: >
12691 from openai import OpenAI
12692
12693
12694 client = OpenAI()
12695
12696
12697 tools = [
12698 {
12699 "type": "function",
12700 "name": "get_current_weather",
12701 "description": "Get the current weather in a given location",
12702 "parameters": {
12703 "type": "object",
12704 "properties": {
12705 "location": {
12706 "type": "string",
12707 "description": "The city and state, e.g. San Francisco, CA",
12708 },
12709 "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
12710 },
12711 "required": ["location", "unit"],
12712 }
12713 }
12714 ]
12715
12716
12717 response = client.responses.create(
12718 model="gpt-4.1",
12719 tools=tools,
12720 input="What is the weather like in Boston today?",
12721 tool_choice="auto"
12722 )
12723
12724
12725 print(response)
12726 javascript: >
12727 import OpenAI from "openai";
12728
12729
12730 const openai = new OpenAI();
12731
12732
12733 const tools = [
12734 {
12735 type: "function",
12736 name: "get_current_weather",
12737 description: "Get the current weather in a given location",
12738 parameters: {
12739 type: "object",
12740 properties: {
12741 location: {
12742 type: "string",
12743 description: "The city and state, e.g. San Francisco, CA",
12744 },
12745 unit: { type: "string", enum: ["celsius", "fahrenheit"] },
12746 },
12747 required: ["location", "unit"],
12748 },
12749 },
12750 ];
12751
12752
12753 const response = await openai.responses.create({
12754 model: "gpt-4.1",
12755 tools: tools,
12756 input: "What is the weather like in Boston today?",
12757 tool_choice: "auto",
12758 });
12759
12760
12761 console.log(response);
12762 csharp: >
12763 using System;
12764
12765 using OpenAI.Responses;
12766
12767
12768 OpenAIResponseClient client = new(
12769 model: "gpt-4.1",
12770 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
12771 );
12772
12773
12774 ResponseTool getCurrentWeatherFunctionTool =
12775 ResponseTool.CreateFunctionTool(
12776 functionName: "get_current_weather",
12777 functionDescription: "Get the current weather in a given location",
12778 functionParameters: BinaryData.FromString("""
12779 {
12780 "type": "object",
12781 "properties": {
12782 "location": {
12783 "type": "string",
12784 "description": "The city and state, e.g. San Francisco, CA"
12785 },
12786 "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
12787 },
12788 "required": ["location", "unit"]
12789 }
12790 """
12791 )
12792 );
12793
12794
12795 string userInputText = "What is the weather like in Boston
12796 today?";
12797
12798
12799 ResponseCreationOptions options = new()
12800
12801 {
12802 Tools =
12803 {
12804 getCurrentWeatherFunctionTool
12805 },
12806 ToolChoice = ResponseToolChoice.CreateAutoChoice(),
12807 };
12808
12809
12810 OpenAIResponse response = client.CreateResponse(userInputText,
12811 options);
12812 response: >
12813 {
12814 "id": "resp_67ca09c5efe0819096d0511c92b8c890096610f474011cc0",
12815 "object": "response",
12816 "created_at": 1741294021,
12817 "status": "completed",
12818 "error": null,
12819 "incomplete_details": null,
12820 "instructions": null,
12821 "max_output_tokens": null,
12822 "model": "gpt-4.1-2025-04-14",
12823 "output": [
12824 {
12825 "type": "function_call",
12826 "id": "fc_67ca09c6bedc8190a7abfec07b1a1332096610f474011cc0",
12827 "call_id": "call_unLAR8MvFNptuiZK6K6HCy5k",
12828 "name": "get_current_weather",
12829 "arguments": "{\"location\":\"Boston, MA\",\"unit\":\"celsius\"}",
12830 "status": "completed"
12831 }
12832 ],
12833 "parallel_tool_calls": true,
12834 "previous_response_id": null,
12835 "reasoning": {
12836 "effort": null,
12837 "summary": null
12838 },
12839 "store": true,
12840 "temperature": 1.0,
12841 "text": {
12842 "format": {
12843 "type": "text"
12844 }
12845 },
12846 "tool_choice": "auto",
12847 "tools": [
12848 {
12849 "type": "function",
12850 "description": "Get the current weather in a given location",
12851 "name": "get_current_weather",
12852 "parameters": {
12853 "type": "object",
12854 "properties": {
12855 "location": {
12856 "type": "string",
12857 "description": "The city and state, e.g. San Francisco, CA"
12858 },
12859 "unit": {
12860 "type": "string",
12861 "enum": [
12862 "celsius",
12863 "fahrenheit"
12864 ]
12865 }
12866 },
12867 "required": [
12868 "location",
12869 "unit"
12870 ]
12871 },
12872 "strict": true
12873 }
12874 ],
12875 "top_p": 1.0,
12876 "truncation": "disabled",
12877 "usage": {
12878 "input_tokens": 291,
12879 "output_tokens": 23,
12880 "output_tokens_details": {
12881 "reasoning_tokens": 0
12882 },
12883 "total_tokens": 314
12884 },
12885 "user": null,
12886 "metadata": {}
12887 }
12888 - title: Reasoning
12889 request:
12890 curl: |
12891 curl https://api.openai.com/v1/responses \
12892 -H "Content-Type: application/json" \
12893 -H "Authorization: Bearer $OPENAI_API_KEY" \
12894 -d '{
12895 "model": "o3-mini",
12896 "input": "How much wood would a woodchuck chuck?",
12897 "reasoning": {
12898 "effort": "high"
12899 }
12900 }'
12901 javascript: |
12902 import OpenAI from "openai";
12903 const openai = new OpenAI();
12904
12905 const response = await openai.responses.create({
12906 model: "o3-mini",
12907 input: "How much wood would a woodchuck chuck?",
12908 reasoning: {
12909 effort: "high"
12910 }
12911 });
12912
12913 console.log(response);
12914 python: |
12915 from openai import OpenAI
12916 client = OpenAI()
12917
12918 response = client.responses.create(
12919 model="o3-mini",
12920 input="How much wood would a woodchuck chuck?",
12921 reasoning={
12922 "effort": "high"
12923 }
12924 )
12925
12926 print(response)
12927 csharp: >
12928 using System;
12929
12930 using OpenAI.Responses;
12931
12932
12933 OpenAIResponseClient client = new(
12934 model: "o3-mini",
12935 apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
12936 );
12937
12938
12939 string userInputText = "How much wood would a woodchuck chuck?";
12940
12941
12942 ResponseCreationOptions options = new()
12943
12944 {
12945 ReasoningOptions = new()
12946 {
12947 ReasoningEffortLevel = ResponseReasoningEffortLevel.High,
12948 },
12949 };
12950
12951
12952 OpenAIResponse response = client.CreateResponse(userInputText,
12953 options);
12954
12955
12956 Console.WriteLine(response.GetOutputText());
12957 response: >
12958 {
12959 "id": "resp_67ccd7eca01881908ff0b5146584e408072912b2993db808",
12960 "object": "response",
12961 "created_at": 1741477868,
12962 "status": "completed",
12963 "error": null,
12964 "incomplete_details": null,
12965 "instructions": null,
12966 "max_output_tokens": null,
12967 "model": "o1-2024-12-17",
12968 "output": [
12969 {
12970 "type": "message",
12971 "id": "msg_67ccd7f7b5848190a6f3e95d809f6b44072912b2993db808",
12972 "status": "completed",
12973 "role": "assistant",
12974 "content": [
12975 {
12976 "type": "output_text",
12977 "text": "The classic tongue twister...",
12978 "annotations": []
12979 }
12980 ]
12981 }
12982 ],
12983 "parallel_tool_calls": true,
12984 "previous_response_id": null,
12985 "reasoning": {
12986 "effort": "high",
12987 "summary": null
12988 },
12989 "store": true,
12990 "temperature": 1.0,
12991 "text": {
12992 "format": {
12993 "type": "text"
12994 }
12995 },
12996 "tool_choice": "auto",
12997 "tools": [],
12998 "top_p": 1.0,
12999 "truncation": "disabled",
13000 "usage": {
13001 "input_tokens": 81,
13002 "input_tokens_details": {
13003 "cached_tokens": 0
13004 },
13005 "output_tokens": 1035,
13006 "output_tokens_details": {
13007 "reasoning_tokens": 832
13008 },
13009 "total_tokens": 1116
13010 },
13011 "user": null,
13012 "metadata": {}
13013 }
13014 /responses/{response_id}:
13015 get:
13016 operationId: getResponse
13017 tags:
13018 - Responses
13019 summary: |
13020 Retrieves a model response with the given ID.
13021 parameters:
13022 - in: path
13023 name: response_id
13024 required: true
13025 schema:
13026 type: string
13027 example: resp_677efb5139a88190b512bc3fef8e535d
13028 description: The ID of the response to retrieve.
13029 - in: query
13030 name: include
13031 schema:
13032 type: array
13033 items:
13034 $ref: "#/components/schemas/Includable"
13035 description: |
13036 Additional fields to include in the response. See the `include`
13037 parameter for Response creation above for more information.
13038 - in: query
13039 name: stream
13040 schema:
13041 type: boolean
13042 description: |
13043 If set to true, the model response data will be streamed to the client
13044 as it is generated using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
13045 See the [Streaming section below](/docs/api-reference/responses-streaming)
13046 for more information.
13047 - in: query
13048 name: starting_after
13049 schema:
13050 type: integer
13051 description: |
13052 The sequence number of the event after which to start streaming.
13053 responses:
13054 "200":
13055 description: OK
13056 content:
13057 application/json:
13058 schema:
13059 $ref: "#/components/schemas/Response"
13060 x-oaiMeta:
13061 name: Get a model response
13062 group: responses
13063 returns: >
13064 The [Response](/docs/api-reference/responses/object) object matching
13065 the
13066
13067 specified ID.
13068 examples:
13069 request:
13070 curl: |
13071 curl https://api.openai.com/v1/responses/resp_123 \
13072 -H "Content-Type: application/json" \
13073 -H "Authorization: Bearer $OPENAI_API_KEY"
13074 javascript: |
13075 import OpenAI from "openai";
13076 const client = new OpenAI();
13077
13078 const response = await client.responses.retrieve("resp_123");
13079 console.log(response);
13080 python: |
13081 from openai import OpenAI
13082 client = OpenAI()
13083
13084 response = client.responses.retrieve("resp_123")
13085 print(response)
13086 response: >
13087 {
13088 "id": "resp_67cb71b351908190a308f3859487620d06981a8637e6bc44",
13089 "object": "response",
13090 "created_at": 1741386163,
13091 "status": "completed",
13092 "error": null,
13093 "incomplete_details": null,
13094 "instructions": null,
13095 "max_output_tokens": null,
13096 "model": "gpt-4o-2024-08-06",
13097 "output": [
13098 {
13099 "type": "message",
13100 "id": "msg_67cb71b3c2b0819084d481baaaf148f206981a8637e6bc44",
13101 "status": "completed",
13102 "role": "assistant",
13103 "content": [
13104 {
13105 "type": "output_text",
13106 "text": "Silent circuits hum, \nThoughts emerge in data streams— \nDigital dawn breaks.",
13107 "annotations": []
13108 }
13109 ]
13110 }
13111 ],
13112 "parallel_tool_calls": true,
13113 "previous_response_id": null,
13114 "reasoning": {
13115 "effort": null,
13116 "summary": null
13117 },
13118 "store": true,
13119 "temperature": 1.0,
13120 "text": {
13121 "format": {
13122 "type": "text"
13123 }
13124 },
13125 "tool_choice": "auto",
13126 "tools": [],
13127 "top_p": 1.0,
13128 "truncation": "disabled",
13129 "usage": {
13130 "input_tokens": 32,
13131 "input_tokens_details": {
13132 "cached_tokens": 0
13133 },
13134 "output_tokens": 18,
13135 "output_tokens_details": {
13136 "reasoning_tokens": 0
13137 },
13138 "total_tokens": 50
13139 },
13140 "user": null,
13141 "metadata": {}
13142 }
13143 delete:
13144 operationId: deleteResponse
13145 tags:
13146 - Responses
13147 summary: |
13148 Deletes a model response with the given ID.
13149 parameters:
13150 - in: path
13151 name: response_id
13152 required: true
13153 schema:
13154 type: string
13155 example: resp_677efb5139a88190b512bc3fef8e535d
13156 description: The ID of the response to delete.
13157 responses:
13158 "200":
13159 description: OK
13160 "404":
13161 description: Not Found
13162 content:
13163 application/json:
13164 schema:
13165 $ref: "#/components/schemas/Error"
13166 x-oaiMeta:
13167 name: Delete a model response
13168 group: responses
13169 returns: |
13170 A success message.
13171 examples:
13172 request:
13173 curl: |
13174 curl -X DELETE https://api.openai.com/v1/responses/resp_123 \
13175 -H "Content-Type: application/json" \
13176 -H "Authorization: Bearer $OPENAI_API_KEY"
13177 javascript: |
13178 import OpenAI from "openai";
13179 const client = new OpenAI();
13180
13181 const response = await client.responses.del("resp_123");
13182 console.log(response);
13183 python: |
13184 from openai import OpenAI
13185 client = OpenAI()
13186
13187 response = client.responses.delete("resp_123")
13188 print(response)
13189 response: |
13190 {
13191 "id": "resp_6786a1bec27481909a17d673315b29f6",
13192 "object": "response",
13193 "deleted": true
13194 }
13195 /responses/{response_id}/cancel:
13196 post:
13197 operationId: cancelResponse
13198 tags:
13199 - Responses
13200 summary: |
13201 Cancels a model response with the given ID. Only responses created with
13202 the `background` parameter set to `true` can be cancelled.
13203 [Learn more](/docs/guides/background).
13204 parameters:
13205 - in: path
13206 name: response_id
13207 required: true
13208 schema:
13209 type: string
13210 example: resp_677efb5139a88190b512bc3fef8e535d
13211 description: The ID of the response to cancel.
13212 responses:
13213 "200":
13214 description: OK
13215 content:
13216 application/json:
13217 schema:
13218 $ref: "#/components/schemas/Response"
13219 "404":
13220 description: Not Found
13221 content:
13222 application/json:
13223 schema:
13224 $ref: "#/components/schemas/Error"
13225 x-oaiMeta:
13226 name: Cancel a response
13227 group: responses
13228 returns: |
13229 A [Response](/docs/api-reference/responses/object) object.
13230 examples:
13231 request:
13232 curl: |
13233 curl -X POST https://api.openai.com/v1/responses/resp_123/cancel \
13234 -H "Content-Type: application/json" \
13235 -H "Authorization: Bearer $OPENAI_API_KEY"
13236 javascript: |
13237 import OpenAI from "openai";
13238 const client = new OpenAI();
13239
13240 const response = await client.responses.cancel("resp_123");
13241 console.log(response);
13242 python: |
13243 from openai import OpenAI
13244 client = OpenAI()
13245
13246 response = client.responses.cancel("resp_123")
13247 print(response)
13248 response: >
13249 {
13250 "id": "resp_67cb71b351908190a308f3859487620d06981a8637e6bc44",
13251 "object": "response",
13252 "created_at": 1741386163,
13253 "status": "completed",
13254 "error": null,
13255 "incomplete_details": null,
13256 "instructions": null,
13257 "max_output_tokens": null,
13258 "model": "gpt-4o-2024-08-06",
13259 "output": [
13260 {
13261 "type": "message",
13262 "id": "msg_67cb71b3c2b0819084d481baaaf148f206981a8637e6bc44",
13263 "status": "completed",
13264 "role": "assistant",
13265 "content": [
13266 {
13267 "type": "output_text",
13268 "text": "Silent circuits hum, \nThoughts emerge in data streams— \nDigital dawn breaks.",
13269 "annotations": []
13270 }
13271 ]
13272 }
13273 ],
13274 "parallel_tool_calls": true,
13275 "previous_response_id": null,
13276 "reasoning": {
13277 "effort": null,
13278 "summary": null
13279 },
13280 "store": true,
13281 "temperature": 1.0,
13282 "text": {
13283 "format": {
13284 "type": "text"
13285 }
13286 },
13287 "tool_choice": "auto",
13288 "tools": [],
13289 "top_p": 1.0,
13290 "truncation": "disabled",
13291 "usage": {
13292 "input_tokens": 32,
13293 "input_tokens_details": {
13294 "cached_tokens": 0
13295 },
13296 "output_tokens": 18,
13297 "output_tokens_details": {
13298 "reasoning_tokens": 0
13299 },
13300 "total_tokens": 50
13301 },
13302 "user": null,
13303 "metadata": {}
13304 }
13305 /responses/{response_id}/input_items:
13306 get:
13307 operationId: listInputItems
13308 tags:
13309 - Responses
13310 summary: Returns a list of input items for a given response.
13311 parameters:
13312 - in: path
13313 name: response_id
13314 required: true
13315 schema:
13316 type: string
13317 description: The ID of the response to retrieve input items for.
13318 - name: limit
13319 in: query
13320 description: >
13321 A limit on the number of objects to be returned. Limit can range
13322 between
13323
13324 1 and 100, and the default is 20.
13325 required: false
13326 schema:
13327 type: integer
13328 default: 20
13329 - in: query
13330 name: order
13331 schema:
13332 type: string
13333 enum:
13334 - asc
13335 - desc
13336 description: |
13337 The order to return the input items in. Default is `desc`.
13338 - `asc`: Return the input items in ascending order.
13339 - `desc`: Return the input items in descending order.
13340 - in: query
13341 name: after
13342 schema:
13343 type: string
13344 description: |
13345 An item ID to list items after, used in pagination.
13346 - in: query
13347 name: before
13348 schema:
13349 type: string
13350 description: |
13351 An item ID to list items before, used in pagination.
13352 - in: query
13353 name: include
13354 schema:
13355 type: array
13356 items:
13357 $ref: "#/components/schemas/Includable"
13358 description: |
13359 Additional fields to include in the response. See the `include`
13360 parameter for Response creation above for more information.
13361 responses:
13362 "200":
13363 description: OK
13364 content:
13365 application/json:
13366 schema:
13367 $ref: "#/components/schemas/ResponseItemList"
13368 x-oaiMeta:
13369 name: List input items
13370 group: responses
13371 returns: A list of input item objects.
13372 examples:
13373 request:
13374 curl: |
13375 curl https://api.openai.com/v1/responses/resp_abc123/input_items \
13376 -H "Content-Type: application/json" \
13377 -H "Authorization: Bearer $OPENAI_API_KEY"
13378 javascript: >
13379 import OpenAI from "openai";
13380
13381 const client = new OpenAI();
13382
13383
13384 const response = await
13385 client.responses.inputItems.list("resp_123");
13386
13387 console.log(response.data);
13388 python: |
13389 from openai import OpenAI
13390 client = OpenAI()
13391
13392 response = client.responses.input_items.list("resp_123")
13393 print(response.data)
13394 response: >
13395 {
13396 "object": "list",
13397 "data": [
13398 {
13399 "id": "msg_abc123",
13400 "type": "message",
13401 "role": "user",
13402 "content": [
13403 {
13404 "type": "input_text",
13405 "text": "Tell me a three sentence bedtime story about a unicorn."
13406 }
13407 ]
13408 }
13409 ],
13410 "first_id": "msg_abc123",
13411 "last_id": "msg_abc123",
13412 "has_more": false
13413 }
13414 /threads:
13415 post:
13416 operationId: createThread
13417 tags:
13418 - Assistants
13419 summary: Create a thread.
13420 requestBody:
13421 content:
13422 application/json:
13423 schema:
13424 $ref: "#/components/schemas/CreateThreadRequest"
13425 responses:
13426 "200":
13427 description: OK
13428 content:
13429 application/json:
13430 schema:
13431 $ref: "#/components/schemas/ThreadObject"
13432 x-oaiMeta:
13433 name: Create thread
13434 group: threads
13435 beta: true
13436 returns: A [thread](/docs/api-reference/threads) object.
13437 examples:
13438 - title: Empty
13439 request:
13440 curl: |
13441 curl https://api.openai.com/v1/threads \
13442 -H "Content-Type: application/json" \
13443 -H "Authorization: Bearer $OPENAI_API_KEY" \
13444 -H "OpenAI-Beta: assistants=v2" \
13445 -d ''
13446 python: |
13447 from openai import OpenAI
13448 client = OpenAI()
13449
13450 empty_thread = client.beta.threads.create()
13451 print(empty_thread)
13452 node.js: |-
13453 import OpenAI from "openai";
13454
13455 const openai = new OpenAI();
13456
13457 async function main() {
13458 const emptyThread = await openai.beta.threads.create();
13459
13460 console.log(emptyThread);
13461 }
13462
13463 main();
13464 response: |
13465 {
13466 "id": "thread_abc123",
13467 "object": "thread",
13468 "created_at": 1699012949,
13469 "metadata": {},
13470 "tool_resources": {}
13471 }
13472 - title: Messages
13473 request:
13474 curl: |
13475 curl https://api.openai.com/v1/threads \
13476 -H "Content-Type: application/json" \
13477 -H "Authorization: Bearer $OPENAI_API_KEY" \
13478 -H "OpenAI-Beta: assistants=v2" \
13479 -d '{
13480 "messages": [{
13481 "role": "user",
13482 "content": "Hello, what is AI?"
13483 }, {
13484 "role": "user",
13485 "content": "How does AI work? Explain it in simple terms."
13486 }]
13487 }'
13488 python: |
13489 from openai import OpenAI
13490 client = OpenAI()
13491
13492 message_thread = client.beta.threads.create(
13493 messages=[
13494 {
13495 "role": "user",
13496 "content": "Hello, what is AI?"
13497 },
13498 {
13499 "role": "user",
13500 "content": "How does AI work? Explain it in simple terms."
13501 },
13502 ]
13503 )
13504
13505 print(message_thread)
13506 node.js: >-
13507 import OpenAI from "openai";
13508
13509
13510 const openai = new OpenAI();
13511
13512
13513 async function main() {
13514 const messageThread = await openai.beta.threads.create({
13515 messages: [
13516 {
13517 role: "user",
13518 content: "Hello, what is AI?"
13519 },
13520 {
13521 role: "user",
13522 content: "How does AI work? Explain it in simple terms.",
13523 },
13524 ],
13525 });
13526
13527 console.log(messageThread);
13528 }
13529
13530
13531 main();
13532 response: |
13533 {
13534 "id": "thread_abc123",
13535 "object": "thread",
13536 "created_at": 1699014083,
13537 "metadata": {},
13538 "tool_resources": {}
13539 }
13540 /threads/runs:
13541 post:
13542 operationId: createThreadAndRun
13543 tags:
13544 - Assistants
13545 summary: Create a thread and run it in one request.
13546 requestBody:
13547 required: true
13548 content:
13549 application/json:
13550 schema:
13551 $ref: "#/components/schemas/CreateThreadAndRunRequest"
13552 responses:
13553 "200":
13554 description: OK
13555 content:
13556 application/json:
13557 schema:
13558 $ref: "#/components/schemas/RunObject"
13559 x-oaiMeta:
13560 name: Create thread and run
13561 group: threads
13562 beta: true
13563 returns: A [run](/docs/api-reference/runs/object) object.
13564 examples:
13565 - title: Default
13566 request:
13567 curl: >
13568 curl https://api.openai.com/v1/threads/runs \
13569 -H "Authorization: Bearer $OPENAI_API_KEY" \
13570 -H "Content-Type: application/json" \
13571 -H "OpenAI-Beta: assistants=v2" \
13572 -d '{
13573 "assistant_id": "asst_abc123",
13574 "thread": {
13575 "messages": [
13576 {"role": "user", "content": "Explain deep learning to a 5 year old."}
13577 ]
13578 }
13579 }'
13580 python: >
13581 from openai import OpenAI
13582
13583 client = OpenAI()
13584
13585
13586 run = client.beta.threads.create_and_run(
13587 assistant_id="asst_abc123",
13588 thread={
13589 "messages": [
13590 {"role": "user", "content": "Explain deep learning to a 5 year old."}
13591 ]
13592 }
13593 )
13594
13595
13596 print(run)
13597 node.js: >
13598 import OpenAI from "openai";
13599
13600
13601 const openai = new OpenAI();
13602
13603
13604 async function main() {
13605 const run = await openai.beta.threads.createAndRun({
13606 assistant_id: "asst_abc123",
13607 thread: {
13608 messages: [
13609 { role: "user", content: "Explain deep learning to a 5 year old." },
13610 ],
13611 },
13612 });
13613
13614 console.log(run);
13615 }
13616
13617
13618 main();
13619 response: |
13620 {
13621 "id": "run_abc123",
13622 "object": "thread.run",
13623 "created_at": 1699076792,
13624 "assistant_id": "asst_abc123",
13625 "thread_id": "thread_abc123",
13626 "status": "queued",
13627 "started_at": null,
13628 "expires_at": 1699077392,
13629 "cancelled_at": null,
13630 "failed_at": null,
13631 "completed_at": null,
13632 "required_action": null,
13633 "last_error": null,
13634 "model": "gpt-4o",
13635 "instructions": "You are a helpful assistant.",
13636 "tools": [],
13637 "tool_resources": {},
13638 "metadata": {},
13639 "temperature": 1.0,
13640 "top_p": 1.0,
13641 "max_completion_tokens": null,
13642 "max_prompt_tokens": null,
13643 "truncation_strategy": {
13644 "type": "auto",
13645 "last_messages": null
13646 },
13647 "incomplete_details": null,
13648 "usage": null,
13649 "response_format": "auto",
13650 "tool_choice": "auto",
13651 "parallel_tool_calls": true
13652 }
13653 - title: Streaming
13654 request:
13655 curl: |
13656 curl https://api.openai.com/v1/threads/runs \
13657 -H "Authorization: Bearer $OPENAI_API_KEY" \
13658 -H "Content-Type: application/json" \
13659 -H "OpenAI-Beta: assistants=v2" \
13660 -d '{
13661 "assistant_id": "asst_123",
13662 "thread": {
13663 "messages": [
13664 {"role": "user", "content": "Hello"}
13665 ]
13666 },
13667 "stream": true
13668 }'
13669 python: |
13670 from openai import OpenAI
13671 client = OpenAI()
13672
13673 stream = client.beta.threads.create_and_run(
13674 assistant_id="asst_123",
13675 thread={
13676 "messages": [
13677 {"role": "user", "content": "Hello"}
13678 ]
13679 },
13680 stream=True
13681 )
13682
13683 for event in stream:
13684 print(event)
13685 node.js: |
13686 import OpenAI from "openai";
13687
13688 const openai = new OpenAI();
13689
13690 async function main() {
13691 const stream = await openai.beta.threads.createAndRun({
13692 assistant_id: "asst_123",
13693 thread: {
13694 messages: [
13695 { role: "user", content: "Hello" },
13696 ],
13697 },
13698 stream: true
13699 });
13700
13701 for await (const event of stream) {
13702 console.log(event);
13703 }
13704 }
13705
13706 main();
13707 response: |
13708 event: thread.created
13709 data: {"id":"thread_123","object":"thread","created_at":1710348075,"metadata":{}}
13710
13711 event: thread.run.created
13712 data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}
13713
13714 event: thread.run.queued
13715 data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}
13716
13717 event: thread.run.in_progress
13718 data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}
13719
13720 event: thread.run.step.created
13721 data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null}
13722
13723 event: thread.run.step.in_progress
13724 data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null}
13725
13726 event: thread.message.created
13727 data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[], "metadata":{}}
13728
13729 event: thread.message.in_progress
13730 data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[], "metadata":{}}
13731
13732 event: thread.message.delta
13733 data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}}
13734
13735 ...
13736
13737 event: thread.message.delta
13738 data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}}
13739
13740 event: thread.message.delta
13741 data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}}
13742
13743 event: thread.message.completed
13744 data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710348077,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! How can I assist you today?","annotations":[]}}], "metadata":{}}
13745
13746 event: thread.run.step.completed
13747 data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710348077,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}}
13748
13749 event: thread.run.completed
13750 {"id":"run_123","object":"thread.run","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1713226836,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1713226837,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":345,"completion_tokens":11,"total_tokens":356},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}
13751
13752 event: done
13753 data: [DONE]
13754 - title: Streaming with Functions
13755 request:
13756 curl: >
13757 curl https://api.openai.com/v1/threads/runs \
13758 -H "Authorization: Bearer $OPENAI_API_KEY" \
13759 -H "Content-Type: application/json" \
13760 -H "OpenAI-Beta: assistants=v2" \
13761 -d '{
13762 "assistant_id": "asst_abc123",
13763 "thread": {
13764 "messages": [
13765 {"role": "user", "content": "What is the weather like in San Francisco?"}
13766 ]
13767 },
13768 "tools": [
13769 {
13770 "type": "function",
13771 "function": {
13772 "name": "get_current_weather",
13773 "description": "Get the current weather in a given location",
13774 "parameters": {
13775 "type": "object",
13776 "properties": {
13777 "location": {
13778 "type": "string",
13779 "description": "The city and state, e.g. San Francisco, CA"
13780 },
13781 "unit": {
13782 "type": "string",
13783 "enum": ["celsius", "fahrenheit"]
13784 }
13785 },
13786 "required": ["location"]
13787 }
13788 }
13789 }
13790 ],
13791 "stream": true
13792 }'
13793 python: >
13794 from openai import OpenAI
13795
13796 client = OpenAI()
13797
13798
13799 tools = [
13800 {
13801 "type": "function",
13802 "function": {
13803 "name": "get_current_weather",
13804 "description": "Get the current weather in a given location",
13805 "parameters": {
13806 "type": "object",
13807 "properties": {
13808 "location": {
13809 "type": "string",
13810 "description": "The city and state, e.g. San Francisco, CA",
13811 },
13812 "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
13813 },
13814 "required": ["location"],
13815 },
13816 }
13817 }
13818 ]
13819
13820
13821 stream = client.beta.threads.create_and_run(
13822 thread={
13823 "messages": [
13824 {"role": "user", "content": "What is the weather like in San Francisco?"}
13825 ]
13826 },
13827 assistant_id="asst_abc123",
13828 tools=tools,
13829 stream=True
13830 )
13831
13832
13833 for event in stream:
13834 print(event)
13835 node.js: >
13836 import OpenAI from "openai";
13837
13838
13839 const openai = new OpenAI();
13840
13841
13842 const tools = [
13843 {
13844 "type": "function",
13845 "function": {
13846 "name": "get_current_weather",
13847 "description": "Get the current weather in a given location",
13848 "parameters": {
13849 "type": "object",
13850 "properties": {
13851 "location": {
13852 "type": "string",
13853 "description": "The city and state, e.g. San Francisco, CA",
13854 },
13855 "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
13856 },
13857 "required": ["location"],
13858 },
13859 }
13860 }
13861 ];
13862
13863
13864 async function main() {
13865 const stream = await openai.beta.threads.createAndRun({
13866 assistant_id: "asst_123",
13867 thread: {
13868 messages: [
13869 { role: "user", content: "What is the weather like in San Francisco?" },
13870 ],
13871 },
13872 tools: tools,
13873 stream: true
13874 });
13875
13876 for await (const event of stream) {
13877 console.log(event);
13878 }
13879 }
13880
13881
13882 main();
13883 response: |
13884 event: thread.created
13885 data: {"id":"thread_123","object":"thread","created_at":1710351818,"metadata":{}}
13886
13887 event: thread.run.created
13888 data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}
13889
13890 event: thread.run.queued
13891 data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}
13892
13893 event: thread.run.in_progress
13894 data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710351818,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}
13895
13896 event: thread.run.step.created
13897 data: {"id":"step_001","object":"thread.run.step","created_at":1710351819,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710352418,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[]},"usage":null}
13898
13899 event: thread.run.step.in_progress
13900 data: {"id":"step_001","object":"thread.run.step","created_at":1710351819,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710352418,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[]},"usage":null}
13901
13902 event: thread.run.step.delta
13903 data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"id":"call_XXNp8YGaFrjrSjgqxtC8JJ1B","type":"function","function":{"name":"get_current_weather","arguments":"","output":null}}]}}}
13904
13905 event: thread.run.step.delta
13906 data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"{\""}}]}}}
13907
13908 event: thread.run.step.delta
13909 data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"location"}}]}}}
13910
13911 ...
13912
13913 event: thread.run.step.delta
13914 data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"ahrenheit"}}]}}}
13915
13916 event: thread.run.step.delta
13917 data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"\"}"}}]}}}
13918
13919 event: thread.run.requires_action
13920 data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"requires_action","started_at":1710351818,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":{"type":"submit_tool_outputs","submit_tool_outputs":{"tool_calls":[{"id":"call_XXNp8YGaFrjrSjgqxtC8JJ1B","type":"function","function":{"name":"get_current_weather","arguments":"{\"location\":\"San Francisco, CA\",\"unit\":\"fahrenheit\"}"}}]}},"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":345,"completion_tokens":11,"total_tokens":356},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}
13921
13922 event: done
13923 data: [DONE]
13924 /threads/{thread_id}:
13925 get:
13926 operationId: getThread
13927 tags:
13928 - Assistants
13929 summary: Retrieves a thread.
13930 parameters:
13931 - in: path
13932 name: thread_id
13933 required: true
13934 schema:
13935 type: string
13936 description: The ID of the thread to retrieve.
13937 responses:
13938 "200":
13939 description: OK
13940 content:
13941 application/json:
13942 schema:
13943 $ref: "#/components/schemas/ThreadObject"
13944 x-oaiMeta:
13945 name: Retrieve thread
13946 group: threads
13947 beta: true
13948 returns: The [thread](/docs/api-reference/threads/object) object matching the
13949 specified ID.
13950 examples:
13951 request:
13952 curl: |
13953 curl https://api.openai.com/v1/threads/thread_abc123 \
13954 -H "Content-Type: application/json" \
13955 -H "Authorization: Bearer $OPENAI_API_KEY" \
13956 -H "OpenAI-Beta: assistants=v2"
13957 python: |
13958 from openai import OpenAI
13959 client = OpenAI()
13960
13961 my_thread = client.beta.threads.retrieve("thread_abc123")
13962 print(my_thread)
13963 node.js: |-
13964 import OpenAI from "openai";
13965
13966 const openai = new OpenAI();
13967
13968 async function main() {
13969 const myThread = await openai.beta.threads.retrieve(
13970 "thread_abc123"
13971 );
13972
13973 console.log(myThread);
13974 }
13975
13976 main();
13977 response: |
13978 {
13979 "id": "thread_abc123",
13980 "object": "thread",
13981 "created_at": 1699014083,
13982 "metadata": {},
13983 "tool_resources": {
13984 "code_interpreter": {
13985 "file_ids": []
13986 }
13987 }
13988 }
13989 post:
13990 operationId: modifyThread
13991 tags:
13992 - Assistants
13993 summary: Modifies a thread.
13994 parameters:
13995 - in: path
13996 name: thread_id
13997 required: true
13998 schema:
13999 type: string
14000 description: The ID of the thread to modify. Only the `metadata` can be modified.
14001 requestBody:
14002 required: true
14003 content:
14004 application/json:
14005 schema:
14006 $ref: "#/components/schemas/ModifyThreadRequest"
14007 responses:
14008 "200":
14009 description: OK
14010 content:
14011 application/json:
14012 schema:
14013 $ref: "#/components/schemas/ThreadObject"
14014 x-oaiMeta:
14015 name: Modify thread
14016 group: threads
14017 beta: true
14018 returns: The modified [thread](/docs/api-reference/threads/object) object
14019 matching the specified ID.
14020 examples:
14021 request:
14022 curl: |
14023 curl https://api.openai.com/v1/threads/thread_abc123 \
14024 -H "Content-Type: application/json" \
14025 -H "Authorization: Bearer $OPENAI_API_KEY" \
14026 -H "OpenAI-Beta: assistants=v2" \
14027 -d '{
14028 "metadata": {
14029 "modified": "true",
14030 "user": "abc123"
14031 }
14032 }'
14033 python: |
14034 from openai import OpenAI
14035 client = OpenAI()
14036
14037 my_updated_thread = client.beta.threads.update(
14038 "thread_abc123",
14039 metadata={
14040 "modified": "true",
14041 "user": "abc123"
14042 }
14043 )
14044 print(my_updated_thread)
14045 node.js: |-
14046 import OpenAI from "openai";
14047
14048 const openai = new OpenAI();
14049
14050 async function main() {
14051 const updatedThread = await openai.beta.threads.update(
14052 "thread_abc123",
14053 {
14054 metadata: { modified: "true", user: "abc123" },
14055 }
14056 );
14057
14058 console.log(updatedThread);
14059 }
14060
14061 main();
14062 response: |
14063 {
14064 "id": "thread_abc123",
14065 "object": "thread",
14066 "created_at": 1699014083,
14067 "metadata": {
14068 "modified": "true",
14069 "user": "abc123"
14070 },
14071 "tool_resources": {}
14072 }
14073 delete:
14074 operationId: deleteThread
14075 tags:
14076 - Assistants
14077 summary: Delete a thread.
14078 parameters:
14079 - in: path
14080 name: thread_id
14081 required: true
14082 schema:
14083 type: string
14084 description: The ID of the thread to delete.
14085 responses:
14086 "200":
14087 description: OK
14088 content:
14089 application/json:
14090 schema:
14091 $ref: "#/components/schemas/DeleteThreadResponse"
14092 x-oaiMeta:
14093 name: Delete thread
14094 group: threads
14095 beta: true
14096 returns: Deletion status
14097 examples:
14098 request:
14099 curl: |
14100 curl https://api.openai.com/v1/threads/thread_abc123 \
14101 -H "Content-Type: application/json" \
14102 -H "Authorization: Bearer $OPENAI_API_KEY" \
14103 -H "OpenAI-Beta: assistants=v2" \
14104 -X DELETE
14105 python: |
14106 from openai import OpenAI
14107 client = OpenAI()
14108
14109 response = client.beta.threads.delete("thread_abc123")
14110 print(response)
14111 node.js: |-
14112 import OpenAI from "openai";
14113
14114 const openai = new OpenAI();
14115
14116 async function main() {
14117 const response = await openai.beta.threads.del("thread_abc123");
14118
14119 console.log(response);
14120 }
14121 main();
14122 response: |
14123 {
14124 "id": "thread_abc123",
14125 "object": "thread.deleted",
14126 "deleted": true
14127 }
14128 /threads/{thread_id}/messages:
14129 get:
14130 operationId: listMessages
14131 tags:
14132 - Assistants
14133 summary: Returns a list of messages for a given thread.
14134 parameters:
14135 - in: path
14136 name: thread_id
14137 required: true
14138 schema:
14139 type: string
14140 description: The ID of the [thread](/docs/api-reference/threads) the messages
14141 belong to.
14142 - name: limit
14143 in: query
14144 description: >
14145 A limit on the number of objects to be returned. Limit can range
14146 between 1 and 100, and the default is 20.
14147 required: false
14148 schema:
14149 type: integer
14150 default: 20
14151 - name: order
14152 in: query
14153 description: >
14154 Sort order by the `created_at` timestamp of the objects. `asc` for
14155 ascending order and `desc` for descending order.
14156 schema:
14157 type: string
14158 default: desc
14159 enum:
14160 - asc
14161 - desc
14162 - name: after
14163 in: query
14164 description: >
14165 A cursor for use in pagination. `after` is an object ID that defines
14166 your place in the list. For instance, if you make a list request and
14167 receive 100 objects, ending with obj_foo, your subsequent call can
14168 include after=obj_foo in order to fetch the next page of the list.
14169 schema:
14170 type: string
14171 - name: before
14172 in: query
14173 description: >
14174 A cursor for use in pagination. `before` is an object ID that
14175 defines your place in the list. For instance, if you make a list
14176 request and receive 100 objects, starting with obj_foo, your
14177 subsequent call can include before=obj_foo in order to fetch the
14178 previous page of the list.
14179 schema:
14180 type: string
14181 - name: run_id
14182 in: query
14183 description: |
14184 Filter messages by the run ID that generated them.
14185 schema:
14186 type: string
14187 responses:
14188 "200":
14189 description: OK
14190 content:
14191 application/json:
14192 schema:
14193 $ref: "#/components/schemas/ListMessagesResponse"
14194 x-oaiMeta:
14195 name: List messages
14196 group: threads
14197 beta: true
14198 returns: A list of [message](/docs/api-reference/messages) objects.
14199 examples:
14200 request:
14201 curl: |
14202 curl https://api.openai.com/v1/threads/thread_abc123/messages \
14203 -H "Content-Type: application/json" \
14204 -H "Authorization: Bearer $OPENAI_API_KEY" \
14205 -H "OpenAI-Beta: assistants=v2"
14206 python: >
14207 from openai import OpenAI
14208
14209 client = OpenAI()
14210
14211
14212 thread_messages =
14213 client.beta.threads.messages.list("thread_abc123")
14214
14215 print(thread_messages.data)
14216 node.js: |-
14217 import OpenAI from "openai";
14218
14219 const openai = new OpenAI();
14220
14221 async function main() {
14222 const threadMessages = await openai.beta.threads.messages.list(
14223 "thread_abc123"
14224 );
14225
14226 console.log(threadMessages.data);
14227 }
14228
14229 main();
14230 response: >
14231 {
14232 "object": "list",
14233 "data": [
14234 {
14235 "id": "msg_abc123",
14236 "object": "thread.message",
14237 "created_at": 1699016383,
14238 "assistant_id": null,
14239 "thread_id": "thread_abc123",
14240 "run_id": null,
14241 "role": "user",
14242 "content": [
14243 {
14244 "type": "text",
14245 "text": {
14246 "value": "How does AI work? Explain it in simple terms.",
14247 "annotations": []
14248 }
14249 }
14250 ],
14251 "attachments": [],
14252 "metadata": {}
14253 },
14254 {
14255 "id": "msg_abc456",
14256 "object": "thread.message",
14257 "created_at": 1699016383,
14258 "assistant_id": null,
14259 "thread_id": "thread_abc123",
14260 "run_id": null,
14261 "role": "user",
14262 "content": [
14263 {
14264 "type": "text",
14265 "text": {
14266 "value": "Hello, what is AI?",
14267 "annotations": []
14268 }
14269 }
14270 ],
14271 "attachments": [],
14272 "metadata": {}
14273 }
14274 ],
14275 "first_id": "msg_abc123",
14276 "last_id": "msg_abc456",
14277 "has_more": false
14278 }
14279 post:
14280 operationId: createMessage
14281 tags:
14282 - Assistants
14283 summary: Create a message.
14284 parameters:
14285 - in: path
14286 name: thread_id
14287 required: true
14288 schema:
14289 type: string
14290 description: The ID of the [thread](/docs/api-reference/threads) to create a
14291 message for.
14292 requestBody:
14293 required: true
14294 content:
14295 application/json:
14296 schema:
14297 $ref: "#/components/schemas/CreateMessageRequest"
14298 responses:
14299 "200":
14300 description: OK
14301 content:
14302 application/json:
14303 schema:
14304 $ref: "#/components/schemas/MessageObject"
14305 x-oaiMeta:
14306 name: Create message
14307 group: threads
14308 beta: true
14309 returns: A [message](/docs/api-reference/messages/object) object.
14310 examples:
14311 request:
14312 curl: |
14313 curl https://api.openai.com/v1/threads/thread_abc123/messages \
14314 -H "Content-Type: application/json" \
14315 -H "Authorization: Bearer $OPENAI_API_KEY" \
14316 -H "OpenAI-Beta: assistants=v2" \
14317 -d '{
14318 "role": "user",
14319 "content": "How does AI work? Explain it in simple terms."
14320 }'
14321 python: |
14322 from openai import OpenAI
14323 client = OpenAI()
14324
14325 thread_message = client.beta.threads.messages.create(
14326 "thread_abc123",
14327 role="user",
14328 content="How does AI work? Explain it in simple terms.",
14329 )
14330 print(thread_message)
14331 node.js: >-
14332 import OpenAI from "openai";
14333
14334
14335 const openai = new OpenAI();
14336
14337
14338 async function main() {
14339 const threadMessages = await openai.beta.threads.messages.create(
14340 "thread_abc123",
14341 { role: "user", content: "How does AI work? Explain it in simple terms." }
14342 );
14343
14344 console.log(threadMessages);
14345 }
14346
14347
14348 main();
14349 response: |
14350 {
14351 "id": "msg_abc123",
14352 "object": "thread.message",
14353 "created_at": 1713226573,
14354 "assistant_id": null,
14355 "thread_id": "thread_abc123",
14356 "run_id": null,
14357 "role": "user",
14358 "content": [
14359 {
14360 "type": "text",
14361 "text": {
14362 "value": "How does AI work? Explain it in simple terms.",
14363 "annotations": []
14364 }
14365 }
14366 ],
14367 "attachments": [],
14368 "metadata": {}
14369 }
14370 /threads/{thread_id}/messages/{message_id}:
14371 get:
14372 operationId: getMessage
14373 tags:
14374 - Assistants
14375 summary: Retrieve a message.
14376 parameters:
14377 - in: path
14378 name: thread_id
14379 required: true
14380 schema:
14381 type: string
14382 description: The ID of the [thread](/docs/api-reference/threads) to which this
14383 message belongs.
14384 - in: path
14385 name: message_id
14386 required: true
14387 schema:
14388 type: string
14389 description: The ID of the message to retrieve.
14390 responses:
14391 "200":
14392 description: OK
14393 content:
14394 application/json:
14395 schema:
14396 $ref: "#/components/schemas/MessageObject"
14397 x-oaiMeta:
14398 name: Retrieve message
14399 group: threads
14400 beta: true
14401 returns: The [message](/docs/api-reference/messages/object) object matching the
14402 specified ID.
14403 examples:
14404 request:
14405 curl: |
14406 curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \
14407 -H "Content-Type: application/json" \
14408 -H "Authorization: Bearer $OPENAI_API_KEY" \
14409 -H "OpenAI-Beta: assistants=v2"
14410 python: |
14411 from openai import OpenAI
14412 client = OpenAI()
14413
14414 message = client.beta.threads.messages.retrieve(
14415 message_id="msg_abc123",
14416 thread_id="thread_abc123",
14417 )
14418 print(message)
14419 node.js: |-
14420 import OpenAI from "openai";
14421
14422 const openai = new OpenAI();
14423
14424 async function main() {
14425 const message = await openai.beta.threads.messages.retrieve(
14426 "thread_abc123",
14427 "msg_abc123"
14428 );
14429
14430 console.log(message);
14431 }
14432
14433 main();
14434 response: |
14435 {
14436 "id": "msg_abc123",
14437 "object": "thread.message",
14438 "created_at": 1699017614,
14439 "assistant_id": null,
14440 "thread_id": "thread_abc123",
14441 "run_id": null,
14442 "role": "user",
14443 "content": [
14444 {
14445 "type": "text",
14446 "text": {
14447 "value": "How does AI work? Explain it in simple terms.",
14448 "annotations": []
14449 }
14450 }
14451 ],
14452 "attachments": [],
14453 "metadata": {}
14454 }
14455 post:
14456 operationId: modifyMessage
14457 tags:
14458 - Assistants
14459 summary: Modifies a message.
14460 parameters:
14461 - in: path
14462 name: thread_id
14463 required: true
14464 schema:
14465 type: string
14466 description: The ID of the thread to which this message belongs.
14467 - in: path
14468 name: message_id
14469 required: true
14470 schema:
14471 type: string
14472 description: The ID of the message to modify.
14473 requestBody:
14474 required: true
14475 content:
14476 application/json:
14477 schema:
14478 $ref: "#/components/schemas/ModifyMessageRequest"
14479 responses:
14480 "200":
14481 description: OK
14482 content:
14483 application/json:
14484 schema:
14485 $ref: "#/components/schemas/MessageObject"
14486 x-oaiMeta:
14487 name: Modify message
14488 group: threads
14489 beta: true
14490 returns: The modified [message](/docs/api-reference/messages/object) object.
14491 examples:
14492 request:
14493 curl: |
14494 curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \
14495 -H "Content-Type: application/json" \
14496 -H "Authorization: Bearer $OPENAI_API_KEY" \
14497 -H "OpenAI-Beta: assistants=v2" \
14498 -d '{
14499 "metadata": {
14500 "modified": "true",
14501 "user": "abc123"
14502 }
14503 }'
14504 python: |
14505 from openai import OpenAI
14506 client = OpenAI()
14507
14508 message = client.beta.threads.messages.update(
14509 message_id="msg_abc12",
14510 thread_id="thread_abc123",
14511 metadata={
14512 "modified": "true",
14513 "user": "abc123",
14514 },
14515 )
14516 print(message)
14517 node.js: |-
14518 import OpenAI from "openai";
14519
14520 const openai = new OpenAI();
14521
14522 async function main() {
14523 const message = await openai.beta.threads.messages.update(
14524 "thread_abc123",
14525 "msg_abc123",
14526 {
14527 metadata: {
14528 modified: "true",
14529 user: "abc123",
14530 },
14531 }
14532 }'
14533 response: |
14534 {
14535 "id": "msg_abc123",
14536 "object": "thread.message",
14537 "created_at": 1699017614,
14538 "assistant_id": null,
14539 "thread_id": "thread_abc123",
14540 "run_id": null,
14541 "role": "user",
14542 "content": [
14543 {
14544 "type": "text",
14545 "text": {
14546 "value": "How does AI work? Explain it in simple terms.",
14547 "annotations": []
14548 }
14549 }
14550 ],
14551 "file_ids": [],
14552 "metadata": {
14553 "modified": "true",
14554 "user": "abc123"
14555 }
14556 }
14557 delete:
14558 operationId: deleteMessage
14559 tags:
14560 - Assistants
14561 summary: Deletes a message.
14562 parameters:
14563 - in: path
14564 name: thread_id
14565 required: true
14566 schema:
14567 type: string
14568 description: The ID of the thread to which this message belongs.
14569 - in: path
14570 name: message_id
14571 required: true
14572 schema:
14573 type: string
14574 description: The ID of the message to delete.
14575 responses:
14576 "200":
14577 description: OK
14578 content:
14579 application/json:
14580 schema:
14581 $ref: "#/components/schemas/DeleteMessageResponse"
14582 x-oaiMeta:
14583 name: Delete message
14584 group: threads
14585 beta: true
14586 returns: Deletion status
14587 examples:
14588 request:
14589 curl: |
14590 curl -X DELETE https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \
14591 -H "Content-Type: application/json" \
14592 -H "Authorization: Bearer $OPENAI_API_KEY" \
14593 -H "OpenAI-Beta: assistants=v2"
14594 python: |
14595 from openai import OpenAI
14596 client = OpenAI()
14597
14598 deleted_message = client.beta.threads.messages.delete(
14599 message_id="msg_abc12",
14600 thread_id="thread_abc123",
14601 )
14602 print(deleted_message)
14603 node.js: |-
14604 import OpenAI from "openai";
14605
14606 const openai = new OpenAI();
14607
14608 async function main() {
14609 const deletedMessage = await openai.beta.threads.messages.del(
14610 "thread_abc123",
14611 "msg_abc123"
14612 );
14613
14614 console.log(deletedMessage);
14615 }
14616 response: |
14617 {
14618 "id": "msg_abc123",
14619 "object": "thread.message.deleted",
14620 "deleted": true
14621 }
14622 /threads/{thread_id}/runs:
14623 get:
14624 operationId: listRuns
14625 tags:
14626 - Assistants
14627 summary: Returns a list of runs belonging to a thread.
14628 parameters:
14629 - name: thread_id
14630 in: path
14631 required: true
14632 schema:
14633 type: string
14634 description: The ID of the thread the run belongs to.
14635 - name: limit
14636 in: query
14637 description: >
14638 A limit on the number of objects to be returned. Limit can range
14639 between 1 and 100, and the default is 20.
14640 required: false
14641 schema:
14642 type: integer
14643 default: 20
14644 - name: order
14645 in: query
14646 description: >