-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbatches.ts
More file actions
155 lines (127 loc) · 3.45 KB
/
Copy pathbatches.ts
File metadata and controls
155 lines (127 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import { APIPromise } from '../core/api-promise';
import { RequestOptions } from '../internal/request-options';
import { path } from '../internal/utils/path';
export class Batches extends APIResource {
/**
* Create a new batch job with the given input file and endpoint
*
* @example
* ```ts
* const batch = await client.batches.create({
* endpoint: '/v1/chat/completions',
* input_file_id: 'file-abc123def456ghi789',
* });
* ```
*/
create(body: BatchCreateParams, options?: RequestOptions): APIPromise<BatchCreateResponse> {
return this._client.post('/batches', { body, ...options });
}
/**
* Get details of a batch job by ID
*
* @example
* ```ts
* const batchJob = await client.batches.retrieve(
* 'batch_job_abc123def456',
* );
* ```
*/
retrieve(id: string, options?: RequestOptions): APIPromise<BatchJob> {
return this._client.get(path`/batches/${id}`, options);
}
/**
* List all batch jobs for the authenticated user
*
* @example
* ```ts
* const batchJobs = await client.batches.list();
* ```
*/
list(options?: RequestOptions): APIPromise<BatchListResponse> {
return this._client.get('/batches', options);
}
/**
* Cancel a batch job by ID
*
* @example
* ```ts
* const batchJob = await client.batches.cancel(
* 'batch_job_abc123def456',
* );
* ```
*/
cancel(id: string, options?: RequestOptions): APIPromise<BatchJob> {
return this._client.post(path`/batches/${id}/cancel`, options);
}
}
export interface BatchJob {
id?: string;
completed_at?: string;
created_at?: string;
endpoint?: string;
error?: string;
error_file_id?: string;
/**
* Size of input file in bytes
*/
file_size_bytes?: number;
input_file_id?: string;
job_deadline?: string;
/**
* Model used for processing requests
*/
model_id?: string;
output_file_id?: string;
/**
* Completion progress (0.0 to 100)
*/
progress?: number;
/**
* Current status of the batch job
*/
status?: 'VALIDATING' | 'IN_PROGRESS' | 'COMPLETED' | 'FAILED' | 'EXPIRED' | 'CANCELLED';
user_id?: string;
}
export interface BatchCreateResponse {
job?: BatchJob;
warning?: string;
}
export type BatchListResponse = Array<BatchJob>;
export interface BatchCreateParams {
/**
* The endpoint to use for batch processing. Each line of the uploaded input file
* is dispatched against this endpoint.
*
* - `/v1/chat/completions` — chat completion batches
* - `/v1/audio/transcriptions` — audio transcription batches (e.g.
* `openai/whisper-large-v3`)
* - `/v1/audio/translations` — audio translation batches
*/
endpoint: '/v1/chat/completions' | '/v1/audio/transcriptions' | '/v1/audio/translations';
/**
* ID of the uploaded input file containing batch requests
*/
input_file_id: string;
/**
* Time window for batch completion (optional)
*/
completion_window?: string;
/**
* Model to use for processing batch requests
*/
model_id?: string;
/**
* Priority for batch processing (optional)
*/
priority?: number;
}
export declare namespace Batches {
export {
type BatchJob as BatchJob,
type BatchCreateResponse as BatchCreateResponse,
type BatchListResponse as BatchListResponse,
type BatchCreateParams as BatchCreateParams,
};
}