@@ -7,6 +7,7 @@ import { APIPromise } from '../core/api-promise';
77import { Stream } from '../core/streaming' ;
88import { RequestOptions } from '../internal/request-options' ;
99import { addOutputText } from '../lib/add-output-text' ;
10+ import { path } from '../internal/utils/path' ;
1011
1112export class Responses extends APIResource {
1213 /**
@@ -43,6 +44,13 @@ export class Responses extends APIResource {
4344
4445 return promise as APIPromise < Stream < ResponseStreamChunk > > ;
4546 }
47+
48+ /**
49+ * Retrieve a response by its ID. Use this to poll the status of background tasks.
50+ */
51+ retrieve ( responseID : string , options ?: RequestOptions ) : APIPromise < ResponseRetrieveResponse > {
52+ return this . _client . get ( path `/v1/responses/${ responseID } ` , options ) ;
53+ }
4654}
4755
4856/**
@@ -97,7 +105,7 @@ export interface FunctionCallOutputItem {
97105 /**
98106 * Status of a response or output item
99107 */
100- status : 'completed' | 'failed' | 'in_progress' | 'requires_action' ;
108+ status : 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | ' requires_action';
101109
102110 type : 'function_call' ;
103111
@@ -227,7 +235,7 @@ export namespace OutputItem {
227235 /**
228236 * Status of a response or output item
229237 */
230- status : 'completed' | 'failed' | 'in_progress' | 'requires_action' ;
238+ status : 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | ' requires_action';
231239
232240 type : 'message' ;
233241 }
@@ -346,7 +354,12 @@ export namespace ResponseStreamChunk {
346354 /**
347355 * Status of a response or output item
348356 */
349- status : 'completed' | 'failed' | 'in_progress' | 'requires_action' ;
357+ status : 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action' ;
358+
359+ /**
360+ * Whether the response was created in background mode.
361+ */
362+ background ?: boolean ;
350363
351364 error ?: ResponsesAPI . ErrorInfo ;
352365
@@ -396,7 +409,12 @@ export namespace ResponseStreamChunk {
396409 /**
397410 * Status of a response or output item
398411 */
399- status : 'completed' | 'failed' | 'in_progress' | 'requires_action' ;
412+ status : 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action' ;
413+
414+ /**
415+ * Whether the response was created in background mode.
416+ */
417+ background ?: boolean ;
400418
401419 error ?: ResponsesAPI . ErrorInfo ;
402420
@@ -445,7 +463,12 @@ export namespace ResponseStreamChunk {
445463 /**
446464 * Status of a response or output item
447465 */
448- status : 'completed' | 'failed' | 'in_progress' | 'requires_action' ;
466+ status : 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action' ;
467+
468+ /**
469+ * Whether the response was created in background mode.
470+ */
471+ background ?: boolean ;
449472
450473 error ?: ResponsesAPI . ErrorInfo ;
451474
@@ -706,6 +729,13 @@ export interface ResponsesCreateParams {
706729 */
707730 input : string | Array < InputItem > ;
708731
732+ /**
733+ * Run the response asynchronously. When true, the request is queued and the
734+ * response object's `status` will be `queued` or `in_progress`. Poll GET
735+ * /v1/responses/{response_id} to retrieve the final result.
736+ */
737+ background ?: boolean | null ;
738+
709739 /**
710740 * System instructions for the model
711741 */
@@ -778,7 +808,7 @@ export namespace ResponsesCreateParams {
778808 /**
779809 * How much effort the model should spend on reasoning
780810 */
781- effort ?: 'low' | 'medium' | 'high' ;
811+ effort ?: 'minimal' | ' low' | 'medium' | 'high' | 'xhigh ';
782812 }
783813
784814 export interface WebSearchTool {
@@ -936,7 +966,44 @@ export interface ResponseCreateResponse {
936966 /**
937967 * Status of a response or output item
938968 */
939- status : 'completed' | 'failed' | 'in_progress' | 'requires_action' ;
969+ status : 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action' ;
970+
971+ /**
972+ * Whether the response was created in background mode.
973+ */
974+ background ?: boolean ;
975+
976+ error ?: ErrorInfo ;
977+
978+ usage ?: ResponsesUsage ;
979+ }
980+
981+ /**
982+ * Non-streaming response returned when stream is false
983+ */
984+ export interface ResponseRetrieveResponse {
985+ id : string ;
986+
987+ created_at : number ;
988+
989+ model : string ;
990+
991+ /**
992+ * Object type in API responses
993+ */
994+ object : 'response' ;
995+
996+ output : Array < OutputItem > ;
997+
998+ /**
999+ * Status of a response or output item
1000+ */
1001+ status : 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action' ;
1002+
1003+ /**
1004+ * Whether the response was created in background mode.
1005+ */
1006+ background ?: boolean ;
9401007
9411008 error ?: ErrorInfo ;
9421009
@@ -957,6 +1024,13 @@ export interface ResponseCreateParamsBase {
9571024 */
9581025 input : string | Array < InputItem > ;
9591026
1027+ /**
1028+ * Run the response asynchronously. When true, the request is queued and the
1029+ * response object's `status` will be `queued` or `in_progress`. Poll GET
1030+ * /v1/responses/{response_id} to retrieve the final result.
1031+ */
1032+ background ?: boolean | null ;
1033+
9601034 /**
9611035 * System instructions for the model
9621036 */
@@ -1029,7 +1103,7 @@ export namespace ResponseCreateParams {
10291103 /**
10301104 * How much effort the model should spend on reasoning
10311105 */
1032- effort ?: 'low' | 'medium' | 'high' ;
1106+ effort ?: 'minimal' | ' low' | 'medium' | 'high' | 'xhigh ';
10331107 }
10341108
10351109 export interface WebSearchTool {
@@ -1149,6 +1223,7 @@ export declare namespace Responses {
11491223 type ResponsesCreateParams as ResponsesCreateParams ,
11501224 type ResponsesUsage as ResponsesUsage ,
11511225 type ResponseCreateResponse as ResponseCreateResponse ,
1226+ type ResponseRetrieveResponse as ResponseRetrieveResponse ,
11521227 type ResponseCreateParams as ResponseCreateParams ,
11531228 type ResponseCreateParamsNonStreaming as ResponseCreateParamsNonStreaming ,
11541229 type ResponseCreateParamsStreaming as ResponseCreateParamsStreaming ,
0 commit comments