python/resources/responses/subresources/input_tokens/index.md +0 −3472 deleted
File Deleted View Diff
1# Input Tokens
2
3## Get input token counts
4
5`responses.input_tokens.count(InputTokenCountParams**kwargs) -> InputTokenCountResponse`
6
7**post** `/responses/input_tokens`
8
9Returns input token counts of the request.
10
11Returns an object with `object` set to `response.input_tokens` and an `input_tokens` count.
12
13### Parameters
14
15- `conversation: Optional[Conversation]`
16
17 The conversation that this response belongs to. Items from this conversation are prepended to `input_items` for this response request.
18 Input items and output items from this response are automatically added to this conversation after this response completes.
19
20 - `str`
21
22 The unique ID of the conversation.
23
24 - `class ResponseConversationParam: …`
25
26 The conversation that this response belongs to.
27
28 - `id: str`
29
30 The unique ID of the conversation.
31
32- `input: Optional[Union[str, Iterable[ResponseInputItemParam], null]]`
33
34 Text, image, or file inputs to the model, used to generate a response
35
36 - `str`
37
38 A text input to the model, equivalent to a text input with the `user` role.
39
40 - `Iterable[ResponseInputItemParam]`
41
42 A list of one or many input items to the model, containing different content types.
43
44 - `class EasyInputMessage: …`
45
46 A message input to the model with a role indicating instruction following
47 hierarchy. Instructions given with the `developer` or `system` role take
48 precedence over instructions given with the `user` role. Messages with the
49 `assistant` role are presumed to have been generated by the model in previous
50 interactions.
51
52 - `content: Union[str, ResponseInputMessageContentList]`
53
54 Text, image, or audio input to the model, used to generate a response.
55 Can also contain previous assistant responses.
56
57 - `str`
58
59 A text input to the model.
60
61 - `List[ResponseInputContent]`
62
63 - `class ResponseInputText: …`
64
65 A text input to the model.
66
67 - `text: str`
68
69 The text input to the model.
70
71 - `type: Literal["input_text"]`
72
73 The type of the input item. Always `input_text`.
74
75 - `"input_text"`
76
77 - `class ResponseInputImage: …`
78
79 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
80
81 - `detail: Literal["low", "high", "auto", "original"]`
82
83 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
84
85 - `"low"`
86
87 - `"high"`
88
89 - `"auto"`
90
91 - `"original"`
92
93 - `type: Literal["input_image"]`
94
95 The type of the input item. Always `input_image`.
96
97 - `"input_image"`
98
99 - `file_id: Optional[str]`
100
101 The ID of the file to be sent to the model.
102
103 - `image_url: Optional[str]`
104
105 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.
106
107 - `class ResponseInputFile: …`
108
109 A file input to the model.
110
111 - `type: Literal["input_file"]`
112
113 The type of the input item. Always `input_file`.
114
115 - `"input_file"`
116
117 - `detail: Optional[Literal["low", "high"]]`
118
119 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.
120
121 - `"low"`
122
123 - `"high"`
124
125 - `file_data: Optional[str]`
126
127 The content of the file to be sent to the model.
128
129 - `file_id: Optional[str]`
130
131 The ID of the file to be sent to the model.
132
133 - `file_url: Optional[str]`
134
135 The URL of the file to be sent to the model.
136
137 - `filename: Optional[str]`
138
139 The name of the file to be sent to the model.
140
141 - `role: Literal["user", "assistant", "system", "developer"]`
142
143 The role of the message input. One of `user`, `assistant`, `system`, or
144 `developer`.
145
146 - `"user"`
147
148 - `"assistant"`
149
150 - `"system"`
151
152 - `"developer"`
153
154 - `phase: Optional[Literal["commentary", "final_answer"]]`
155
156 Labels an `assistant` message as intermediate commentary (`commentary`) or the final answer (`final_answer`).
157 For models like `gpt-5.3-codex` and beyond, when sending follow-up requests, preserve and resend
158 phase on all assistant messages — dropping it can degrade performance. Not used for user messages.
159
160 - `"commentary"`
161
162 - `"final_answer"`
163
164 - `type: Optional[Literal["message"]]`
165
166 The type of the message input. Always `message`.
167
168 - `"message"`
169
170 - `class Message: …`
171
172 A message input to the model with a role indicating instruction following
173 hierarchy. Instructions given with the `developer` or `system` role take
174 precedence over instructions given with the `user` role.
175
176 - `content: ResponseInputMessageContentList`
177
178 A list of one or many input items to the model, containing different content
179 types.
180
181 - `class ResponseInputText: …`
182
183 A text input to the model.
184
185 - `class ResponseInputImage: …`
186
187 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
188
189 - `class ResponseInputFile: …`
190
191 A file input to the model.
192
193 - `role: Literal["user", "system", "developer"]`
194
195 The role of the message input. One of `user`, `system`, or `developer`.
196
197 - `"user"`
198
199 - `"system"`
200
201 - `"developer"`
202
203 - `status: Optional[Literal["in_progress", "completed", "incomplete"]]`
204
205 The status of item. One of `in_progress`, `completed`, or
206 `incomplete`. Populated when items are returned via API.
207
208 - `"in_progress"`
209
210 - `"completed"`
211
212 - `"incomplete"`
213
214 - `type: Optional[Literal["message"]]`
215
216 The type of the message input. Always set to `message`.
217
218 - `"message"`
219
220 - `class ResponseOutputMessage: …`
221
222 An output message from the model.
223
224 - `id: str`
225
226 The unique ID of the output message.
227
228 - `content: List[Content]`
229
230 The content of the output message.
231
232 - `class ResponseOutputText: …`
233
234 A text output from the model.
235
236 - `annotations: List[Annotation]`
237
238 The annotations of the text output.
239
240 - `class AnnotationFileCitation: …`
241
242 A citation to a file.
243
244 - `file_id: str`
245
246 The ID of the file.
247
248 - `filename: str`
249
250 The filename of the file cited.
251
252 - `index: int`
253
254 The index of the file in the list of files.
255
256 - `type: Literal["file_citation"]`
257
258 The type of the file citation. Always `file_citation`.
259
260 - `"file_citation"`
261
262 - `class AnnotationURLCitation: …`
263
264 A citation for a web resource used to generate a model response.
265
266 - `end_index: int`
267
268 The index of the last character of the URL citation in the message.
269
270 - `start_index: int`
271
272 The index of the first character of the URL citation in the message.
273
274 - `title: str`
275
276 The title of the web resource.
277
278 - `type: Literal["url_citation"]`
279
280 The type of the URL citation. Always `url_citation`.
281
282 - `"url_citation"`
283
284 - `url: str`
285
286 The URL of the web resource.
287
288 - `class AnnotationContainerFileCitation: …`
289
290 A citation for a container file used to generate a model response.
291
292 - `container_id: str`
293
294 The ID of the container file.
295
296 - `end_index: int`
297
298 The index of the last character of the container file citation in the message.
299
300 - `file_id: str`
301
302 The ID of the file.
303
304 - `filename: str`
305
306 The filename of the container file cited.
307
308 - `start_index: int`
309
310 The index of the first character of the container file citation in the message.
311
312 - `type: Literal["container_file_citation"]`
313
314 The type of the container file citation. Always `container_file_citation`.
315
316 - `"container_file_citation"`
317
318 - `class AnnotationFilePath: …`
319
320 A path to a file.
321
322 - `file_id: str`
323
324 The ID of the file.
325
326 - `index: int`
327
328 The index of the file in the list of files.
329
330 - `type: Literal["file_path"]`
331
332 The type of the file path. Always `file_path`.
333
334 - `"file_path"`
335
336 - `text: str`
337
338 The text output from the model.
339
340 - `type: Literal["output_text"]`
341
342 The type of the output text. Always `output_text`.
343
344 - `"output_text"`
345
346 - `logprobs: Optional[List[Logprob]]`
347
348 - `token: str`
349
350 - `bytes: List[int]`
351
352 - `logprob: float`
353
354 - `top_logprobs: List[LogprobTopLogprob]`
355
356 - `token: str`
357
358 - `bytes: List[int]`
359
360 - `logprob: float`
361
362 - `class ResponseOutputRefusal: …`
363
364 A refusal from the model.
365
366 - `refusal: str`
367
368 The refusal explanation from the model.
369
370 - `type: Literal["refusal"]`
371
372 The type of the refusal. Always `refusal`.
373
374 - `"refusal"`
375
376 - `role: Literal["assistant"]`
377
378 The role of the output message. Always `assistant`.
379
380 - `"assistant"`
381
382 - `status: Literal["in_progress", "completed", "incomplete"]`
383
384 The status of the message input. One of `in_progress`, `completed`, or
385 `incomplete`. Populated when input items are returned via API.
386
387 - `"in_progress"`
388
389 - `"completed"`
390
391 - `"incomplete"`
392
393 - `type: Literal["message"]`
394
395 The type of the output message. Always `message`.
396
397 - `"message"`
398
399 - `phase: Optional[Literal["commentary", "final_answer"]]`
400
401 Labels an `assistant` message as intermediate commentary (`commentary`) or the final answer (`final_answer`).
402 For models like `gpt-5.3-codex` and beyond, when sending follow-up requests, preserve and resend
403 phase on all assistant messages — dropping it can degrade performance. Not used for user messages.
404
405 - `"commentary"`
406
407 - `"final_answer"`
408
409 - `class ResponseFileSearchToolCall: …`
410
411 The results of a file search tool call. See the
412 [file search guide](https://platform.openai.com/docs/guides/tools-file-search) for more information.
413
414 - `id: str`
415
416 The unique ID of the file search tool call.
417
418 - `queries: List[str]`
419
420 The queries used to search for files.
421
422 - `status: Literal["in_progress", "searching", "completed", 2 more]`
423
424 The status of the file search tool call. One of `in_progress`,
425 `searching`, `incomplete` or `failed`,
426
427 - `"in_progress"`
428
429 - `"searching"`
430
431 - `"completed"`
432
433 - `"incomplete"`
434
435 - `"failed"`
436
437 - `type: Literal["file_search_call"]`
438
439 The type of the file search tool call. Always `file_search_call`.
440
441 - `"file_search_call"`
442
443 - `results: Optional[List[Result]]`
444
445 The results of the file search tool call.
446
447 - `attributes: Optional[Dict[str, Union[str, float, bool]]]`
448
449 Set of 16 key-value pairs that can be attached to an object. This can be
450 useful for storing additional information about the object in a structured
451 format, and querying for objects via API or the dashboard. Keys are strings
452 with a maximum length of 64 characters. Values are strings with a maximum
453 length of 512 characters, booleans, or numbers.
454
455 - `str`
456
457 - `float`
458
459 - `bool`
460
461 - `file_id: Optional[str]`
462
463 The unique ID of the file.
464
465 - `filename: Optional[str]`
466
467 The name of the file.
468
469 - `score: Optional[float]`
470
471 The relevance score of the file - a value between 0 and 1.
472
473 - `text: Optional[str]`
474
475 The text that was retrieved from the file.
476
477 - `class ResponseComputerToolCall: …`
478
479 A tool call to a computer use tool. See the
480 [computer use guide](https://platform.openai.com/docs/guides/tools-computer-use) for more information.
481
482 - `id: str`
483
484 The unique ID of the computer call.
485
486 - `call_id: str`
487
488 An identifier used when responding to the tool call with output.
489
490 - `pending_safety_checks: List[PendingSafetyCheck]`
491
492 The pending safety checks for the computer call.
493
494 - `id: str`
495
496 The ID of the pending safety check.
497
498 - `code: Optional[str]`
499
500 The type of the pending safety check.
501
502 - `message: Optional[str]`
503
504 Details about the pending safety check.
505
506 - `status: Literal["in_progress", "completed", "incomplete"]`
507
508 The status of the item. One of `in_progress`, `completed`, or
509 `incomplete`. Populated when items are returned via API.
510
511 - `"in_progress"`
512
513 - `"completed"`
514
515 - `"incomplete"`
516
517 - `type: Literal["computer_call"]`
518
519 The type of the computer call. Always `computer_call`.
520
521 - `"computer_call"`
522
523 - `action: Optional[Action]`
524
525 A click action.
526
527 - `class ActionClick: …`
528
529 A click action.
530
531 - `button: Literal["left", "right", "wheel", 2 more]`
532
533 Indicates which mouse button was pressed during the click. One of `left`, `right`, `wheel`, `back`, or `forward`.
534
535 - `"left"`
536
537 - `"right"`
538
539 - `"wheel"`
540
541 - `"back"`
542
543 - `"forward"`
544
545 - `type: Literal["click"]`
546
547 Specifies the event type. For a click action, this property is always `click`.
548
549 - `"click"`
550
551 - `x: int`
552
553 The x-coordinate where the click occurred.
554
555 - `y: int`
556
557 The y-coordinate where the click occurred.
558
559 - `keys: Optional[List[str]]`
560
561 The keys being held while clicking.
562
563 - `class ActionDoubleClick: …`
564
565 A double click action.
566
567 - `keys: Optional[List[str]]`
568
569 The keys being held while double-clicking.
570
571 - `type: Literal["double_click"]`
572
573 Specifies the event type. For a double click action, this property is always set to `double_click`.
574
575 - `"double_click"`
576
577 - `x: int`
578
579 The x-coordinate where the double click occurred.
580
581 - `y: int`
582
583 The y-coordinate where the double click occurred.
584
585 - `class ActionDrag: …`
586
587 A drag action.
588
589 - `path: List[ActionDragPath]`
590
591 An array of coordinates representing the path of the drag action. Coordinates will appear as an array of objects, eg
592
593 ```
594 [
595 { x: 100, y: 200 },
596 { x: 200, y: 300 }
597 ]
598 ```
599
600 - `x: int`
601
602 The x-coordinate.
603
604 - `y: int`
605
606 The y-coordinate.
607
608 - `type: Literal["drag"]`
609
610 Specifies the event type. For a drag action, this property is always set to `drag`.
611
612 - `"drag"`
613
614 - `keys: Optional[List[str]]`
615
616 The keys being held while dragging the mouse.
617
618 - `class ActionKeypress: …`
619
620 A collection of keypresses the model would like to perform.
621
622 - `keys: List[str]`
623
624 The combination of keys the model is requesting to be pressed. This is an array of strings, each representing a key.
625
626 - `type: Literal["keypress"]`
627
628 Specifies the event type. For a keypress action, this property is always set to `keypress`.
629
630 - `"keypress"`
631
632 - `class ActionMove: …`
633
634 A mouse move action.
635
636 - `type: Literal["move"]`
637
638 Specifies the event type. For a move action, this property is always set to `move`.
639
640 - `"move"`
641
642 - `x: int`
643
644 The x-coordinate to move to.
645
646 - `y: int`
647
648 The y-coordinate to move to.
649
650 - `keys: Optional[List[str]]`
651
652 The keys being held while moving the mouse.
653
654 - `class ActionScreenshot: …`
655
656 A screenshot action.
657
658 - `type: Literal["screenshot"]`
659
660 Specifies the event type. For a screenshot action, this property is always set to `screenshot`.
661
662 - `"screenshot"`
663
664 - `class ActionScroll: …`
665
666 A scroll action.
667
668 - `scroll_x: int`
669
670 The horizontal scroll distance.
671
672 - `scroll_y: int`
673
674 The vertical scroll distance.
675
676 - `type: Literal["scroll"]`
677
678 Specifies the event type. For a scroll action, this property is always set to `scroll`.
679
680 - `"scroll"`
681
682 - `x: int`
683
684 The x-coordinate where the scroll occurred.
685
686 - `y: int`
687
688 The y-coordinate where the scroll occurred.
689
690 - `keys: Optional[List[str]]`
691
692 The keys being held while scrolling.
693
694 - `class ActionType: …`
695
696 An action to type in text.
697
698 - `text: str`
699
700 The text to type.
701
702 - `type: Literal["type"]`
703
704 Specifies the event type. For a type action, this property is always set to `type`.
705
706 - `"type"`
707
708 - `class ActionWait: …`
709
710 A wait action.
711
712 - `type: Literal["wait"]`
713
714 Specifies the event type. For a wait action, this property is always set to `wait`.
715
716 - `"wait"`
717
718 - `actions: Optional[ComputerActionList]`
719
720 Flattened batched actions for `computer_use`. Each action includes an
721 `type` discriminator and action-specific fields.
722
723 - `class Click: …`
724
725 A click action.
726
727 - `button: Literal["left", "right", "wheel", 2 more]`
728
729 Indicates which mouse button was pressed during the click. One of `left`, `right`, `wheel`, `back`, or `forward`.
730
731 - `"left"`
732
733 - `"right"`
734
735 - `"wheel"`
736
737 - `"back"`
738
739 - `"forward"`
740
741 - `type: Literal["click"]`
742
743 Specifies the event type. For a click action, this property is always `click`.
744
745 - `"click"`
746
747 - `x: int`
748
749 The x-coordinate where the click occurred.
750
751 - `y: int`
752
753 The y-coordinate where the click occurred.
754
755 - `keys: Optional[List[str]]`
756
757 The keys being held while clicking.
758
759 - `class DoubleClick: …`
760
761 A double click action.
762
763 - `keys: Optional[List[str]]`
764
765 The keys being held while double-clicking.
766
767 - `type: Literal["double_click"]`
768
769 Specifies the event type. For a double click action, this property is always set to `double_click`.
770
771 - `"double_click"`
772
773 - `x: int`
774
775 The x-coordinate where the double click occurred.
776
777 - `y: int`
778
779 The y-coordinate where the double click occurred.
780
781 - `class Drag: …`
782
783 A drag action.
784
785 - `path: List[DragPath]`
786
787 An array of coordinates representing the path of the drag action. Coordinates will appear as an array of objects, eg
788
789 ```
790 [
791 { x: 100, y: 200 },
792 { x: 200, y: 300 }
793 ]
794 ```
795
796 - `x: int`
797
798 The x-coordinate.
799
800 - `y: int`
801
802 The y-coordinate.
803
804 - `type: Literal["drag"]`
805
806 Specifies the event type. For a drag action, this property is always set to `drag`.
807
808 - `"drag"`
809
810 - `keys: Optional[List[str]]`
811
812 The keys being held while dragging the mouse.
813
814 - `class Keypress: …`
815
816 A collection of keypresses the model would like to perform.
817
818 - `keys: List[str]`
819
820 The combination of keys the model is requesting to be pressed. This is an array of strings, each representing a key.
821
822 - `type: Literal["keypress"]`
823
824 Specifies the event type. For a keypress action, this property is always set to `keypress`.
825
826 - `"keypress"`
827
828 - `class Move: …`
829
830 A mouse move action.
831
832 - `type: Literal["move"]`
833
834 Specifies the event type. For a move action, this property is always set to `move`.
835
836 - `"move"`
837
838 - `x: int`
839
840 The x-coordinate to move to.
841
842 - `y: int`
843
844 The y-coordinate to move to.
845
846 - `keys: Optional[List[str]]`
847
848 The keys being held while moving the mouse.
849
850 - `class Screenshot: …`
851
852 A screenshot action.
853
854 - `type: Literal["screenshot"]`
855
856 Specifies the event type. For a screenshot action, this property is always set to `screenshot`.
857
858 - `"screenshot"`
859
860 - `class Scroll: …`
861
862 A scroll action.
863
864 - `scroll_x: int`
865
866 The horizontal scroll distance.
867
868 - `scroll_y: int`
869
870 The vertical scroll distance.
871
872 - `type: Literal["scroll"]`
873
874 Specifies the event type. For a scroll action, this property is always set to `scroll`.
875
876 - `"scroll"`
877
878 - `x: int`
879
880 The x-coordinate where the scroll occurred.
881
882 - `y: int`
883
884 The y-coordinate where the scroll occurred.
885
886 - `keys: Optional[List[str]]`
887
888 The keys being held while scrolling.
889
890 - `class Type: …`
891
892 An action to type in text.
893
894 - `text: str`
895
896 The text to type.
897
898 - `type: Literal["type"]`
899
900 Specifies the event type. For a type action, this property is always set to `type`.
901
902 - `"type"`
903
904 - `class Wait: …`
905
906 A wait action.
907
908 - `type: Literal["wait"]`
909
910 Specifies the event type. For a wait action, this property is always set to `wait`.
911
912 - `"wait"`
913
914 - `class ComputerCallOutput: …`
915
916 The output of a computer tool call.
917
918 - `call_id: str`
919
920 The ID of the computer tool call that produced the output.
921
922 - `output: ResponseComputerToolCallOutputScreenshot`
923
924 A computer screenshot image used with the computer use tool.
925
926 - `type: Literal["computer_screenshot"]`
927
928 Specifies the event type. For a computer screenshot, this property is
929 always set to `computer_screenshot`.
930
931 - `"computer_screenshot"`
932
933 - `file_id: Optional[str]`
934
935 The identifier of an uploaded file that contains the screenshot.
936
937 - `image_url: Optional[str]`
938
939 The URL of the screenshot image.
940
941 - `type: Literal["computer_call_output"]`
942
943 The type of the computer tool call output. Always `computer_call_output`.
944
945 - `"computer_call_output"`
946
947 - `id: Optional[str]`
948
949 The ID of the computer tool call output.
950
951 - `acknowledged_safety_checks: Optional[List[ComputerCallOutputAcknowledgedSafetyCheck]]`
952
953 The safety checks reported by the API that have been acknowledged by the developer.
954
955 - `id: str`
956
957 The ID of the pending safety check.
958
959 - `code: Optional[str]`
960
961 The type of the pending safety check.
962
963 - `message: Optional[str]`
964
965 Details about the pending safety check.
966
967 - `status: Optional[Literal["in_progress", "completed", "incomplete"]]`
968
969 The status of the message input. One of `in_progress`, `completed`, or `incomplete`. Populated when input items are returned via API.
970
971 - `"in_progress"`
972
973 - `"completed"`
974
975 - `"incomplete"`
976
977 - `class ResponseFunctionWebSearch: …`
978
979 The results of a web search tool call. See the
980 [web search guide](https://platform.openai.com/docs/guides/tools-web-search) for more information.
981
982 - `id: str`
983
984 The unique ID of the web search tool call.
985
986 - `action: Action`
987
988 An object describing the specific action taken in this web search call.
989 Includes details on how the model used the web (search, open_page, find_in_page).
990
991 - `class ActionSearch: …`
992
993 Action type "search" - Performs a web search query.
994
995 - `query: str`
996
997 [DEPRECATED] The search query.
998
999 - `type: Literal["search"]`
1000
1001 The action type.
1002
1003 - `"search"`
1004
1005 - `queries: Optional[List[str]]`
1006
1007 The search queries.
1008
1009 - `sources: Optional[List[ActionSearchSource]]`
1010
1011 The sources used in the search.
1012
1013 - `type: Literal["url"]`
1014
1015 The type of source. Always `url`.
1016
1017 - `"url"`
1018
1019 - `url: str`
1020
1021 The URL of the source.
1022
1023 - `class ActionOpenPage: …`
1024
1025 Action type "open_page" - Opens a specific URL from search results.
1026
1027 - `type: Literal["open_page"]`
1028
1029 The action type.
1030
1031 - `"open_page"`
1032
1033 - `url: Optional[str]`
1034
1035 The URL opened by the model.
1036
1037 - `class ActionFindInPage: …`
1038
1039 Action type "find_in_page": Searches for a pattern within a loaded page.
1040
1041 - `pattern: str`
1042
1043 The pattern or text to search for within the page.
1044
1045 - `type: Literal["find_in_page"]`
1046
1047 The action type.
1048
1049 - `"find_in_page"`
1050
1051 - `url: str`
1052
1053 The URL of the page searched for the pattern.
1054
1055 - `status: Literal["in_progress", "searching", "completed", "failed"]`
1056
1057 The status of the web search tool call.
1058
1059 - `"in_progress"`
1060
1061 - `"searching"`
1062
1063 - `"completed"`
1064
1065 - `"failed"`
1066
1067 - `type: Literal["web_search_call"]`
1068
1069 The type of the web search tool call. Always `web_search_call`.
1070
1071 - `"web_search_call"`
1072
1073 - `class ResponseFunctionToolCall: …`
1074
1075 A tool call to run a function. See the
1076 [function calling guide](https://platform.openai.com/docs/guides/function-calling) for more information.
1077
1078 - `arguments: str`
1079
1080 A JSON string of the arguments to pass to the function.
1081
1082 - `call_id: str`
1083
1084 The unique ID of the function tool call generated by the model.
1085
1086 - `name: str`
1087
1088 The name of the function to run.
1089
1090 - `type: Literal["function_call"]`
1091
1092 The type of the function tool call. Always `function_call`.
1093
1094 - `"function_call"`
1095
1096 - `id: Optional[str]`
1097
1098 The unique ID of the function tool call.
1099
1100 - `namespace: Optional[str]`
1101
1102 The namespace of the function to run.
1103
1104 - `status: Optional[Literal["in_progress", "completed", "incomplete"]]`
1105
1106 The status of the item. One of `in_progress`, `completed`, or
1107 `incomplete`. Populated when items are returned via API.
1108
1109 - `"in_progress"`
1110
1111 - `"completed"`
1112
1113 - `"incomplete"`
1114
1115 - `class FunctionCallOutput: …`
1116
1117 The output of a function tool call.
1118
1119 - `call_id: str`
1120
1121 The unique ID of the function tool call generated by the model.
1122
1123 - `output: Union[str, ResponseFunctionCallOutputItemList]`
1124
1125 Text, image, or file output of the function tool call.
1126
1127 - `str`
1128
1129 A JSON string of the output of the function tool call.
1130
1131 - `List[ResponseFunctionCallOutputItem]`
1132
1133 - `class ResponseInputTextContent: …`
1134
1135 A text input to the model.
1136
1137 - `text: str`
1138
1139 The text input to the model.
1140
1141 - `type: Literal["input_text"]`
1142
1143 The type of the input item. Always `input_text`.
1144
1145 - `"input_text"`
1146
1147 - `class ResponseInputImageContent: …`
1148
1149 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision)
1150
1151 - `type: Literal["input_image"]`
1152
1153 The type of the input item. Always `input_image`.
1154
1155 - `"input_image"`
1156
1157 - `detail: Optional[Literal["low", "high", "auto", "original"]]`
1158
1159 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
1160
1161 - `"low"`
1162
1163 - `"high"`
1164
1165 - `"auto"`
1166
1167 - `"original"`
1168
1169 - `file_id: Optional[str]`
1170
1171 The ID of the file to be sent to the model.
1172
1173 - `image_url: Optional[str]`
1174
1175 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.
1176
1177 - `class ResponseInputFileContent: …`
1178
1179 A file input to the model.
1180
1181 - `type: Literal["input_file"]`
1182
1183 The type of the input item. Always `input_file`.
1184
1185 - `"input_file"`
1186
1187 - `detail: Optional[Literal["low", "high"]]`
1188
1189 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.
1190
1191 - `"low"`
1192
1193 - `"high"`
1194
1195 - `file_data: Optional[str]`
1196
1197 The base64-encoded data of the file to be sent to the model.
1198
1199 - `file_id: Optional[str]`
1200
1201 The ID of the file to be sent to the model.
1202
1203 - `file_url: Optional[str]`
1204
1205 The URL of the file to be sent to the model.
1206
1207 - `filename: Optional[str]`
1208
1209 The name of the file to be sent to the model.
1210
1211 - `type: Literal["function_call_output"]`
1212
1213 The type of the function tool call output. Always `function_call_output`.
1214
1215 - `"function_call_output"`
1216
1217 - `id: Optional[str]`
1218
1219 The unique ID of the function tool call output. Populated when this item is returned via API.
1220
1221 - `status: Optional[Literal["in_progress", "completed", "incomplete"]]`
1222
1223 The status of the item. One of `in_progress`, `completed`, or `incomplete`. Populated when items are returned via API.
1224
1225 - `"in_progress"`
1226
1227 - `"completed"`
1228
1229 - `"incomplete"`
1230
1231 - `class ToolSearchCall: …`
1232
1233 - `arguments: object`
1234
1235 The arguments supplied to the tool search call.
1236
1237 - `type: Literal["tool_search_call"]`
1238
1239 The item type. Always `tool_search_call`.
1240
1241 - `"tool_search_call"`
1242
1243 - `id: Optional[str]`
1244
1245 The unique ID of this tool search call.
1246
1247 - `call_id: Optional[str]`
1248
1249 The unique ID of the tool search call generated by the model.
1250
1251 - `execution: Optional[Literal["server", "client"]]`
1252
1253 Whether tool search was executed by the server or by the client.
1254
1255 - `"server"`
1256
1257 - `"client"`
1258
1259 - `status: Optional[Literal["in_progress", "completed", "incomplete"]]`
1260
1261 The status of the tool search call.
1262
1263 - `"in_progress"`
1264
1265 - `"completed"`
1266
1267 - `"incomplete"`
1268
1269 - `class ResponseToolSearchOutputItemParam: …`
1270
1271 - `tools: List[Tool]`
1272
1273 The loaded tool definitions returned by the tool search output.
1274
1275 - `class FunctionTool: …`
1276
1277 Defines a function in your own code the model can choose to call. Learn more about [function calling](https://platform.openai.com/docs/guides/function-calling).
1278
1279 - `name: str`
1280
1281 The name of the function to call.
1282
1283 - `parameters: Optional[Dict[str, object]]`
1284
1285 A JSON schema object describing the parameters of the function.
1286
1287 - `strict: Optional[bool]`
1288
1289 Whether to enforce strict parameter validation. Default `true`.
1290
1291 - `type: Literal["function"]`
1292
1293 The type of the function tool. Always `function`.
1294
1295 - `"function"`
1296
1297 - `defer_loading: Optional[bool]`
1298
1299 Whether this function is deferred and loaded via tool search.
1300
1301 - `description: Optional[str]`
1302
1303 A description of the function. Used by the model to determine whether or not to call the function.
1304
1305 - `class FileSearchTool: …`
1306
1307 A tool that searches for relevant content from uploaded files. Learn more about the [file search tool](https://platform.openai.com/docs/guides/tools-file-search).
1308
1309 - `type: Literal["file_search"]`
1310
1311 The type of the file search tool. Always `file_search`.
1312
1313 - `"file_search"`
1314
1315 - `vector_store_ids: List[str]`
1316
1317 The IDs of the vector stores to search.
1318
1319 - `filters: Optional[Filters]`
1320
1321 A filter to apply.
1322
1323 - `class ComparisonFilter: …`
1324
1325 A filter used to compare a specified attribute key to a given value using a defined comparison operation.
1326
1327 - `key: str`
1328
1329 The key to compare against the value.
1330
1331 - `type: Literal["eq", "ne", "gt", 5 more]`
1332
1333 Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`, `nin`.
1334
1335 - `eq`: equals
1336 - `ne`: not equal
1337 - `gt`: greater than
1338 - `gte`: greater than or equal
1339 - `lt`: less than
1340 - `lte`: less than or equal
1341 - `in`: in
1342 - `nin`: not in
1343
1344 - `"eq"`
1345
1346 - `"ne"`
1347
1348 - `"gt"`
1349
1350 - `"gte"`
1351
1352 - `"lt"`
1353
1354 - `"lte"`
1355
1356 - `"in"`
1357
1358 - `"nin"`
1359
1360 - `value: Union[str, float, bool, List[Union[str, float]]]`
1361
1362 The value to compare against the attribute key; supports string, number, or boolean types.
1363
1364 - `str`
1365
1366 - `float`
1367
1368 - `bool`
1369
1370 - `List[Union[str, float]]`
1371
1372 - `str`
1373
1374 - `float`
1375
1376 - `class CompoundFilter: …`
1377
1378 Combine multiple filters using `and` or `or`.
1379
1380 - `filters: List[Filter]`
1381
1382 Array of filters to combine. Items can be `ComparisonFilter` or `CompoundFilter`.
1383
1384 - `class ComparisonFilter: …`
1385
1386 A filter used to compare a specified attribute key to a given value using a defined comparison operation.
1387
1388 - `object`
1389
1390 - `type: Literal["and", "or"]`
1391
1392 Type of operation: `and` or `or`.
1393
1394 - `"and"`
1395
1396 - `"or"`
1397
1398 - `max_num_results: Optional[int]`
1399
1400 The maximum number of results to return. This number should be between 1 and 50 inclusive.
1401
1402 - `ranking_options: Optional[RankingOptions]`
1403
1404 Ranking options for search.
1405
1406 - `hybrid_search: Optional[RankingOptionsHybridSearch]`
1407
1408 Weights that control how reciprocal rank fusion balances semantic embedding matches versus sparse keyword matches when hybrid search is enabled.
1409
1410 - `embedding_weight: float`
1411
1412 The weight of the embedding in the reciprocal ranking fusion.
1413
1414 - `text_weight: float`
1415
1416 The weight of the text in the reciprocal ranking fusion.
1417
1418 - `ranker: Optional[Literal["auto", "default-2024-11-15"]]`
1419
1420 The ranker to use for the file search.
1421
1422 - `"auto"`
1423
1424 - `"default-2024-11-15"`
1425
1426 - `score_threshold: Optional[float]`
1427
1428 The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer results.
1429
1430 - `class ComputerTool: …`
1431
1432 A tool that controls a virtual computer. Learn more about the [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
1433
1434 - `type: Literal["computer"]`
1435
1436 The type of the computer tool. Always `computer`.
1437
1438 - `"computer"`
1439
1440 - `class ComputerUsePreviewTool: …`
1441
1442 A tool that controls a virtual computer. Learn more about the [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
1443
1444 - `display_height: int`
1445
1446 The height of the computer display.
1447
1448 - `display_width: int`
1449
1450 The width of the computer display.
1451
1452 - `environment: Literal["windows", "mac", "linux", 2 more]`
1453
1454 The type of computer environment to control.
1455
1456 - `"windows"`
1457
1458 - `"mac"`
1459
1460 - `"linux"`
1461
1462 - `"ubuntu"`
1463
1464 - `"browser"`
1465
1466 - `type: Literal["computer_use_preview"]`
1467
1468 The type of the computer use tool. Always `computer_use_preview`.
1469
1470 - `"computer_use_preview"`
1471
1472 - `class WebSearchTool: …`
1473
1474 Search the Internet for sources related to the prompt. Learn more about the
1475 [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
1476
1477 - `type: Literal["web_search", "web_search_2025_08_26"]`
1478
1479 The type of the web search tool. One of `web_search` or `web_search_2025_08_26`.
1480
1481 - `"web_search"`
1482
1483 - `"web_search_2025_08_26"`
1484
1485 - `filters: Optional[Filters]`
1486
1487 Filters for the search.
1488
1489 - `allowed_domains: Optional[List[str]]`
1490
1491 Allowed domains for the search. If not provided, all domains are allowed.
1492 Subdomains of the provided domains are allowed as well.
1493
1494 Example: `["pubmed.ncbi.nlm.nih.gov"]`
1495
1496 - `search_context_size: Optional[Literal["low", "medium", "high"]]`
1497
1498 High level guidance for the amount of context window space to use for the search. One of `low`, `medium`, or `high`. `medium` is the default.
1499
1500 - `"low"`
1501
1502 - `"medium"`
1503
1504 - `"high"`
1505
1506 - `user_location: Optional[UserLocation]`
1507
1508 The approximate location of the user.
1509
1510 - `city: Optional[str]`
1511
1512 Free text input for the city of the user, e.g. `San Francisco`.
1513
1514 - `country: Optional[str]`
1515
1516 The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user, e.g. `US`.
1517
1518 - `region: Optional[str]`
1519
1520 Free text input for the region of the user, e.g. `California`.
1521
1522 - `timezone: Optional[str]`
1523
1524 The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the user, e.g. `America/Los_Angeles`.
1525
1526 - `type: Optional[Literal["approximate"]]`
1527
1528 The type of location approximation. Always `approximate`.
1529
1530 - `"approximate"`
1531
1532 - `class Mcp: …`
1533
1534 Give the model access to additional tools via remote Model Context Protocol
1535 (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).
1536
1537 - `server_label: str`
1538
1539 A label for this MCP server, used to identify it in tool calls.
1540
1541 - `type: Literal["mcp"]`
1542
1543 The type of the MCP tool. Always `mcp`.
1544
1545 - `"mcp"`
1546
1547 - `allowed_tools: Optional[McpAllowedTools]`
1548
1549 List of allowed tool names or a filter object.
1550
1551 - `List[str]`
1552
1553 A string array of allowed tool names
1554
1555 - `class McpAllowedToolsMcpToolFilter: …`
1556
1557 A filter object to specify which tools are allowed.
1558
1559 - `read_only: Optional[bool]`
1560
1561 Indicates whether or not a tool modifies data or is read-only. If an
1562 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
1563 it will match this filter.
1564
1565 - `tool_names: Optional[List[str]]`
1566
1567 List of allowed tool names.
1568
1569 - `authorization: Optional[str]`
1570
1571 An OAuth access token that can be used with a remote MCP server, either
1572 with a custom MCP server URL or a service connector. Your application
1573 must handle the OAuth authorization flow and provide the token here.
1574
1575 - `connector_id: Optional[Literal["connector_dropbox", "connector_gmail", "connector_googlecalendar", 5 more]]`
1576
1577 Identifier for service connectors, like those available in ChatGPT. One of
1578 `server_url` or `connector_id` must be provided. Learn more about service
1579 connectors [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).
1580
1581 Currently supported `connector_id` values are:
1582
1583 - Dropbox: `connector_dropbox`
1584 - Gmail: `connector_gmail`
1585 - Google Calendar: `connector_googlecalendar`
1586 - Google Drive: `connector_googledrive`
1587 - Microsoft Teams: `connector_microsoftteams`
1588 - Outlook Calendar: `connector_outlookcalendar`
1589 - Outlook Email: `connector_outlookemail`
1590 - SharePoint: `connector_sharepoint`
1591
1592 - `"connector_dropbox"`
1593
1594 - `"connector_gmail"`
1595
1596 - `"connector_googlecalendar"`
1597
1598 - `"connector_googledrive"`
1599
1600 - `"connector_microsoftteams"`
1601
1602 - `"connector_outlookcalendar"`
1603
1604 - `"connector_outlookemail"`
1605
1606 - `"connector_sharepoint"`
1607
1608 - `defer_loading: Optional[bool]`
1609
1610 Whether this MCP tool is deferred and discovered via tool search.
1611
1612 - `headers: Optional[Dict[str, str]]`
1613
1614 Optional HTTP headers to send to the MCP server. Use for authentication
1615 or other purposes.
1616
1617 - `require_approval: Optional[McpRequireApproval]`
1618
1619 Specify which of the MCP server's tools require approval.
1620
1621 - `class McpRequireApprovalMcpToolApprovalFilter: …`
1622
1623 Specify which of the MCP server's tools require approval. Can be
1624 `always`, `never`, or a filter object associated with tools
1625 that require approval.
1626
1627 - `always: Optional[McpRequireApprovalMcpToolApprovalFilterAlways]`
1628
1629 A filter object to specify which tools are allowed.
1630
1631 - `read_only: Optional[bool]`
1632
1633 Indicates whether or not a tool modifies data or is read-only. If an
1634 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
1635 it will match this filter.
1636
1637 - `tool_names: Optional[List[str]]`
1638
1639 List of allowed tool names.
1640
1641 - `never: Optional[McpRequireApprovalMcpToolApprovalFilterNever]`
1642
1643 A filter object to specify which tools are allowed.
1644
1645 - `read_only: Optional[bool]`
1646
1647 Indicates whether or not a tool modifies data or is read-only. If an
1648 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
1649 it will match this filter.
1650
1651 - `tool_names: Optional[List[str]]`
1652
1653 List of allowed tool names.
1654
1655 - `Literal["always", "never"]`
1656
1657 Specify a single approval policy for all tools. One of `always` or
1658 `never`. When set to `always`, all tools will require approval. When
1659 set to `never`, all tools will not require approval.
1660
1661 - `"always"`
1662
1663 - `"never"`
1664
1665 - `server_description: Optional[str]`
1666
1667 Optional description of the MCP server, used to provide more context.
1668
1669 - `server_url: Optional[str]`
1670
1671 The URL for the MCP server. One of `server_url` or `connector_id` must be
1672 provided.
1673
1674 - `class CodeInterpreter: …`
1675
1676 A tool that runs Python code to help generate a response to a prompt.
1677
1678 - `container: CodeInterpreterContainer`
1679
1680 The code interpreter container. Can be a container ID or an object that
1681 specifies uploaded file IDs to make available to your code, along with an
1682 optional `memory_limit` setting.
1683
1684 - `str`
1685
1686 The container ID.
1687
1688 - `class CodeInterpreterContainerCodeInterpreterToolAuto: …`
1689
1690 Configuration for a code interpreter container. Optionally specify the IDs of the files to run the code on.
1691
1692 - `type: Literal["auto"]`
1693
1694 Always `auto`.
1695
1696 - `"auto"`
1697
1698 - `file_ids: Optional[List[str]]`
1699
1700 An optional list of uploaded files to make available to your code.
1701
1702 - `memory_limit: Optional[Literal["1g", "4g", "16g", "64g"]]`
1703
1704 The memory limit for the code interpreter container.
1705
1706 - `"1g"`
1707
1708 - `"4g"`
1709
1710 - `"16g"`
1711
1712 - `"64g"`
1713
1714 - `network_policy: Optional[CodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicy]`
1715
1716 Network access policy for the container.
1717
1718 - `class ContainerNetworkPolicyDisabled: …`
1719
1720 - `type: Literal["disabled"]`
1721
1722 Disable outbound network access. Always `disabled`.
1723
1724 - `"disabled"`
1725
1726 - `class ContainerNetworkPolicyAllowlist: …`
1727
1728 - `allowed_domains: List[str]`
1729
1730 A list of allowed domains when type is `allowlist`.
1731
1732 - `type: Literal["allowlist"]`
1733
1734 Allow outbound network access only to specified domains. Always `allowlist`.
1735
1736 - `"allowlist"`
1737
1738 - `domain_secrets: Optional[List[ContainerNetworkPolicyDomainSecret]]`
1739
1740 Optional domain-scoped secrets for allowlisted domains.
1741
1742 - `domain: str`
1743
1744 The domain associated with the secret.
1745
1746 - `name: str`
1747
1748 The name of the secret to inject for the domain.
1749
1750 - `value: str`
1751
1752 The secret value to inject for the domain.
1753
1754 - `type: Literal["code_interpreter"]`
1755
1756 The type of the code interpreter tool. Always `code_interpreter`.
1757
1758 - `"code_interpreter"`
1759
1760 - `class ImageGeneration: …`
1761
1762 A tool that generates images using the GPT image models.
1763
1764 - `type: Literal["image_generation"]`
1765
1766 The type of the image generation tool. Always `image_generation`.
1767
1768 - `"image_generation"`
1769
1770 - `action: Optional[Literal["generate", "edit", "auto"]]`
1771
1772 Whether to generate a new image or edit an existing image. Default: `auto`.
1773
1774 - `"generate"`
1775
1776 - `"edit"`
1777
1778 - `"auto"`
1779
1780 - `background: Optional[Literal["transparent", "opaque", "auto"]]`
1781
1782 Allows to set transparency for the background of the generated image(s).
1783 This parameter is only supported for GPT image models that support
1784 transparent backgrounds. Must be one of `transparent`, `opaque`, or
1785 `auto` (default value). When `auto` is used, the model will
1786 automatically determine the best background for the image.
1787
1788 `gpt-image-2` and `gpt-image-2-2026-04-21` do not support
1789 transparent backgrounds. Requests with `background` set to
1790 `transparent` will return an error for these models; use `opaque` or
1791 `auto` instead.
1792
1793 If `transparent`, the output format needs to support transparency,
1794 so it should be set to either `png` (default value) or `webp`.
1795
1796 - `"transparent"`
1797
1798 - `"opaque"`
1799
1800 - `"auto"`
1801
1802 - `input_fidelity: Optional[Literal["high", "low"]]`
1803
1804 Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for `gpt-image-1` and `gpt-image-1.5` and later models, unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`.
1805
1806 - `"high"`
1807
1808 - `"low"`
1809
1810 - `input_image_mask: Optional[ImageGenerationInputImageMask]`
1811
1812 Optional mask for inpainting. Contains `image_url`
1813 (string, optional) and `file_id` (string, optional).
1814
1815 - `file_id: Optional[str]`
1816
1817 File ID for the mask image.
1818
1819 - `image_url: Optional[str]`
1820
1821 Base64-encoded mask image.
1822
1823 - `model: Optional[Union[str, Literal["gpt-image-1", "gpt-image-1-mini", "gpt-image-2", 3 more], null]]`
1824
1825 The image generation model to use. Default: `gpt-image-1`.
1826
1827 - `str`
1828
1829 - `Literal["gpt-image-1", "gpt-image-1-mini", "gpt-image-2", 3 more]`
1830
1831 The image generation model to use. Default: `gpt-image-1`.
1832
1833 - `"gpt-image-1"`
1834
1835 - `"gpt-image-1-mini"`
1836
1837 - `"gpt-image-2"`
1838
1839 - `"gpt-image-2-2026-04-21"`
1840
1841 - `"gpt-image-1.5"`
1842
1843 - `"chatgpt-image-latest"`
1844
1845 - `moderation: Optional[Literal["auto", "low"]]`
1846
1847 Moderation level for the generated image. Default: `auto`.
1848
1849 - `"auto"`
1850
1851 - `"low"`
1852
1853 - `output_compression: Optional[int]`
1854
1855 Compression level for the output image. Default: 100.
1856
1857 - `output_format: Optional[Literal["png", "webp", "jpeg"]]`
1858
1859 The output format of the generated image. One of `png`, `webp`, or
1860 `jpeg`. Default: `png`.
1861
1862 - `"png"`
1863
1864 - `"webp"`
1865
1866 - `"jpeg"`
1867
1868 - `partial_images: Optional[int]`
1869
1870 Number of partial images to generate in streaming mode, from 0 (default value) to 3.
1871
1872 - `quality: Optional[Literal["low", "medium", "high", "auto"]]`
1873
1874 The quality of the generated image. One of `low`, `medium`, `high`,
1875 or `auto`. Default: `auto`.
1876
1877 - `"low"`
1878
1879 - `"medium"`
1880
1881 - `"high"`
1882
1883 - `"auto"`
1884
1885 - `size: Optional[Union[str, Literal["1024x1024", "1024x1536", "1536x1024", "auto"], null]]`
1886
1887 The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum supported resolution is `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`.
1888
1889 - `str`
1890
1891 - `Literal["1024x1024", "1024x1536", "1536x1024", "auto"]`
1892
1893 The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum supported resolution is `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`.
1894
1895 - `"1024x1024"`
1896
1897 - `"1024x1536"`
1898
1899 - `"1536x1024"`
1900
1901 - `"auto"`
1902
1903 - `class LocalShell: …`
1904
1905 A tool that allows the model to execute shell commands in a local environment.
1906
1907 - `type: Literal["local_shell"]`
1908
1909 The type of the local shell tool. Always `local_shell`.
1910
1911 - `"local_shell"`
1912
1913 - `class FunctionShellTool: …`
1914
1915 A tool that allows the model to execute shell commands.
1916
1917 - `type: Literal["shell"]`
1918
1919 The type of the shell tool. Always `shell`.
1920
1921 - `"shell"`
1922
1923 - `environment: Optional[Environment]`
1924
1925 - `class ContainerAuto: …`
1926
1927 - `type: Literal["container_auto"]`
1928
1929 Automatically creates a container for this request
1930
1931 - `"container_auto"`
1932
1933 - `file_ids: Optional[List[str]]`
1934
1935 An optional list of uploaded files to make available to your code.
1936
1937 - `memory_limit: Optional[Literal["1g", "4g", "16g", "64g"]]`
1938
1939 The memory limit for the container.
1940
1941 - `"1g"`
1942
1943 - `"4g"`
1944
1945 - `"16g"`
1946
1947 - `"64g"`
1948
1949 - `network_policy: Optional[NetworkPolicy]`
1950
1951 Network access policy for the container.
1952
1953 - `class ContainerNetworkPolicyDisabled: …`
1954
1955 - `class ContainerNetworkPolicyAllowlist: …`
1956
1957 - `skills: Optional[List[Skill]]`
1958
1959 An optional list of skills referenced by id or inline data.
1960
1961 - `class SkillReference: …`
1962
1963 - `skill_id: str`
1964
1965 The ID of the referenced skill.
1966
1967 - `type: Literal["skill_reference"]`
1968
1969 References a skill created with the /v1/skills endpoint.
1970
1971 - `"skill_reference"`
1972
1973 - `version: Optional[str]`
1974
1975 Optional skill version. Use a positive integer or 'latest'. Omit for default.
1976
1977 - `class InlineSkill: …`
1978
1979 - `description: str`
1980
1981 The description of the skill.
1982
1983 - `name: str`
1984
1985 The name of the skill.
1986
1987 - `source: InlineSkillSource`
1988
1989 Inline skill payload
1990
1991 - `data: str`
1992
1993 Base64-encoded skill zip bundle.
1994
1995 - `media_type: Literal["application/zip"]`
1996
1997 The media type of the inline skill payload. Must be `application/zip`.
1998
1999 - `"application/zip"`
2000
2001 - `type: Literal["base64"]`
2002
2003 The type of the inline skill source. Must be `base64`.
2004
2005 - `"base64"`
2006
2007 - `type: Literal["inline"]`
2008
2009 Defines an inline skill for this request.
2010
2011 - `"inline"`
2012
2013 - `class LocalEnvironment: …`
2014
2015 - `type: Literal["local"]`
2016
2017 Use a local computer environment.
2018
2019 - `"local"`
2020
2021 - `skills: Optional[List[LocalSkill]]`
2022
2023 An optional list of skills.
2024
2025 - `description: str`
2026
2027 The description of the skill.
2028
2029 - `name: str`
2030
2031 The name of the skill.
2032
2033 - `path: str`
2034
2035 The path to the directory containing the skill.
2036
2037 - `class ContainerReference: …`
2038
2039 - `container_id: str`
2040
2041 The ID of the referenced container.
2042
2043 - `type: Literal["container_reference"]`
2044
2045 References a container created with the /v1/containers endpoint
2046
2047 - `"container_reference"`
2048
2049 - `class CustomTool: …`
2050
2051 A custom tool that processes input using a specified format. Learn more about [custom tools](https://platform.openai.com/docs/guides/function-calling#custom-tools)
2052
2053 - `name: str`
2054
2055 The name of the custom tool, used to identify it in tool calls.
2056
2057 - `type: Literal["custom"]`
2058
2059 The type of the custom tool. Always `custom`.
2060
2061 - `"custom"`
2062
2063 - `defer_loading: Optional[bool]`
2064
2065 Whether this tool should be deferred and discovered via tool search.
2066
2067 - `description: Optional[str]`
2068
2069 Optional description of the custom tool, used to provide more context.
2070
2071 - `format: Optional[CustomToolInputFormat]`
2072
2073 The input format for the custom tool. Default is unconstrained text.
2074
2075 - `class Text: …`
2076
2077 Unconstrained free-form text.
2078
2079 - `type: Literal["text"]`
2080
2081 Unconstrained text format. Always `text`.
2082
2083 - `"text"`
2084
2085 - `class Grammar: …`
2086
2087 A grammar defined by the user.
2088
2089 - `definition: str`
2090
2091 The grammar definition.
2092
2093 - `syntax: Literal["lark", "regex"]`
2094
2095 The syntax of the grammar definition. One of `lark` or `regex`.
2096
2097 - `"lark"`
2098
2099 - `"regex"`
2100
2101 - `type: Literal["grammar"]`
2102
2103 Grammar format. Always `grammar`.
2104
2105 - `"grammar"`
2106
2107 - `class NamespaceTool: …`
2108
2109 Groups function/custom tools under a shared namespace.
2110
2111 - `description: str`
2112
2113 A description of the namespace shown to the model.
2114
2115 - `name: str`
2116
2117 The namespace name used in tool calls (for example, `crm`).
2118
2119 - `tools: List[Tool]`
2120
2121 The function/custom tools available inside this namespace.
2122
2123 - `class ToolFunction: …`
2124
2125 - `name: str`
2126
2127 - `type: Literal["function"]`
2128
2129 - `"function"`
2130
2131 - `defer_loading: Optional[bool]`
2132
2133 Whether this function should be deferred and discovered via tool search.
2134
2135 - `description: Optional[str]`
2136
2137 - `parameters: Optional[object]`
2138
2139 - `strict: Optional[bool]`
2140
2141 - `class CustomTool: …`
2142
2143 A custom tool that processes input using a specified format. Learn more about [custom tools](https://platform.openai.com/docs/guides/function-calling#custom-tools)
2144
2145 - `type: Literal["namespace"]`
2146
2147 The type of the tool. Always `namespace`.
2148
2149 - `"namespace"`
2150
2151 - `class ToolSearchTool: …`
2152
2153 Hosted or BYOT tool search configuration for deferred tools.
2154
2155 - `type: Literal["tool_search"]`
2156
2157 The type of the tool. Always `tool_search`.
2158
2159 - `"tool_search"`
2160
2161 - `description: Optional[str]`
2162
2163 Description shown to the model for a client-executed tool search tool.
2164
2165 - `execution: Optional[Literal["server", "client"]]`
2166
2167 Whether tool search is executed by the server or by the client.
2168
2169 - `"server"`
2170
2171 - `"client"`
2172
2173 - `parameters: Optional[object]`
2174
2175 Parameter schema for a client-executed tool search tool.
2176
2177 - `class WebSearchPreviewTool: …`
2178
2179 This tool searches the web for relevant results to use in a response. Learn more about the [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
2180
2181 - `type: Literal["web_search_preview", "web_search_preview_2025_03_11"]`
2182
2183 The type of the web search tool. One of `web_search_preview` or `web_search_preview_2025_03_11`.
2184
2185 - `"web_search_preview"`
2186
2187 - `"web_search_preview_2025_03_11"`
2188
2189 - `search_content_types: Optional[List[Literal["text", "image"]]]`
2190
2191 - `"text"`
2192
2193 - `"image"`
2194
2195 - `search_context_size: Optional[Literal["low", "medium", "high"]]`
2196
2197 High level guidance for the amount of context window space to use for the search. One of `low`, `medium`, or `high`. `medium` is the default.
2198
2199 - `"low"`
2200
2201 - `"medium"`
2202
2203 - `"high"`
2204
2205 - `user_location: Optional[UserLocation]`
2206
2207 The user's location.
2208
2209 - `type: Literal["approximate"]`
2210
2211 The type of location approximation. Always `approximate`.
2212
2213 - `"approximate"`
2214
2215 - `city: Optional[str]`
2216
2217 Free text input for the city of the user, e.g. `San Francisco`.
2218
2219 - `country: Optional[str]`
2220
2221 The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user, e.g. `US`.
2222
2223 - `region: Optional[str]`
2224
2225 Free text input for the region of the user, e.g. `California`.
2226
2227 - `timezone: Optional[str]`
2228
2229 The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the user, e.g. `America/Los_Angeles`.
2230
2231 - `class ApplyPatchTool: …`
2232
2233 Allows the assistant to create, delete, or update files using unified diffs.
2234
2235 - `type: Literal["apply_patch"]`
2236
2237 The type of the tool. Always `apply_patch`.
2238
2239 - `"apply_patch"`
2240
2241 - `type: Literal["tool_search_output"]`
2242
2243 The item type. Always `tool_search_output`.
2244
2245 - `"tool_search_output"`
2246
2247 - `id: Optional[str]`
2248
2249 The unique ID of this tool search output.
2250
2251 - `call_id: Optional[str]`
2252
2253 The unique ID of the tool search call generated by the model.
2254
2255 - `execution: Optional[Literal["server", "client"]]`
2256
2257 Whether tool search was executed by the server or by the client.
2258
2259 - `"server"`
2260
2261 - `"client"`
2262
2263 - `status: Optional[Literal["in_progress", "completed", "incomplete"]]`
2264
2265 The status of the tool search output.
2266
2267 - `"in_progress"`
2268
2269 - `"completed"`
2270
2271 - `"incomplete"`
2272
2273 - `class ResponseReasoningItem: …`
2274
2275 A description of the chain of thought used by a reasoning model while generating
2276 a response. Be sure to include these items in your `input` to the Responses API
2277 for subsequent turns of a conversation if you are manually
2278 [managing context](https://platform.openai.com/docs/guides/conversation-state).
2279
2280 - `id: str`
2281
2282 The unique identifier of the reasoning content.
2283
2284 - `summary: List[Summary]`
2285
2286 Reasoning summary content.
2287
2288 - `text: str`
2289
2290 A summary of the reasoning output from the model so far.
2291
2292 - `type: Literal["summary_text"]`
2293
2294 The type of the object. Always `summary_text`.
2295
2296 - `"summary_text"`
2297
2298 - `type: Literal["reasoning"]`
2299
2300 The type of the object. Always `reasoning`.
2301
2302 - `"reasoning"`
2303
2304 - `content: Optional[List[Content]]`
2305
2306 Reasoning text content.
2307
2308 - `text: str`
2309
2310 The reasoning text from the model.
2311
2312 - `type: Literal["reasoning_text"]`
2313
2314 The type of the reasoning text. Always `reasoning_text`.
2315
2316 - `"reasoning_text"`
2317
2318 - `encrypted_content: Optional[str]`
2319
2320 The encrypted content of the reasoning item - populated when a response is
2321 generated with `reasoning.encrypted_content` in the `include` parameter.
2322
2323 - `status: Optional[Literal["in_progress", "completed", "incomplete"]]`
2324
2325 The status of the item. One of `in_progress`, `completed`, or
2326 `incomplete`. Populated when items are returned via API.
2327
2328 - `"in_progress"`
2329
2330 - `"completed"`
2331
2332 - `"incomplete"`
2333
2334 - `class ResponseCompactionItemParam: …`
2335
2336 A compaction item generated by the [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact).
2337
2338 - `encrypted_content: str`
2339
2340 The encrypted content of the compaction summary.
2341
2342 - `type: Literal["compaction"]`
2343
2344 The type of the item. Always `compaction`.
2345
2346 - `"compaction"`
2347
2348 - `id: Optional[str]`
2349
2350 The ID of the compaction item.
2351
2352 - `class ImageGenerationCall: …`
2353
2354 An image generation request made by the model.
2355
2356 - `id: str`
2357
2358 The unique ID of the image generation call.
2359
2360 - `result: Optional[str]`
2361
2362 The generated image encoded in base64.
2363
2364 - `status: Literal["in_progress", "completed", "generating", "failed"]`
2365
2366 The status of the image generation call.
2367
2368 - `"in_progress"`
2369
2370 - `"completed"`
2371
2372 - `"generating"`
2373
2374 - `"failed"`
2375
2376 - `type: Literal["image_generation_call"]`
2377
2378 The type of the image generation call. Always `image_generation_call`.
2379
2380 - `"image_generation_call"`
2381
2382 - `class ResponseCodeInterpreterToolCall: …`
2383
2384 A tool call to run code.
2385
2386 - `id: str`
2387
2388 The unique ID of the code interpreter tool call.
2389
2390 - `code: Optional[str]`
2391
2392 The code to run, or null if not available.
2393
2394 - `container_id: str`
2395
2396 The ID of the container used to run the code.
2397
2398 - `outputs: Optional[List[Output]]`
2399
2400 The outputs generated by the code interpreter, such as logs or images.
2401 Can be null if no outputs are available.
2402
2403 - `class OutputLogs: …`
2404
2405 The logs output from the code interpreter.
2406
2407 - `logs: str`
2408
2409 The logs output from the code interpreter.
2410
2411 - `type: Literal["logs"]`
2412
2413 The type of the output. Always `logs`.
2414
2415 - `"logs"`
2416
2417 - `class OutputImage: …`
2418
2419 The image output from the code interpreter.
2420
2421 - `type: Literal["image"]`
2422
2423 The type of the output. Always `image`.
2424
2425 - `"image"`
2426
2427 - `url: str`
2428
2429 The URL of the image output from the code interpreter.
2430
2431 - `status: Literal["in_progress", "completed", "incomplete", 2 more]`
2432
2433 The status of the code interpreter tool call. Valid values are `in_progress`, `completed`, `incomplete`, `interpreting`, and `failed`.
2434
2435 - `"in_progress"`
2436
2437 - `"completed"`
2438
2439 - `"incomplete"`
2440
2441 - `"interpreting"`
2442
2443 - `"failed"`
2444
2445 - `type: Literal["code_interpreter_call"]`
2446
2447 The type of the code interpreter tool call. Always `code_interpreter_call`.
2448
2449 - `"code_interpreter_call"`
2450
2451 - `class LocalShellCall: …`
2452
2453 A tool call to run a command on the local shell.
2454
2455 - `id: str`
2456
2457 The unique ID of the local shell call.
2458
2459 - `action: LocalShellCallAction`
2460
2461 Execute a shell command on the server.
2462
2463 - `command: List[str]`
2464
2465 The command to run.
2466
2467 - `env: Dict[str, str]`
2468
2469 Environment variables to set for the command.
2470
2471 - `type: Literal["exec"]`
2472
2473 The type of the local shell action. Always `exec`.
2474
2475 - `"exec"`
2476
2477 - `timeout_ms: Optional[int]`
2478
2479 Optional timeout in milliseconds for the command.
2480
2481 - `user: Optional[str]`
2482
2483 Optional user to run the command as.
2484
2485 - `working_directory: Optional[str]`
2486
2487 Optional working directory to run the command in.
2488
2489 - `call_id: str`
2490
2491 The unique ID of the local shell tool call generated by the model.
2492
2493 - `status: Literal["in_progress", "completed", "incomplete"]`
2494
2495 The status of the local shell call.
2496
2497 - `"in_progress"`
2498
2499 - `"completed"`
2500
2501 - `"incomplete"`
2502
2503 - `type: Literal["local_shell_call"]`
2504
2505 The type of the local shell call. Always `local_shell_call`.
2506
2507 - `"local_shell_call"`
2508
2509 - `class LocalShellCallOutput: …`
2510
2511 The output of a local shell tool call.
2512
2513 - `id: str`
2514
2515 The unique ID of the local shell tool call generated by the model.
2516
2517 - `output: str`
2518
2519 A JSON string of the output of the local shell tool call.
2520
2521 - `type: Literal["local_shell_call_output"]`
2522
2523 The type of the local shell tool call output. Always `local_shell_call_output`.
2524
2525 - `"local_shell_call_output"`
2526
2527 - `status: Optional[Literal["in_progress", "completed", "incomplete"]]`
2528
2529 The status of the item. One of `in_progress`, `completed`, or `incomplete`.
2530
2531 - `"in_progress"`
2532
2533 - `"completed"`
2534
2535 - `"incomplete"`
2536
2537 - `class ShellCall: …`
2538
2539 A tool representing a request to execute one or more shell commands.
2540
2541 - `action: ShellCallAction`
2542
2543 The shell commands and limits that describe how to run the tool call.
2544
2545 - `commands: List[str]`
2546
2547 Ordered shell commands for the execution environment to run.
2548
2549 - `max_output_length: Optional[int]`
2550
2551 Maximum number of UTF-8 characters to capture from combined stdout and stderr output.
2552
2553 - `timeout_ms: Optional[int]`
2554
2555 Maximum wall-clock time in milliseconds to allow the shell commands to run.
2556
2557 - `call_id: str`
2558
2559 The unique ID of the shell tool call generated by the model.
2560
2561 - `type: Literal["shell_call"]`
2562
2563 The type of the item. Always `shell_call`.
2564
2565 - `"shell_call"`
2566
2567 - `id: Optional[str]`
2568
2569 The unique ID of the shell tool call. Populated when this item is returned via API.
2570
2571 - `environment: Optional[ShellCallEnvironment]`
2572
2573 The environment to execute the shell commands in.
2574
2575 - `class LocalEnvironment: …`
2576
2577 - `class ContainerReference: …`
2578
2579 - `status: Optional[Literal["in_progress", "completed", "incomplete"]]`
2580
2581 The status of the shell call. One of `in_progress`, `completed`, or `incomplete`.
2582
2583 - `"in_progress"`
2584
2585 - `"completed"`
2586
2587 - `"incomplete"`
2588
2589 - `class ShellCallOutput: …`
2590
2591 The streamed output items emitted by a shell tool call.
2592
2593 - `call_id: str`
2594
2595 The unique ID of the shell tool call generated by the model.
2596
2597 - `output: List[ResponseFunctionShellCallOutputContent]`
2598
2599 Captured chunks of stdout and stderr output, along with their associated outcomes.
2600
2601 - `outcome: Outcome`
2602
2603 The exit or timeout outcome associated with this shell call.
2604
2605 - `class OutcomeTimeout: …`
2606
2607 Indicates that the shell call exceeded its configured time limit.
2608
2609 - `type: Literal["timeout"]`
2610
2611 The outcome type. Always `timeout`.
2612
2613 - `"timeout"`
2614
2615 - `class OutcomeExit: …`
2616
2617 Indicates that the shell commands finished and returned an exit code.
2618
2619 - `exit_code: int`
2620
2621 The exit code returned by the shell process.
2622
2623 - `type: Literal["exit"]`
2624
2625 The outcome type. Always `exit`.
2626
2627 - `"exit"`
2628
2629 - `stderr: str`
2630
2631 Captured stderr output for the shell call.
2632
2633 - `stdout: str`
2634
2635 Captured stdout output for the shell call.
2636
2637 - `type: Literal["shell_call_output"]`
2638
2639 The type of the item. Always `shell_call_output`.
2640
2641 - `"shell_call_output"`
2642
2643 - `id: Optional[str]`
2644
2645 The unique ID of the shell tool call output. Populated when this item is returned via API.
2646
2647 - `max_output_length: Optional[int]`
2648
2649 The maximum number of UTF-8 characters captured for this shell call's combined output.
2650
2651 - `status: Optional[Literal["in_progress", "completed", "incomplete"]]`
2652
2653 The status of the shell call output.
2654
2655 - `"in_progress"`
2656
2657 - `"completed"`
2658
2659 - `"incomplete"`
2660
2661 - `class ApplyPatchCall: …`
2662
2663 A tool call representing a request to create, delete, or update files using diff patches.
2664
2665 - `call_id: str`
2666
2667 The unique ID of the apply patch tool call generated by the model.
2668
2669 - `operation: ApplyPatchCallOperation`
2670
2671 The specific create, delete, or update instruction for the apply_patch tool call.
2672
2673 - `class ApplyPatchCallOperationCreateFile: …`
2674
2675 Instruction for creating a new file via the apply_patch tool.
2676
2677 - `diff: str`
2678
2679 Unified diff content to apply when creating the file.
2680
2681 - `path: str`
2682
2683 Path of the file to create relative to the workspace root.
2684
2685 - `type: Literal["create_file"]`
2686
2687 The operation type. Always `create_file`.
2688
2689 - `"create_file"`
2690
2691 - `class ApplyPatchCallOperationDeleteFile: …`
2692
2693 Instruction for deleting an existing file via the apply_patch tool.
2694
2695 - `path: str`
2696
2697 Path of the file to delete relative to the workspace root.
2698
2699 - `type: Literal["delete_file"]`
2700
2701 The operation type. Always `delete_file`.
2702
2703 - `"delete_file"`
2704
2705 - `class ApplyPatchCallOperationUpdateFile: …`
2706
2707 Instruction for updating an existing file via the apply_patch tool.
2708
2709 - `diff: str`
2710
2711 Unified diff content to apply to the existing file.
2712
2713 - `path: str`
2714
2715 Path of the file to update relative to the workspace root.
2716
2717 - `type: Literal["update_file"]`
2718
2719 The operation type. Always `update_file`.
2720
2721 - `"update_file"`
2722
2723 - `status: Literal["in_progress", "completed"]`
2724
2725 The status of the apply patch tool call. One of `in_progress` or `completed`.
2726
2727 - `"in_progress"`
2728
2729 - `"completed"`
2730
2731 - `type: Literal["apply_patch_call"]`
2732
2733 The type of the item. Always `apply_patch_call`.
2734
2735 - `"apply_patch_call"`
2736
2737 - `id: Optional[str]`
2738
2739 The unique ID of the apply patch tool call. Populated when this item is returned via API.
2740
2741 - `class ApplyPatchCallOutput: …`
2742
2743 The streamed output emitted by an apply patch tool call.
2744
2745 - `call_id: str`
2746
2747 The unique ID of the apply patch tool call generated by the model.
2748
2749 - `status: Literal["completed", "failed"]`
2750
2751 The status of the apply patch tool call output. One of `completed` or `failed`.
2752
2753 - `"completed"`
2754
2755 - `"failed"`
2756
2757 - `type: Literal["apply_patch_call_output"]`
2758
2759 The type of the item. Always `apply_patch_call_output`.
2760
2761 - `"apply_patch_call_output"`
2762
2763 - `id: Optional[str]`
2764
2765 The unique ID of the apply patch tool call output. Populated when this item is returned via API.
2766
2767 - `output: Optional[str]`
2768
2769 Optional human-readable log text from the apply patch tool (e.g., patch results or errors).
2770
2771 - `class McpListTools: …`
2772
2773 A list of tools available on an MCP server.
2774
2775 - `id: str`
2776
2777 The unique ID of the list.
2778
2779 - `server_label: str`
2780
2781 The label of the MCP server.
2782
2783 - `tools: List[McpListToolsTool]`
2784
2785 The tools available on the server.
2786
2787 - `input_schema: object`
2788
2789 The JSON schema describing the tool's input.
2790
2791 - `name: str`
2792
2793 The name of the tool.
2794
2795 - `annotations: Optional[object]`
2796
2797 Additional annotations about the tool.
2798
2799 - `description: Optional[str]`
2800
2801 The description of the tool.
2802
2803 - `type: Literal["mcp_list_tools"]`
2804
2805 The type of the item. Always `mcp_list_tools`.
2806
2807 - `"mcp_list_tools"`
2808
2809 - `error: Optional[str]`
2810
2811 Error message if the server could not list tools.
2812
2813 - `class McpApprovalRequest: …`
2814
2815 A request for human approval of a tool invocation.
2816
2817 - `id: str`
2818
2819 The unique ID of the approval request.
2820
2821 - `arguments: str`
2822
2823 A JSON string of arguments for the tool.
2824
2825 - `name: str`
2826
2827 The name of the tool to run.
2828
2829 - `server_label: str`
2830
2831 The label of the MCP server making the request.
2832
2833 - `type: Literal["mcp_approval_request"]`
2834
2835 The type of the item. Always `mcp_approval_request`.
2836
2837 - `"mcp_approval_request"`
2838
2839 - `class McpApprovalResponse: …`
2840
2841 A response to an MCP approval request.
2842
2843 - `approval_request_id: str`
2844
2845 The ID of the approval request being answered.
2846
2847 - `approve: bool`
2848
2849 Whether the request was approved.
2850
2851 - `type: Literal["mcp_approval_response"]`
2852
2853 The type of the item. Always `mcp_approval_response`.
2854
2855 - `"mcp_approval_response"`
2856
2857 - `id: Optional[str]`
2858
2859 The unique ID of the approval response
2860
2861 - `reason: Optional[str]`
2862
2863 Optional reason for the decision.
2864
2865 - `class McpCall: …`
2866
2867 An invocation of a tool on an MCP server.
2868
2869 - `id: str`
2870
2871 The unique ID of the tool call.
2872
2873 - `arguments: str`
2874
2875 A JSON string of the arguments passed to the tool.
2876
2877 - `name: str`
2878
2879 The name of the tool that was run.
2880
2881 - `server_label: str`
2882
2883 The label of the MCP server running the tool.
2884
2885 - `type: Literal["mcp_call"]`
2886
2887 The type of the item. Always `mcp_call`.
2888
2889 - `"mcp_call"`
2890
2891 - `approval_request_id: Optional[str]`
2892
2893 Unique identifier for the MCP tool call approval request.
2894 Include this value in a subsequent `mcp_approval_response` input to approve or reject the corresponding tool call.
2895
2896 - `error: Optional[str]`
2897
2898 The error from the tool call, if any.
2899
2900 - `output: Optional[str]`
2901
2902 The output from the tool call.
2903
2904 - `status: Optional[Literal["in_progress", "completed", "incomplete", 2 more]]`
2905
2906 The status of the tool call. One of `in_progress`, `completed`, `incomplete`, `calling`, or `failed`.
2907
2908 - `"in_progress"`
2909
2910 - `"completed"`
2911
2912 - `"incomplete"`
2913
2914 - `"calling"`
2915
2916 - `"failed"`
2917
2918 - `class ResponseCustomToolCallOutput: …`
2919
2920 The output of a custom tool call from your code, being sent back to the model.
2921
2922 - `call_id: str`
2923
2924 The call ID, used to map this custom tool call output to a custom tool call.
2925
2926 - `output: Union[str, List[OutputOutputContentList]]`
2927
2928 The output from the custom tool call generated by your code.
2929 Can be a string or an list of output content.
2930
2931 - `str`
2932
2933 A string of the output of the custom tool call.
2934
2935 - `List[OutputOutputContentList]`
2936
2937 Text, image, or file output of the custom tool call.
2938
2939 - `class ResponseInputText: …`
2940
2941 A text input to the model.
2942
2943 - `class ResponseInputImage: …`
2944
2945 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
2946
2947 - `class ResponseInputFile: …`
2948
2949 A file input to the model.
2950
2951 - `type: Literal["custom_tool_call_output"]`
2952
2953 The type of the custom tool call output. Always `custom_tool_call_output`.
2954
2955 - `"custom_tool_call_output"`
2956
2957 - `id: Optional[str]`
2958
2959 The unique ID of the custom tool call output in the OpenAI platform.
2960
2961 - `class ResponseCustomToolCall: …`
2962
2963 A call to a custom tool created by the model.
2964
2965 - `call_id: str`
2966
2967 An identifier used to map this custom tool call to a tool call output.
2968
2969 - `input: str`
2970
2971 The input for the custom tool call generated by the model.
2972
2973 - `name: str`
2974
2975 The name of the custom tool being called.
2976
2977 - `type: Literal["custom_tool_call"]`
2978
2979 The type of the custom tool call. Always `custom_tool_call`.
2980
2981 - `"custom_tool_call"`
2982
2983 - `id: Optional[str]`
2984
2985 The unique ID of the custom tool call in the OpenAI platform.
2986
2987 - `namespace: Optional[str]`
2988
2989 The namespace of the custom tool being called.
2990
2991 - `class CompactionTrigger: …`
2992
2993 Compacts the current context. Must be the final input item.
2994
2995 - `type: Literal["compaction_trigger"]`
2996
2997 The type of the item. Always `compaction_trigger`.
2998
2999 - `"compaction_trigger"`
3000
3001 - `class ItemReference: …`
3002
3003 An internal identifier for an item to reference.
3004
3005 - `id: str`
3006
3007 The ID of the item to reference.
3008
3009 - `type: Optional[Literal["item_reference"]]`
3010
3011 The type of item to reference. Always `item_reference`.
3012
3013 - `"item_reference"`
3014
3015- `instructions: Optional[str]`
3016
3017 A system (or developer) message inserted into the model's context.
3018 When used along with `previous_response_id`, the instructions from a previous response will not be carried over to the next response. This makes it simple to swap out system (or developer) messages in new responses.
3019
3020- `model: Optional[str]`
3021
3022 Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the [model guide](https://platform.openai.com/docs/models) to browse and compare available models.
3023
3024- `parallel_tool_calls: Optional[bool]`
3025
3026 Whether to allow the model to run tool calls in parallel.
3027
3028- `previous_response_id: Optional[str]`
3029
3030 The unique ID of the previous response to the model. Use this to create multi-turn conversations. Learn more about [conversation state](https://platform.openai.com/docs/guides/conversation-state). Cannot be used in conjunction with `conversation`.
3031
3032- `reasoning: Optional[Reasoning]`
3033
3034 **gpt-5 and o-series models only** Configuration options for [reasoning models](https://platform.openai.com/docs/guides/reasoning).
3035
3036 - `effort: Optional[ReasoningEffort]`
3037
3038 Constrains effort on reasoning for
3039 [reasoning models](https://platform.openai.com/docs/guides/reasoning).
3040 Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing
3041 reasoning effort can result in faster responses and fewer tokens used
3042 on reasoning in a response.
3043
3044 - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for all reasoning values in gpt-5.1.
3045 - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support `none`.
3046 - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
3047 - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
3048
3049 - `"none"`
3050
3051 - `"minimal"`
3052
3053 - `"low"`
3054
3055 - `"medium"`
3056
3057 - `"high"`
3058
3059 - `"xhigh"`
3060
3061 - `generate_summary: Optional[Literal["auto", "concise", "detailed"]]`
3062
3063 **Deprecated:** use `summary` instead.
3064
3065 A summary of the reasoning performed by the model. This can be
3066 useful for debugging and understanding the model's reasoning process.
3067 One of `auto`, `concise`, or `detailed`.
3068
3069 - `"auto"`
3070
3071 - `"concise"`
3072
3073 - `"detailed"`
3074
3075 - `summary: Optional[Literal["auto", "concise", "detailed"]]`
3076
3077 A summary of the reasoning performed by the model. This can be
3078 useful for debugging and understanding the model's reasoning process.
3079 One of `auto`, `concise`, or `detailed`.
3080
3081 `concise` is supported for `computer-use-preview` models and all reasoning models after `gpt-5`.
3082
3083 - `"auto"`
3084
3085 - `"concise"`
3086
3087 - `"detailed"`
3088
3089- `text: Optional[Text]`
3090
3091 Configuration options for a text response from the model. Can be plain
3092 text or structured JSON data. Learn more:
3093
3094 - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
3095 - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
3096
3097 - `format: Optional[ResponseFormatTextConfigParam]`
3098
3099 An object specifying the format that the model must output.
3100
3101 Configuring `{ "type": "json_schema" }` enables Structured Outputs,
3102 which ensures the model will match your supplied JSON schema. Learn more in the
3103 [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
3104
3105 The default format is `{ "type": "text" }` with no additional options.
3106
3107 **Not recommended for gpt-4o and newer models:**
3108
3109 Setting to `{ "type": "json_object" }` enables the older JSON mode, which
3110 ensures the message the model generates is valid JSON. Using `json_schema`
3111 is preferred for models that support it.
3112
3113 - `class ResponseFormatText: …`
3114
3115 Default response format. Used to generate text responses.
3116
3117 - `type: Literal["text"]`
3118
3119 The type of response format being defined. Always `text`.
3120
3121 - `"text"`
3122
3123 - `class ResponseFormatTextJSONSchemaConfig: …`
3124
3125 JSON Schema response format. Used to generate structured JSON responses.
3126 Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
3127
3128 - `name: str`
3129
3130 The name of the response format. Must be a-z, A-Z, 0-9, or contain
3131 underscores and dashes, with a maximum length of 64.
3132
3133 - `schema: Dict[str, object]`
3134
3135 The schema for the response format, described as a JSON Schema object.
3136 Learn how to build JSON schemas [here](https://json-schema.org/).
3137
3138 - `type: Literal["json_schema"]`
3139
3140 The type of response format being defined. Always `json_schema`.
3141
3142 - `"json_schema"`
3143
3144 - `description: Optional[str]`
3145
3146 A description of what the response format is for, used by the model to
3147 determine how to respond in the format.
3148
3149 - `strict: Optional[bool]`
3150
3151 Whether to enable strict schema adherence when generating the output.
3152 If set to true, the model will always follow the exact schema defined
3153 in the `schema` field. Only a subset of JSON Schema is supported when
3154 `strict` is `true`. To learn more, read the [Structured Outputs
3155 guide](https://platform.openai.com/docs/guides/structured-outputs).
3156
3157 - `class ResponseFormatJSONObject: …`
3158
3159 JSON object response format. An older method of generating JSON responses.
3160 Using `json_schema` is recommended for models that support it. Note that the
3161 model will not generate JSON without a system or user message instructing it
3162 to do so.
3163
3164 - `type: Literal["json_object"]`
3165
3166 The type of response format being defined. Always `json_object`.
3167
3168 - `"json_object"`
3169
3170 - `verbosity: Optional[Literal["low", "medium", "high"]]`
3171
3172 Constrains the verbosity of the model's response. Lower values will result in
3173 more concise responses, while higher values will result in more verbose responses.
3174 Currently supported values are `low`, `medium`, and `high`.
3175
3176 - `"low"`
3177
3178 - `"medium"`
3179
3180 - `"high"`
3181
3182- `tool_choice: Optional[ToolChoice]`
3183
3184 Controls which tool the model should use, if any.
3185
3186 - `Literal["none", "auto", "required"]`
3187
3188 - `"none"`
3189
3190 - `"auto"`
3191
3192 - `"required"`
3193
3194 - `class ToolChoiceAllowed: …`
3195
3196 Constrains the tools available to the model to a pre-defined set.
3197
3198 - `mode: Literal["auto", "required"]`
3199
3200 Constrains the tools available to the model to a pre-defined set.
3201
3202 `auto` allows the model to pick from among the allowed tools and generate a
3203 message.
3204
3205 `required` requires the model to call one or more of the allowed tools.
3206
3207 - `"auto"`
3208
3209 - `"required"`
3210
3211 - `tools: List[Dict[str, object]]`
3212
3213 A list of tool definitions that the model should be allowed to call.
3214
3215 For the Responses API, the list of tool definitions might look like:
3216
3217 ```json
3218 [
3219 { "type": "function", "name": "get_weather" },
3220 { "type": "mcp", "server_label": "deepwiki" },
3221 { "type": "image_generation" }
3222 ]
3223 ```
3224
3225 - `type: Literal["allowed_tools"]`
3226
3227 Allowed tool configuration type. Always `allowed_tools`.
3228
3229 - `"allowed_tools"`
3230
3231 - `class ToolChoiceTypes: …`
3232
3233 Indicates that the model should use a built-in tool to generate a response.
3234 [Learn more about built-in tools](https://platform.openai.com/docs/guides/tools).
3235
3236 - `type: Literal["file_search", "web_search_preview", "computer", 5 more]`
3237
3238 The type of hosted tool the model should to use. Learn more about
3239 [built-in tools](https://platform.openai.com/docs/guides/tools).
3240
3241 Allowed values are:
3242
3243 - `file_search`
3244 - `web_search_preview`
3245 - `computer`
3246 - `computer_use_preview`
3247 - `computer_use`
3248 - `code_interpreter`
3249 - `image_generation`
3250
3251 - `"file_search"`
3252
3253 - `"web_search_preview"`
3254
3255 - `"computer"`
3256
3257 - `"computer_use_preview"`
3258
3259 - `"computer_use"`
3260
3261 - `"web_search_preview_2025_03_11"`
3262
3263 - `"image_generation"`
3264
3265 - `"code_interpreter"`
3266
3267 - `class ToolChoiceFunction: …`
3268
3269 Use this option to force the model to call a specific function.
3270
3271 - `name: str`
3272
3273 The name of the function to call.
3274
3275 - `type: Literal["function"]`
3276
3277 For function calling, the type is always `function`.
3278
3279 - `"function"`
3280
3281 - `class ToolChoiceMcp: …`
3282
3283 Use this option to force the model to call a specific tool on a remote MCP server.
3284
3285 - `server_label: str`
3286
3287 The label of the MCP server to use.
3288
3289 - `type: Literal["mcp"]`
3290
3291 For MCP tools, the type is always `mcp`.
3292
3293 - `"mcp"`
3294
3295 - `name: Optional[str]`
3296
3297 The name of the tool to call on the server.
3298
3299 - `class ToolChoiceCustom: …`
3300
3301 Use this option to force the model to call a specific custom tool.
3302
3303 - `name: str`
3304
3305 The name of the custom tool to call.
3306
3307 - `type: Literal["custom"]`
3308
3309 For custom tool calling, the type is always `custom`.
3310
3311 - `"custom"`
3312
3313 - `class ToolChoiceApplyPatch: …`
3314
3315 Forces the model to call the apply_patch tool when executing a tool call.
3316
3317 - `type: Literal["apply_patch"]`
3318
3319 The tool to call. Always `apply_patch`.
3320
3321 - `"apply_patch"`
3322
3323 - `class ToolChoiceShell: …`
3324
3325 Forces the model to call the shell tool when a tool call is required.
3326
3327 - `type: Literal["shell"]`
3328
3329 The tool to call. Always `shell`.
3330
3331 - `"shell"`
3332
3333- `tools: Optional[Iterable[ToolParam]]`
3334
3335 An array of tools the model may call while generating a response. You can specify which tool to use by setting the `tool_choice` parameter.
3336
3337 - `class FunctionTool: …`
3338
3339 Defines a function in your own code the model can choose to call. Learn more about [function calling](https://platform.openai.com/docs/guides/function-calling).
3340
3341 - `class FileSearchTool: …`
3342
3343 A tool that searches for relevant content from uploaded files. Learn more about the [file search tool](https://platform.openai.com/docs/guides/tools-file-search).
3344
3345 - `class ComputerTool: …`
3346
3347 A tool that controls a virtual computer. Learn more about the [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
3348
3349 - `class ComputerUsePreviewTool: …`
3350
3351 A tool that controls a virtual computer. Learn more about the [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
3352
3353 - `class WebSearchTool: …`
3354
3355 Search the Internet for sources related to the prompt. Learn more about the
3356 [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
3357
3358 - `class Mcp: …`
3359
3360 Give the model access to additional tools via remote Model Context Protocol
3361 (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).
3362
3363 - `class CodeInterpreter: …`
3364
3365 A tool that runs Python code to help generate a response to a prompt.
3366
3367 - `class ImageGeneration: …`
3368
3369 A tool that generates images using the GPT image models.
3370
3371 - `class LocalShell: …`
3372
3373 A tool that allows the model to execute shell commands in a local environment.
3374
3375 - `class FunctionShellTool: …`
3376
3377 A tool that allows the model to execute shell commands.
3378
3379 - `class CustomTool: …`
3380
3381 A custom tool that processes input using a specified format. Learn more about [custom tools](https://platform.openai.com/docs/guides/function-calling#custom-tools)
3382
3383 - `class NamespaceTool: …`
3384
3385 Groups function/custom tools under a shared namespace.
3386
3387 - `class ToolSearchTool: …`
3388
3389 Hosted or BYOT tool search configuration for deferred tools.
3390
3391 - `class WebSearchPreviewTool: …`
3392
3393 This tool searches the web for relevant results to use in a response. Learn more about the [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
3394
3395 - `class ApplyPatchTool: …`
3396
3397 Allows the assistant to create, delete, or update files using unified diffs.
3398
3399- `truncation: Optional[Literal["auto", "disabled"]]`
3400
3401 The truncation strategy to use for the model response. - `auto`: If the input to this Response exceeds the model's context window size, the model will truncate the response to fit the context window by dropping items from the beginning of the conversation. - `disabled` (default): If the input size will exceed the context window size for a model, the request will fail with a 400 error.
3402
3403 - `"auto"`
3404
3405 - `"disabled"`
3406
3407### Returns
3408
3409- `class InputTokenCountResponse: …`
3410
3411 - `input_tokens: int`
3412
3413 - `object: Literal["response.input_tokens"]`
3414
3415 - `"response.input_tokens"`
3416
3417### Example
3418
3419```python
3420import os
3421from openai import OpenAI
3422
3423client = OpenAI(
3424 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
3425)
3426response = client.responses.input_tokens.count()
3427print(response.input_tokens)
3428```
3429
3430#### Response
3431
3432```json
3433{
3434 "input_tokens": 123,
3435 "object": "response.input_tokens"
3436}
3437```
3438
3439### Example
3440
3441```python
3442from openai import OpenAI
3443
3444client = OpenAI()
3445
3446response = client.responses.input_tokens.count(
3447 model="gpt-5",
3448 input="Tell me a joke."
3449)
3450print(response.input_tokens)
3451```
3452
3453#### Response
3454
3455```json
3456{
3457 "object": "response.input_tokens",
3458 "input_tokens": 11
3459}
3460```
3461
3462## Domain Types
3463
3464### Input Token Count Response
3465
3466- `class InputTokenCountResponse: …`
3467
3468 - `input_tokens: int`
3469
3470 - `object: Literal["response.input_tokens"]`
3471
3472 - `"response.input_tokens"`