items.d.mts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. import { APIResource } from "../../core/resource.mjs";
  2. import * as ConversationsAPI from "./conversations.mjs";
  3. import * as ResponsesAPI from "../responses/responses.mjs";
  4. import { APIPromise } from "../../core/api-promise.mjs";
  5. import { ConversationCursorPage, type ConversationCursorPageParams, PagePromise } from "../../core/pagination.mjs";
  6. import { RequestOptions } from "../../internal/request-options.mjs";
  7. export declare class Items extends APIResource {
  8. /**
  9. * Create items in a conversation with the given ID.
  10. */
  11. create(conversationID: string, params: ItemCreateParams, options?: RequestOptions): APIPromise<ConversationItemList>;
  12. /**
  13. * Get a single item from a conversation with the given IDs.
  14. */
  15. retrieve(itemID: string, params: ItemRetrieveParams, options?: RequestOptions): APIPromise<ConversationItem>;
  16. /**
  17. * List all items for a conversation with the given ID.
  18. */
  19. list(conversationID: string, query?: ItemListParams | null | undefined, options?: RequestOptions): PagePromise<ConversationItemsPage, ConversationItem>;
  20. /**
  21. * Delete an item from a conversation with the given IDs.
  22. */
  23. delete(itemID: string, params: ItemDeleteParams, options?: RequestOptions): APIPromise<ConversationsAPI.Conversation>;
  24. }
  25. export type ConversationItemsPage = ConversationCursorPage<ConversationItem>;
  26. /**
  27. * A single item within a conversation. The set of possible types are the same as
  28. * the `output` type of a
  29. * [Response object](https://platform.openai.com/docs/api-reference/responses/object#responses/object-output).
  30. */
  31. export type ConversationItem = ConversationsAPI.Message | ResponsesAPI.ResponseFunctionToolCallItem | ResponsesAPI.ResponseFunctionToolCallOutputItem | ResponsesAPI.ResponseFileSearchToolCall | ResponsesAPI.ResponseFunctionWebSearch | ConversationItem.ImageGenerationCall | ResponsesAPI.ResponseComputerToolCall | ResponsesAPI.ResponseComputerToolCallOutputItem | ResponsesAPI.ResponseReasoningItem | ResponsesAPI.ResponseCodeInterpreterToolCall | ConversationItem.LocalShellCall | ConversationItem.LocalShellCallOutput | ResponsesAPI.ResponseFunctionShellToolCall | ResponsesAPI.ResponseFunctionShellToolCallOutput | ResponsesAPI.ResponseApplyPatchToolCall | ResponsesAPI.ResponseApplyPatchToolCallOutput | ConversationItem.McpListTools | ConversationItem.McpApprovalRequest | ConversationItem.McpApprovalResponse | ConversationItem.McpCall | ResponsesAPI.ResponseCustomToolCall | ResponsesAPI.ResponseCustomToolCallOutput;
  32. export declare namespace ConversationItem {
  33. /**
  34. * An image generation request made by the model.
  35. */
  36. interface ImageGenerationCall {
  37. /**
  38. * The unique ID of the image generation call.
  39. */
  40. id: string;
  41. /**
  42. * The generated image encoded in base64.
  43. */
  44. result: string | null;
  45. /**
  46. * The status of the image generation call.
  47. */
  48. status: 'in_progress' | 'completed' | 'generating' | 'failed';
  49. /**
  50. * The type of the image generation call. Always `image_generation_call`.
  51. */
  52. type: 'image_generation_call';
  53. }
  54. /**
  55. * A tool call to run a command on the local shell.
  56. */
  57. interface LocalShellCall {
  58. /**
  59. * The unique ID of the local shell call.
  60. */
  61. id: string;
  62. /**
  63. * Execute a shell command on the server.
  64. */
  65. action: LocalShellCall.Action;
  66. /**
  67. * The unique ID of the local shell tool call generated by the model.
  68. */
  69. call_id: string;
  70. /**
  71. * The status of the local shell call.
  72. */
  73. status: 'in_progress' | 'completed' | 'incomplete';
  74. /**
  75. * The type of the local shell call. Always `local_shell_call`.
  76. */
  77. type: 'local_shell_call';
  78. }
  79. namespace LocalShellCall {
  80. /**
  81. * Execute a shell command on the server.
  82. */
  83. interface Action {
  84. /**
  85. * The command to run.
  86. */
  87. command: Array<string>;
  88. /**
  89. * Environment variables to set for the command.
  90. */
  91. env: {
  92. [key: string]: string;
  93. };
  94. /**
  95. * The type of the local shell action. Always `exec`.
  96. */
  97. type: 'exec';
  98. /**
  99. * Optional timeout in milliseconds for the command.
  100. */
  101. timeout_ms?: number | null;
  102. /**
  103. * Optional user to run the command as.
  104. */
  105. user?: string | null;
  106. /**
  107. * Optional working directory to run the command in.
  108. */
  109. working_directory?: string | null;
  110. }
  111. }
  112. /**
  113. * The output of a local shell tool call.
  114. */
  115. interface LocalShellCallOutput {
  116. /**
  117. * The unique ID of the local shell tool call generated by the model.
  118. */
  119. id: string;
  120. /**
  121. * A JSON string of the output of the local shell tool call.
  122. */
  123. output: string;
  124. /**
  125. * The type of the local shell tool call output. Always `local_shell_call_output`.
  126. */
  127. type: 'local_shell_call_output';
  128. /**
  129. * The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  130. */
  131. status?: 'in_progress' | 'completed' | 'incomplete' | null;
  132. }
  133. /**
  134. * A list of tools available on an MCP server.
  135. */
  136. interface McpListTools {
  137. /**
  138. * The unique ID of the list.
  139. */
  140. id: string;
  141. /**
  142. * The label of the MCP server.
  143. */
  144. server_label: string;
  145. /**
  146. * The tools available on the server.
  147. */
  148. tools: Array<McpListTools.Tool>;
  149. /**
  150. * The type of the item. Always `mcp_list_tools`.
  151. */
  152. type: 'mcp_list_tools';
  153. /**
  154. * Error message if the server could not list tools.
  155. */
  156. error?: string | null;
  157. }
  158. namespace McpListTools {
  159. /**
  160. * A tool available on an MCP server.
  161. */
  162. interface Tool {
  163. /**
  164. * The JSON schema describing the tool's input.
  165. */
  166. input_schema: unknown;
  167. /**
  168. * The name of the tool.
  169. */
  170. name: string;
  171. /**
  172. * Additional annotations about the tool.
  173. */
  174. annotations?: unknown | null;
  175. /**
  176. * The description of the tool.
  177. */
  178. description?: string | null;
  179. }
  180. }
  181. /**
  182. * A request for human approval of a tool invocation.
  183. */
  184. interface McpApprovalRequest {
  185. /**
  186. * The unique ID of the approval request.
  187. */
  188. id: string;
  189. /**
  190. * A JSON string of arguments for the tool.
  191. */
  192. arguments: string;
  193. /**
  194. * The name of the tool to run.
  195. */
  196. name: string;
  197. /**
  198. * The label of the MCP server making the request.
  199. */
  200. server_label: string;
  201. /**
  202. * The type of the item. Always `mcp_approval_request`.
  203. */
  204. type: 'mcp_approval_request';
  205. }
  206. /**
  207. * A response to an MCP approval request.
  208. */
  209. interface McpApprovalResponse {
  210. /**
  211. * The unique ID of the approval response
  212. */
  213. id: string;
  214. /**
  215. * The ID of the approval request being answered.
  216. */
  217. approval_request_id: string;
  218. /**
  219. * Whether the request was approved.
  220. */
  221. approve: boolean;
  222. /**
  223. * The type of the item. Always `mcp_approval_response`.
  224. */
  225. type: 'mcp_approval_response';
  226. /**
  227. * Optional reason for the decision.
  228. */
  229. reason?: string | null;
  230. }
  231. /**
  232. * An invocation of a tool on an MCP server.
  233. */
  234. interface McpCall {
  235. /**
  236. * The unique ID of the tool call.
  237. */
  238. id: string;
  239. /**
  240. * A JSON string of the arguments passed to the tool.
  241. */
  242. arguments: string;
  243. /**
  244. * The name of the tool that was run.
  245. */
  246. name: string;
  247. /**
  248. * The label of the MCP server running the tool.
  249. */
  250. server_label: string;
  251. /**
  252. * The type of the item. Always `mcp_call`.
  253. */
  254. type: 'mcp_call';
  255. /**
  256. * Unique identifier for the MCP tool call approval request. Include this value in
  257. * a subsequent `mcp_approval_response` input to approve or reject the
  258. * corresponding tool call.
  259. */
  260. approval_request_id?: string | null;
  261. /**
  262. * The error from the tool call, if any.
  263. */
  264. error?: string | null;
  265. /**
  266. * The output from the tool call.
  267. */
  268. output?: string | null;
  269. /**
  270. * The status of the tool call. One of `in_progress`, `completed`, `incomplete`,
  271. * `calling`, or `failed`.
  272. */
  273. status?: 'in_progress' | 'completed' | 'incomplete' | 'calling' | 'failed';
  274. }
  275. }
  276. /**
  277. * A list of Conversation items.
  278. */
  279. export interface ConversationItemList {
  280. /**
  281. * A list of conversation items.
  282. */
  283. data: Array<ConversationItem>;
  284. /**
  285. * The ID of the first item in the list.
  286. */
  287. first_id: string;
  288. /**
  289. * Whether there are more items available.
  290. */
  291. has_more: boolean;
  292. /**
  293. * The ID of the last item in the list.
  294. */
  295. last_id: string;
  296. /**
  297. * The type of object returned, must be `list`.
  298. */
  299. object: 'list';
  300. }
  301. export interface ItemCreateParams {
  302. /**
  303. * Body param: The items to add to the conversation. You may add up to 20 items at
  304. * a time.
  305. */
  306. items: Array<ResponsesAPI.ResponseInputItem>;
  307. /**
  308. * Query param: Additional fields to include in the response. See the `include`
  309. * parameter for
  310. * [listing Conversation items above](https://platform.openai.com/docs/api-reference/conversations/list-items#conversations_list_items-include)
  311. * for more information.
  312. */
  313. include?: Array<ResponsesAPI.ResponseIncludable>;
  314. }
  315. export interface ItemRetrieveParams {
  316. /**
  317. * Path param: The ID of the conversation that contains the item.
  318. */
  319. conversation_id: string;
  320. /**
  321. * Query param: Additional fields to include in the response. See the `include`
  322. * parameter for
  323. * [listing Conversation items above](https://platform.openai.com/docs/api-reference/conversations/list-items#conversations_list_items-include)
  324. * for more information.
  325. */
  326. include?: Array<ResponsesAPI.ResponseIncludable>;
  327. }
  328. export interface ItemListParams extends ConversationCursorPageParams {
  329. /**
  330. * Specify additional output data to include in the model response. Currently
  331. * supported values are:
  332. *
  333. * - `web_search_call.action.sources`: Include the sources of the web search tool
  334. * call.
  335. * - `code_interpreter_call.outputs`: Includes the outputs of python code execution
  336. * in code interpreter tool call items.
  337. * - `computer_call_output.output.image_url`: Include image urls from the computer
  338. * call output.
  339. * - `file_search_call.results`: Include the search results of the file search tool
  340. * call.
  341. * - `message.input_image.image_url`: Include image urls from the input message.
  342. * - `message.output_text.logprobs`: Include logprobs with assistant messages.
  343. * - `reasoning.encrypted_content`: Includes an encrypted version of reasoning
  344. * tokens in reasoning item outputs. This enables reasoning items to be used in
  345. * multi-turn conversations when using the Responses API statelessly (like when
  346. * the `store` parameter is set to `false`, or when an organization is enrolled
  347. * in the zero data retention program).
  348. */
  349. include?: Array<ResponsesAPI.ResponseIncludable>;
  350. /**
  351. * The order to return the input items in. Default is `desc`.
  352. *
  353. * - `asc`: Return the input items in ascending order.
  354. * - `desc`: Return the input items in descending order.
  355. */
  356. order?: 'asc' | 'desc';
  357. }
  358. export interface ItemDeleteParams {
  359. /**
  360. * The ID of the conversation that contains the item.
  361. */
  362. conversation_id: string;
  363. }
  364. export declare namespace Items {
  365. export { type ConversationItem as ConversationItem, type ConversationItemList as ConversationItemList, type ConversationItemsPage as ConversationItemsPage, type ItemCreateParams as ItemCreateParams, type ItemRetrieveParams as ItemRetrieveParams, type ItemListParams as ItemListParams, type ItemDeleteParams as ItemDeleteParams, };
  366. }
  367. //# sourceMappingURL=items.d.mts.map