@runinfra/sdk 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -54
- package/README.md +94 -72
- package/dist/index.d.ts +90 -27
- package/dist/index.js +342 -80
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const RUNINFRA_SDK_VERSION = "0.
|
|
1
|
+
export declare const RUNINFRA_SDK_VERSION = "0.2.0";
|
|
2
2
|
export interface RunInfraOptions {
|
|
3
3
|
apiKey: string;
|
|
4
4
|
pipelineId?: string;
|
|
@@ -16,6 +16,7 @@ export interface RunInfraRequestOptions {
|
|
|
16
16
|
maxRetries?: number;
|
|
17
17
|
retryBaseMs?: number;
|
|
18
18
|
headers?: Record<string, string>;
|
|
19
|
+
extraBody?: Record<string, unknown>;
|
|
19
20
|
}
|
|
20
21
|
export interface ChatMessage {
|
|
21
22
|
role: "system" | "user" | "assistant" | "tool" | string;
|
|
@@ -23,10 +24,28 @@ export interface ChatMessage {
|
|
|
23
24
|
name?: string;
|
|
24
25
|
tool_call_id?: string;
|
|
25
26
|
}
|
|
26
|
-
export interface ChatCompletionRequest
|
|
27
|
+
export interface ChatCompletionRequest {
|
|
27
28
|
model: string;
|
|
28
29
|
messages: ChatMessage[];
|
|
29
30
|
stream?: boolean;
|
|
31
|
+
temperature?: number;
|
|
32
|
+
top_p?: number;
|
|
33
|
+
max_tokens?: number;
|
|
34
|
+
max_completion_tokens?: number;
|
|
35
|
+
stop?: string | string[];
|
|
36
|
+
presence_penalty?: number;
|
|
37
|
+
frequency_penalty?: number;
|
|
38
|
+
user?: string;
|
|
39
|
+
metadata?: Record<string, unknown>;
|
|
40
|
+
stream_options?: {
|
|
41
|
+
include_usage?: boolean;
|
|
42
|
+
} & Record<string, unknown>;
|
|
43
|
+
tools?: Array<Record<string, unknown>>;
|
|
44
|
+
tool_choice?: string | Record<string, unknown>;
|
|
45
|
+
response_format?: Record<string, unknown>;
|
|
46
|
+
seed?: number;
|
|
47
|
+
logprobs?: boolean;
|
|
48
|
+
top_logprobs?: number;
|
|
30
49
|
}
|
|
31
50
|
export interface ChatCompletionStreamEvent extends Record<string, unknown> {
|
|
32
51
|
choices?: Array<{
|
|
@@ -37,6 +56,7 @@ export interface ChatCompletionStreamEvent extends Record<string, unknown> {
|
|
|
37
56
|
}
|
|
38
57
|
export interface RunInfraRequestMetadata extends Record<string, unknown> {
|
|
39
58
|
_request_id?: string;
|
|
59
|
+
_idempotent_replay?: boolean;
|
|
40
60
|
}
|
|
41
61
|
export interface ChatCompletionResponse extends RunInfraRequestMetadata {
|
|
42
62
|
id?: string;
|
|
@@ -59,12 +79,22 @@ export interface ChatCompletionsCreate {
|
|
|
59
79
|
}, options?: RunInfraRequestOptions): Promise<ChatCompletionResponse>;
|
|
60
80
|
(request: ChatCompletionRequest, options?: RunInfraRequestOptions): Promise<ChatCompletionResponse | RunInfraStream<ChatCompletionStreamEvent>>;
|
|
61
81
|
}
|
|
62
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Request shape for the current RunInfra Responses compatibility adapter.
|
|
84
|
+
* The gateway maps supported fields onto chat completions and rewraps the
|
|
85
|
+
* result; this is not a full stateful OpenAI Responses implementation.
|
|
86
|
+
*/
|
|
87
|
+
export interface ResponsesCreateRequest {
|
|
63
88
|
model: string;
|
|
64
89
|
input: string | Array<Record<string, unknown>>;
|
|
65
90
|
instructions?: string;
|
|
66
91
|
max_output_tokens?: number;
|
|
67
92
|
stream?: boolean;
|
|
93
|
+
temperature?: number;
|
|
94
|
+
top_p?: number;
|
|
95
|
+
tools?: Array<Record<string, unknown>>;
|
|
96
|
+
tool_choice?: string | Record<string, unknown>;
|
|
97
|
+
response_format?: Record<string, unknown>;
|
|
68
98
|
}
|
|
69
99
|
export interface ResponsesStreamEvent extends Record<string, unknown> {
|
|
70
100
|
type?: string;
|
|
@@ -73,6 +103,7 @@ export interface ResponsesStreamEvent extends Record<string, unknown> {
|
|
|
73
103
|
export interface ResponsesCreateResponse extends RunInfraRequestMetadata {
|
|
74
104
|
id?: string;
|
|
75
105
|
object?: string;
|
|
106
|
+
created_at?: number;
|
|
76
107
|
status?: string;
|
|
77
108
|
model?: string;
|
|
78
109
|
output_text?: string;
|
|
@@ -88,9 +119,12 @@ export interface ResponsesCreate {
|
|
|
88
119
|
}, options?: RunInfraRequestOptions): Promise<ResponsesCreateResponse>;
|
|
89
120
|
(request: ResponsesCreateRequest, options?: RunInfraRequestOptions): Promise<ResponsesCreateResponse | RunInfraStream<ResponsesStreamEvent>>;
|
|
90
121
|
}
|
|
91
|
-
export interface EmbeddingRequest
|
|
122
|
+
export interface EmbeddingRequest {
|
|
92
123
|
model: string;
|
|
93
124
|
input: string | string[];
|
|
125
|
+
encoding_format?: "float" | string;
|
|
126
|
+
dimensions?: number;
|
|
127
|
+
user?: string;
|
|
94
128
|
}
|
|
95
129
|
export interface EmbeddingObject extends Record<string, unknown> {
|
|
96
130
|
object?: string;
|
|
@@ -103,7 +137,7 @@ export interface EmbeddingResponse extends RunInfraRequestMetadata {
|
|
|
103
137
|
data: EmbeddingObject[];
|
|
104
138
|
usage?: Record<string, unknown>;
|
|
105
139
|
}
|
|
106
|
-
export interface SpeechRequest
|
|
140
|
+
export interface SpeechRequest {
|
|
107
141
|
model: string;
|
|
108
142
|
input: string;
|
|
109
143
|
voice?: string;
|
|
@@ -111,11 +145,16 @@ export interface SpeechRequest extends Record<string, unknown> {
|
|
|
111
145
|
ref_text?: string;
|
|
112
146
|
task_type?: string;
|
|
113
147
|
response_format?: string;
|
|
148
|
+
speed?: number;
|
|
114
149
|
}
|
|
115
|
-
export interface TranscriptionRequest
|
|
150
|
+
export interface TranscriptionRequest {
|
|
116
151
|
model: string;
|
|
117
152
|
file: Blob;
|
|
118
153
|
filename?: string;
|
|
154
|
+
language?: string;
|
|
155
|
+
prompt?: string;
|
|
156
|
+
response_format?: "json" | "verbose_json" | string;
|
|
157
|
+
temperature?: number;
|
|
119
158
|
}
|
|
120
159
|
export interface TranscriptionResponse extends RunInfraRequestMetadata {
|
|
121
160
|
text?: string;
|
|
@@ -123,9 +162,15 @@ export interface TranscriptionResponse extends RunInfraRequestMetadata {
|
|
|
123
162
|
duration?: number;
|
|
124
163
|
segments?: Array<Record<string, unknown>>;
|
|
125
164
|
}
|
|
126
|
-
export interface ImageGenerateRequest
|
|
165
|
+
export interface ImageGenerateRequest {
|
|
127
166
|
model: string;
|
|
128
167
|
prompt: string;
|
|
168
|
+
n?: number;
|
|
169
|
+
size?: string;
|
|
170
|
+
response_format?: "url" | "b64_json" | string;
|
|
171
|
+
quality?: string;
|
|
172
|
+
style?: string;
|
|
173
|
+
user?: string;
|
|
129
174
|
}
|
|
130
175
|
export interface ImageObject extends Record<string, unknown> {
|
|
131
176
|
url?: string;
|
|
@@ -167,7 +212,6 @@ export interface ModelListResponse extends RunInfraRequestMetadata {
|
|
|
167
212
|
object?: string;
|
|
168
213
|
data: ModelObject[];
|
|
169
214
|
}
|
|
170
|
-
export type UnsupportedOperationRequest = Record<string, unknown>;
|
|
171
215
|
export interface ConstructWebhookEventOptions {
|
|
172
216
|
payload: string | Uint8Array | ArrayBuffer;
|
|
173
217
|
signatureHeader: string;
|
|
@@ -180,30 +224,44 @@ export declare class RunInfraError extends Error {
|
|
|
180
224
|
readonly type: string;
|
|
181
225
|
readonly requestId?: string;
|
|
182
226
|
readonly retryAfterMs?: number;
|
|
227
|
+
readonly code?: string;
|
|
228
|
+
readonly param?: string;
|
|
183
229
|
constructor(message: string, input: {
|
|
184
230
|
status: number;
|
|
185
231
|
type: string;
|
|
186
232
|
requestId?: string;
|
|
187
233
|
retryAfterMs?: number;
|
|
234
|
+
code?: string;
|
|
235
|
+
param?: string;
|
|
188
236
|
});
|
|
189
237
|
}
|
|
190
238
|
export declare class AuthenticationError extends RunInfraError {
|
|
191
|
-
constructor(message: string, status: number, requestId?: string);
|
|
239
|
+
constructor(message: string, status: number, requestId?: string, code?: string, param?: string);
|
|
192
240
|
}
|
|
193
241
|
export declare class PermissionDeniedError extends RunInfraError {
|
|
194
|
-
constructor(message: string, status: number, requestId?: string);
|
|
242
|
+
constructor(message: string, status: number, requestId?: string, code?: string, param?: string, type?: string);
|
|
195
243
|
}
|
|
196
244
|
export declare class RateLimitError extends RunInfraError {
|
|
197
|
-
constructor(message: string, status: number, requestId?: string, retryAfterMs?: number);
|
|
245
|
+
constructor(message: string, status: number, requestId?: string, retryAfterMs?: number, code?: string, param?: string);
|
|
198
246
|
}
|
|
199
247
|
export declare class InsufficientCreditsError extends RunInfraError {
|
|
200
|
-
|
|
248
|
+
/** Remaining workspace balance in cents, when the gateway reports it. */
|
|
249
|
+
readonly currentBalanceCents?: number;
|
|
250
|
+
/** Credits this request needed, in cents, when the gateway reports it. */
|
|
251
|
+
readonly requiredCents?: number;
|
|
252
|
+
/** Where to top up, when the gateway reports it. */
|
|
253
|
+
readonly topupUrl?: string;
|
|
254
|
+
constructor(message: string, status: number, requestId?: string, code?: string, param?: string, details?: {
|
|
255
|
+
currentBalanceCents?: number;
|
|
256
|
+
requiredCents?: number;
|
|
257
|
+
topupUrl?: string;
|
|
258
|
+
});
|
|
201
259
|
}
|
|
202
260
|
export declare class DeploymentError extends RunInfraError {
|
|
203
|
-
constructor(message: string, status: number, requestId?: string);
|
|
261
|
+
constructor(message: string, status: number, requestId?: string, code?: string, param?: string);
|
|
204
262
|
}
|
|
205
263
|
export declare class ModelNotFoundError extends RunInfraError {
|
|
206
|
-
constructor(message: string, status: number, requestId?: string);
|
|
264
|
+
constructor(message: string, status: number, requestId?: string, code?: string, param?: string);
|
|
207
265
|
}
|
|
208
266
|
export declare class RunInfraTimeoutError extends RunInfraError {
|
|
209
267
|
constructor(message?: string, requestId?: string);
|
|
@@ -227,7 +285,8 @@ export declare class RunInfraAudioResponse {
|
|
|
227
285
|
readonly requestId?: string;
|
|
228
286
|
private readonly response;
|
|
229
287
|
private readonly readTimeoutMs?;
|
|
230
|
-
|
|
288
|
+
private readonly sensitiveValues;
|
|
289
|
+
constructor(response: Response, readTimeoutMs?: number, sensitiveValues?: readonly string[]);
|
|
231
290
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
232
291
|
blob(): Promise<Blob>;
|
|
233
292
|
stream(): ReadableStream<Uint8Array> | null;
|
|
@@ -237,7 +296,8 @@ export declare class RunInfraStream<TEvent extends Record<string, unknown> = Rec
|
|
|
237
296
|
readonly response: Response;
|
|
238
297
|
readonly requestId?: string;
|
|
239
298
|
private readonly readTimeoutMs?;
|
|
240
|
-
|
|
299
|
+
private readonly sensitiveValues;
|
|
300
|
+
constructor(response: Response, readTimeoutMs?: number, sensitiveValues?: readonly string[]);
|
|
241
301
|
[Symbol.asyncIterator](): AsyncIterator<TEvent>;
|
|
242
302
|
}
|
|
243
303
|
export declare class RunInfra {
|
|
@@ -255,11 +315,10 @@ export declare class RunInfra {
|
|
|
255
315
|
/**
|
|
256
316
|
* Audio surfaces (text-to-speech + speech-to-text).
|
|
257
317
|
*
|
|
258
|
-
*
|
|
259
|
-
* against a live deployed pipeline in our canary suite. The HTTP envelope
|
|
318
|
+
* Preview helpers for deployed RunInfra audio routes. The HTTP envelope
|
|
260
319
|
* matches the OpenAI Audio API contract and the request/response shapes are
|
|
261
|
-
* stable
|
|
262
|
-
*
|
|
320
|
+
* stable. Supported voices, reference-audio modes, and response formats are
|
|
321
|
+
* deployment-specific.
|
|
263
322
|
*/
|
|
264
323
|
readonly audio: {
|
|
265
324
|
speech: {
|
|
@@ -276,21 +335,24 @@ export declare class RunInfra {
|
|
|
276
335
|
/**
|
|
277
336
|
* Image generation surface.
|
|
278
337
|
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
* own deployed model before using in production. Live-canary verification
|
|
283
|
-
* is tracked for v1.0.0 GA.
|
|
338
|
+
* Preview helper for deployed RunInfra image routes. The HTTP envelope
|
|
339
|
+
* matches the OpenAI Images API contract. Supported size, response format,
|
|
340
|
+
* quality, style, and user fields depend on the selected deployment.
|
|
284
341
|
*/
|
|
285
342
|
readonly images: {
|
|
286
343
|
generate: (request: ImageGenerateRequest, options?: RunInfraRequestOptions) => Promise<ImageGenerationResponse>;
|
|
287
344
|
};
|
|
288
345
|
readonly webhooks: {
|
|
289
|
-
create: (request?: UnsupportedOperationRequest) => Promise<never>;
|
|
290
|
-
list: () => Promise<never>;
|
|
291
346
|
verifySignature: typeof verifyWebhookSignature;
|
|
292
347
|
constructEvent: typeof constructWebhookEvent;
|
|
293
348
|
};
|
|
349
|
+
/**
|
|
350
|
+
* Voice pipeline surface.
|
|
351
|
+
*
|
|
352
|
+
* Preview helper for co-located voice pipelines. It requires a
|
|
353
|
+
* pipeline-scoped client and posts binary audio to `/pipeline`; transcript
|
|
354
|
+
* and response behavior depends on the selected deployment.
|
|
355
|
+
*/
|
|
294
356
|
readonly voice: {
|
|
295
357
|
pipeline: {
|
|
296
358
|
create: (request: VoicePipelineRequest, options?: RunInfraRequestOptions) => Promise<VoicePipelineResponse>;
|
|
@@ -298,6 +360,7 @@ export declare class RunInfra {
|
|
|
298
360
|
};
|
|
299
361
|
private readonly apiKey;
|
|
300
362
|
private readonly baseURL;
|
|
363
|
+
private readonly hasPipelineScope;
|
|
301
364
|
private readonly timeoutMs;
|
|
302
365
|
private readonly maxRetries;
|
|
303
366
|
private readonly retryBaseMs;
|