@@ -46,6 +46,20 @@ export class Batches extends APIResource {
4646 list ( options ?: RequestOptions ) : APIPromise < BatchListResponse > {
4747 return this . _client . get ( '/batches' , options ) ;
4848 }
49+
50+ /**
51+ * Cancel a batch job by ID
52+ *
53+ * @example
54+ * ```ts
55+ * const response = await client.batches.cancel(
56+ * 'batch_job_abc123def456',
57+ * );
58+ * ```
59+ */
60+ cancel ( id : string , options ?: RequestOptions ) : APIPromise < BatchCancelResponse > {
61+ return this . _client . post ( path `/batches/${ id } /cancel` , options ) ;
62+ }
4963}
5064
5165export interface BatchCreateResponse {
@@ -186,6 +200,48 @@ export namespace BatchListResponse {
186200 }
187201}
188202
203+ export interface BatchCancelResponse {
204+ id ?: string ;
205+
206+ completed_at ?: string ;
207+
208+ created_at ?: string ;
209+
210+ endpoint ?: string ;
211+
212+ error ?: string ;
213+
214+ error_file_id ?: string ;
215+
216+ /**
217+ * Size of input file in bytes
218+ */
219+ file_size_bytes ?: number ;
220+
221+ input_file_id ?: string ;
222+
223+ job_deadline ?: string ;
224+
225+ /**
226+ * Model used for processing requests
227+ */
228+ model_id ?: string ;
229+
230+ output_file_id ?: string ;
231+
232+ /**
233+ * Completion progress (0.0 to 100)
234+ */
235+ progress ?: number ;
236+
237+ /**
238+ * Current status of the batch job
239+ */
240+ status ?: 'VALIDATING' | 'IN_PROGRESS' | 'COMPLETED' | 'FAILED' | 'EXPIRED' | 'CANCELLED' ;
241+
242+ user_id ?: string ;
243+ }
244+
189245export interface BatchCreateParams {
190246 /**
191247 * The endpoint to use for batch processing
@@ -218,6 +274,7 @@ export declare namespace Batches {
218274 type BatchCreateResponse as BatchCreateResponse ,
219275 type BatchRetrieveResponse as BatchRetrieveResponse ,
220276 type BatchListResponse as BatchListResponse ,
277+ type BatchCancelResponse as BatchCancelResponse ,
221278 type BatchCreateParams as BatchCreateParams ,
222279 } ;
223280}
0 commit comments