@runinfra/sdk 0.1.3 → 0.3.2

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/dist/index.d.ts CHANGED
@@ -1,42 +1,158 @@
1
- export declare const RUNINFRA_SDK_VERSION = "0.1.3";
1
+ export declare const RUNINFRA_SDK_VERSION = "0.3.2";
2
2
  export interface RunInfraOptions {
3
3
  apiKey: string;
4
4
  pipelineId?: string;
5
5
  baseURL?: string;
6
+ /**
7
+ * The timeout of every call, in milliseconds. Left out, a non-streamed call
8
+ * is given 750 seconds, and a streamed call 190 seconds to its response
9
+ * headers and to each later read. The `fetch` in use has its own limits:
10
+ * Node's built-in `fetch` waits at most 300 seconds for the response
11
+ * headers, whatever this says.
12
+ */
6
13
  timeoutMs?: number;
7
14
  maxRetries?: number;
8
15
  retryBaseMs?: number;
16
+ /**
17
+ * The `fetch` every call is sent with. Defaults to the runtime's own. Pass
18
+ * one whose own time limits allow more when a non-streamed call must wait
19
+ * longer for its response headers than the runtime's `fetch` does.
20
+ */
9
21
  fetch?: typeof fetch;
10
22
  dangerouslyAllowBrowser?: boolean;
11
23
  }
12
24
  export interface RunInfraRequestOptions {
13
25
  clientRequestId?: string;
14
26
  idempotencyKey?: string;
27
+ /** The timeout of this call, in milliseconds. It wins over the client's `timeoutMs` and over the defaults. */
15
28
  timeoutMs?: number;
16
29
  maxRetries?: number;
17
30
  retryBaseMs?: number;
18
31
  headers?: Record<string, string>;
32
+ extraBody?: Record<string, unknown>;
19
33
  }
34
+ /** One call the model asks for, on an assistant message's `tool_calls`. */
35
+ export interface ChatCompletionMessageToolCall {
36
+ /** The call's id. The `tool` message that answers the call repeats it as `tool_call_id`. */
37
+ id: string;
38
+ type: "function";
39
+ function: {
40
+ name: string;
41
+ /** The arguments as a JSON string. Parse and check them before you run the tool. */
42
+ arguments: string;
43
+ };
44
+ }
45
+ /**
46
+ * One message of a chat. `system`, `developer` and `user` messages carry
47
+ * `content`. An `assistant` message carries `content`, a non-empty
48
+ * `tool_calls`, or both. A `tool` message carries `content` and the
49
+ * `tool_call_id` of the call it answers; `ChatToolMessage` types that one.
50
+ */
20
51
  export interface ChatMessage {
21
- role: "system" | "user" | "assistant" | "tool" | string;
22
- content: string | Array<Record<string, unknown>>;
52
+ role: "system" | "developer" | "user" | "assistant" | "tool" | string;
53
+ /** `null` or left out on an assistant message that carries only `tool_calls`. */
54
+ content?: string | Array<Record<string, unknown>> | null;
23
55
  name?: string;
56
+ /** On a `tool` message: the `id` of the call this message answers. */
24
57
  tool_call_id?: string;
58
+ /** On an `assistant` message: the calls the model asked for. */
59
+ tool_calls?: ChatCompletionMessageToolCall[];
60
+ /** On an answered `assistant` message: the model's thinking, when the model reports it. */
61
+ reasoning?: string | null;
62
+ }
63
+ /** The message that answers one tool call: the result as `content`, and the call's id. */
64
+ export interface ChatToolMessage extends ChatMessage {
65
+ role: "tool";
66
+ content: string | Array<Record<string, unknown>>;
67
+ tool_call_id: string;
25
68
  }
26
- export interface ChatCompletionRequest extends Record<string, unknown> {
69
+ export interface ChatCompletionRequest {
27
70
  model: string;
28
71
  messages: ChatMessage[];
29
72
  stream?: boolean;
73
+ temperature?: number;
74
+ top_p?: number;
75
+ max_tokens?: number;
76
+ max_completion_tokens?: number;
77
+ stop?: string | string[];
78
+ presence_penalty?: number;
79
+ frequency_penalty?: number;
80
+ user?: string;
81
+ metadata?: Record<string, unknown>;
82
+ stream_options?: {
83
+ include_usage?: boolean;
84
+ } & Record<string, unknown>;
85
+ tools?: Array<Record<string, unknown>>;
86
+ tool_choice?: string | Record<string, unknown>;
87
+ response_format?: Record<string, unknown>;
88
+ seed?: number;
89
+ logprobs?: boolean;
90
+ top_logprobs?: number;
91
+ /** `-1` or `0` turns it off. */
92
+ top_k?: number;
93
+ min_p?: number;
94
+ repetition_penalty?: number;
95
+ /** How many choices to generate. */
96
+ n?: number;
97
+ best_of?: number;
98
+ logit_bias?: Record<string, number>;
99
+ /** `false` asks for one tool call at a time. Whether it is honored depends on the model. */
100
+ parallel_tool_calls?: boolean;
101
+ /** How much the model reasons, such as `"none"`, `"low"` or `"high"`. The accepted values depend on the model. */
102
+ reasoning_effort?: string;
103
+ /** The reasoning object some routers send. Do not send it beside a `reasoning_effort` that disagrees. */
104
+ reasoning?: {
105
+ effort?: string;
106
+ enabled?: boolean;
107
+ exclude?: boolean;
108
+ } & Record<string, unknown>;
109
+ /** `false` hides the model's reasoning from the answer. */
110
+ include_reasoning?: boolean;
111
+ /** A cache-affinity hint for requests that share a prompt prefix. */
112
+ prompt_cache_key?: string;
113
+ service_tier?: string;
114
+ store?: boolean;
115
+ safety_identifier?: string;
116
+ modalities?: string[];
117
+ audio?: Record<string, unknown>;
118
+ prediction?: Record<string, unknown>;
119
+ verbosity?: string;
120
+ web_search_options?: Record<string, unknown>;
121
+ moderation?: unknown;
122
+ /** The older spelling of `tools`. Prefer `tools`. */
123
+ functions?: Array<Record<string, unknown>>;
124
+ /** The older spelling of `tool_choice`. Prefer `tool_choice`. */
125
+ function_call?: string | Record<string, unknown>;
126
+ }
127
+ /** One piece of a tool call on a stream. Pieces of the same call share `index`; join their `arguments`. */
128
+ export interface ChatCompletionStreamToolCallDelta {
129
+ index: number;
130
+ /** On the first piece of a call. */
131
+ id?: string;
132
+ type?: "function";
133
+ function?: {
134
+ /** On the first piece of a call. */
135
+ name?: string;
136
+ /** The next piece of the arguments' JSON string. */
137
+ arguments?: string;
138
+ };
30
139
  }
31
140
  export interface ChatCompletionStreamEvent extends Record<string, unknown> {
32
141
  choices?: Array<{
142
+ index?: number;
33
143
  delta?: {
34
- content?: string;
144
+ role?: string;
145
+ content?: string | null;
146
+ /** The next piece of the model's thinking, when the model reports it. */
147
+ reasoning?: string | null;
148
+ tool_calls?: ChatCompletionStreamToolCallDelta[];
35
149
  } & Record<string, unknown>;
150
+ finish_reason?: string | null;
36
151
  } & Record<string, unknown>>;
37
152
  }
38
153
  export interface RunInfraRequestMetadata extends Record<string, unknown> {
39
154
  _request_id?: string;
155
+ _idempotent_replay?: boolean;
40
156
  }
41
157
  export interface ChatCompletionResponse extends RunInfraRequestMetadata {
42
158
  id?: string;
@@ -59,12 +175,22 @@ export interface ChatCompletionsCreate {
59
175
  }, options?: RunInfraRequestOptions): Promise<ChatCompletionResponse>;
60
176
  (request: ChatCompletionRequest, options?: RunInfraRequestOptions): Promise<ChatCompletionResponse | RunInfraStream<ChatCompletionStreamEvent>>;
61
177
  }
62
- export interface ResponsesCreateRequest extends Record<string, unknown> {
178
+ /**
179
+ * Request shape for the current RunInfra Responses compatibility adapter.
180
+ * The gateway maps supported fields onto chat completions and rewraps the
181
+ * result; this is not a full stateful OpenAI Responses implementation.
182
+ */
183
+ export interface ResponsesCreateRequest {
63
184
  model: string;
64
185
  input: string | Array<Record<string, unknown>>;
65
186
  instructions?: string;
66
187
  max_output_tokens?: number;
67
188
  stream?: boolean;
189
+ temperature?: number;
190
+ top_p?: number;
191
+ tools?: Array<Record<string, unknown>>;
192
+ tool_choice?: string | Record<string, unknown>;
193
+ response_format?: Record<string, unknown>;
68
194
  }
69
195
  export interface ResponsesStreamEvent extends Record<string, unknown> {
70
196
  type?: string;
@@ -73,6 +199,7 @@ export interface ResponsesStreamEvent extends Record<string, unknown> {
73
199
  export interface ResponsesCreateResponse extends RunInfraRequestMetadata {
74
200
  id?: string;
75
201
  object?: string;
202
+ created_at?: number;
76
203
  status?: string;
77
204
  model?: string;
78
205
  output_text?: string;
@@ -88,9 +215,12 @@ export interface ResponsesCreate {
88
215
  }, options?: RunInfraRequestOptions): Promise<ResponsesCreateResponse>;
89
216
  (request: ResponsesCreateRequest, options?: RunInfraRequestOptions): Promise<ResponsesCreateResponse | RunInfraStream<ResponsesStreamEvent>>;
90
217
  }
91
- export interface EmbeddingRequest extends Record<string, unknown> {
218
+ export interface EmbeddingRequest {
92
219
  model: string;
93
220
  input: string | string[];
221
+ encoding_format?: "float" | string;
222
+ dimensions?: number;
223
+ user?: string;
94
224
  }
95
225
  export interface EmbeddingObject extends Record<string, unknown> {
96
226
  object?: string;
@@ -103,7 +233,7 @@ export interface EmbeddingResponse extends RunInfraRequestMetadata {
103
233
  data: EmbeddingObject[];
104
234
  usage?: Record<string, unknown>;
105
235
  }
106
- export interface SpeechRequest extends Record<string, unknown> {
236
+ export interface SpeechRequest {
107
237
  model: string;
108
238
  input: string;
109
239
  voice?: string;
@@ -111,11 +241,16 @@ export interface SpeechRequest extends Record<string, unknown> {
111
241
  ref_text?: string;
112
242
  task_type?: string;
113
243
  response_format?: string;
244
+ speed?: number;
114
245
  }
115
- export interface TranscriptionRequest extends Record<string, unknown> {
246
+ export interface TranscriptionRequest {
116
247
  model: string;
117
248
  file: Blob;
118
249
  filename?: string;
250
+ language?: string;
251
+ prompt?: string;
252
+ response_format?: "json" | "verbose_json" | string;
253
+ temperature?: number;
119
254
  }
120
255
  export interface TranscriptionResponse extends RunInfraRequestMetadata {
121
256
  text?: string;
@@ -123,9 +258,15 @@ export interface TranscriptionResponse extends RunInfraRequestMetadata {
123
258
  duration?: number;
124
259
  segments?: Array<Record<string, unknown>>;
125
260
  }
126
- export interface ImageGenerateRequest extends Record<string, unknown> {
261
+ export interface ImageGenerateRequest {
127
262
  model: string;
128
263
  prompt: string;
264
+ n?: number;
265
+ size?: string;
266
+ response_format?: "url" | "b64_json" | string;
267
+ quality?: string;
268
+ style?: string;
269
+ user?: string;
129
270
  }
130
271
  export interface ImageObject extends Record<string, unknown> {
131
272
  url?: string;
@@ -167,7 +308,219 @@ export interface ModelListResponse extends RunInfraRequestMetadata {
167
308
  object?: string;
168
309
  data: ModelObject[];
169
310
  }
170
- export type UnsupportedOperationRequest = Record<string, unknown>;
311
+ /**
312
+ * The state of a batch job. A job starts in `validating` while its input file
313
+ * is read, then moves by itself through `checked` and `queued` to `running`.
314
+ * `completed`, `expired`, `cancelled`, and `failed` are final.
315
+ */
316
+ export type BatchState = "validating" | "checked" | "queued" | "running" | "paused" | "cancelling" | "completed" | "expired" | "cancelled" | "failed";
317
+ /** Why a paused job waits. Set exactly when `batch_state` is `paused`. */
318
+ export type BatchPauseReason = "funds" | "destination" | "source" | "key_limit" | "daily_room";
319
+ /** Why a job ended. `null` while the job is open. */
320
+ export type BatchEndReason = "all_done" | "max_cost_reached" | "cancel_asked" | "key_revoked" | "account_deleted" | "window_ended" | "model_withdrawn" | "not_flex" | "not_started" | "check_failed";
321
+ /** Why a job's input file was refused. Set only when `end_reason` is `check_failed`. */
322
+ export type BatchCheckError = "url_not_public" | "link_expires_too_soon" | "file_too_large" | "link_changed" | "link_not_supported";
323
+ /** A notice about a job: data only. */
324
+ export type BatchNotice = "batch_ended" | "batch_paused" | "batch_expires_soon";
325
+ /** Why a line of the input file was refused when the file was read. */
326
+ export type BatchLineCheckCode = "invalid_json" | "line_too_large" | "invalid_request" | "media_not_supported" | "prompt_too_large";
327
+ /** The code of a line that failed after its job started, as an error delivery carries it. */
328
+ export type BatchDeliveryErrorCode = "invalid_request" | "prompt_too_large" | "model_error" | "link_changed";
329
+ /** Why batch is not available, on a `flex_not_available` refusal (`error.reason`). */
330
+ export type BatchUnavailableReason = "model" | "partner" | "price";
331
+ /**
332
+ * The refusal codes a caller of the batch routes can receive, as
333
+ * `RunInfraError.code` carries them. Codes every route can answer
334
+ * (`invalid_api_key` on 401, `rate_limit_exceeded` on 429) are not repeated
335
+ * here.
336
+ */
337
+ export type BatchRefusalCode = "batch_not_open" | "invalid_request" | "not_found" | "model_not_sold" | "flex_not_available" | "url_not_public" | "link_expires_too_soon" | "destination_unreachable" | "needs_funds" | "key_spend_limit_reached" | "batch_ended" | "batches_scope_violation";
338
+ /** Where a job's answers go. A webhook address is the only destination. */
339
+ export interface BatchDestination {
340
+ type: "webhook";
341
+ /** A public HTTPS address on port 443, at most 8,192 bytes. */
342
+ url: string;
343
+ }
344
+ export interface BatchCreateRequest {
345
+ /** A model that offers batch. */
346
+ model: string;
347
+ /**
348
+ * A public HTTPS link (port 443, at most 8,192 bytes) to a JSONL file of at
349
+ * most 50 MiB whose host serves byte ranges. A signed link must stay valid
350
+ * until the job's window ends.
351
+ */
352
+ input_url: string;
353
+ destination: BatchDestination;
354
+ /** The most the job may cost, in cents: a whole number from 1 to 100,000,000. */
355
+ max_cost_cents: number;
356
+ /** The job's window in hours. 24 is the only value, and the default. */
357
+ window_hours?: 24;
358
+ /** A label of at most 64 characters. */
359
+ name?: string;
360
+ }
361
+ export interface BatchListParams {
362
+ /** Page size, from 1 to 50. The gateway's default is 20. */
363
+ limit?: number;
364
+ /** The `next_cursor` of the page before. */
365
+ cursor?: string;
366
+ state?: BatchState;
367
+ /** A model slug. */
368
+ model?: string;
369
+ }
370
+ /**
371
+ * A batch job, as every batch route answers it. `failed` never includes an
372
+ * undelivered line, and once a job has ended the counts `succeeded`,
373
+ * `failed`, `expired`, `cancelled`, `undelivered`, and `lines_invalid` add up
374
+ * to `lines_total`.
375
+ */
376
+ export interface BatchJob {
377
+ id: string;
378
+ /** `null` when the model is no longer listed. */
379
+ model_slug: string | null;
380
+ batch_state: BatchState;
381
+ pause_reason: BatchPauseReason | null;
382
+ /** Who started the job: an API key, or a person in the dashboard. Never a name. */
383
+ made_by: {
384
+ kind: "person" | "key";
385
+ };
386
+ /** Every line read from the file, the invalid ones included. */
387
+ lines_total: number;
388
+ lines_invalid: number;
389
+ succeeded: number;
390
+ failed: number;
391
+ /** Lines the job had not run when its window ended. They are not charged. */
392
+ expired: number;
393
+ cancelled: number;
394
+ /**
395
+ * Answered lines the address did not acknowledge with a 2xx in time. They
396
+ * are not charged and are not sent again.
397
+ */
398
+ undelivered: number;
399
+ /** What the job's lines were charged so far, in microcents (millionths of a cent). */
400
+ cost_microcents: number;
401
+ max_cost_cents: number | null;
402
+ /** ISO 8601 UTC with milliseconds. */
403
+ created_at: string;
404
+ started_at: string | null;
405
+ /** The end of the job's window. */
406
+ expires_at: string;
407
+ finished_at: string | null;
408
+ destination_type: "webhook" | null;
409
+ notice: BatchNotice | null;
410
+ /** The API key the job runs as. */
411
+ key_id: string | null;
412
+ end_reason: BatchEndReason | null;
413
+ check_error: BatchCheckError | null;
414
+ name: string | null;
415
+ }
416
+ /** The lines one check code refused: how many, and the first line numbers (1-based, at most five). */
417
+ export interface BatchLineCheckErrors {
418
+ code: BatchLineCheckCode;
419
+ count: number;
420
+ first_lines: number[];
421
+ }
422
+ /** The gateway's estimate of the most a job's lines can cost. */
423
+ export interface BatchQuote {
424
+ input_cost_cents: number;
425
+ output_cost_ceiling_cents: number;
426
+ /** `input_cost_cents` plus `output_cost_ceiling_cents`. */
427
+ most_cents: number;
428
+ flex_input_cents_per_million: number;
429
+ flex_output_cents_per_million: number;
430
+ est_input_tokens: number;
431
+ /** An estimate, never a promise. */
432
+ can_finish_in_window: boolean;
433
+ covered_until_after: string | null;
434
+ }
435
+ /** A job as `batches.retrieve()` answers it: the job, the lines its check refused, and its quote. */
436
+ export interface BatchJobDetail extends BatchJob {
437
+ errors: BatchLineCheckErrors[];
438
+ /** `null` while the file is still read, once the job has ended, and when no quote can be made now. */
439
+ quote: BatchQuote | null;
440
+ }
441
+ export interface BatchCreateResponse extends RunInfraRequestMetadata {
442
+ batch: BatchJob;
443
+ }
444
+ export interface BatchRetrieveResponse extends RunInfraRequestMetadata {
445
+ batch: BatchJobDetail;
446
+ }
447
+ export interface BatchListResponse extends RunInfraRequestMetadata {
448
+ /** Newest first. */
449
+ batches: BatchJob[];
450
+ /** Pass it as `cursor` for the next page. `null` on the last page. */
451
+ next_cursor: string | null;
452
+ }
453
+ export interface BatchCancelResponse extends RunInfraRequestMetadata {
454
+ batch_id: string;
455
+ /** `cancelled` when no line had run; `cancelling` while lines in flight settle. */
456
+ batch_state: "cancelling" | "cancelled";
457
+ }
458
+ export interface BatchDeliveryUsage {
459
+ prompt_tokens: number;
460
+ completion_tokens: number;
461
+ total_tokens: number;
462
+ }
463
+ export interface BatchDeliveryCost {
464
+ /** What the line cost, in microcents (millionths of a cent). */
465
+ microcents: number;
466
+ }
467
+ /**
468
+ * The test delivery a `batches.create()` call sends to the destination before
469
+ * it answers. The address must reply 2xx with a body that CONTAINS `value`.
470
+ */
471
+ export interface BatchTestDelivery {
472
+ id: string;
473
+ test: true;
474
+ value: string;
475
+ }
476
+ /** One answered line. `id` is the same for the same line and attempt. Key your own writes on it. */
477
+ export interface BatchAnswerDelivery {
478
+ id: string;
479
+ batch_id: string;
480
+ custom_id: string;
481
+ /** The line's 1-based number in the input file. */
482
+ line: number;
483
+ attempt: number;
484
+ test: false;
485
+ /** The chat completion object. */
486
+ response: Record<string, unknown>;
487
+ error?: undefined;
488
+ usage: BatchDeliveryUsage | null;
489
+ cost: BatchDeliveryCost | null;
490
+ }
491
+ /** One line that failed after its job started. It carries no usage and no cost. */
492
+ export interface BatchErrorDelivery {
493
+ id: string;
494
+ batch_id: string;
495
+ /** `null` when the file changed after it was checked (`link_changed`); `line` names the line then. */
496
+ custom_id: string | null;
497
+ line: number;
498
+ attempt: number;
499
+ test: false;
500
+ error: {
501
+ code: BatchDeliveryErrorCode;
502
+ };
503
+ response?: undefined;
504
+ usage: null;
505
+ cost: null;
506
+ }
507
+ export type BatchDelivery = BatchTestDelivery | BatchAnswerDelivery | BatchErrorDelivery;
508
+ export interface VerifyBatchDeliveryOptions {
509
+ /** The RAW request body exactly as it arrived: a string or bytes, never a re-serialized object. */
510
+ payload: string | Uint8Array | ArrayBuffer;
511
+ /** The request's headers, in any case: a `Headers` object or a plain object such as Node's `req.headers`. */
512
+ headers: Headers | Record<string, string | string[] | undefined>;
513
+ /** The workspace's batch signing secret as the dashboard shows it: `whsec_` followed by base64. */
514
+ secret: string;
515
+ /**
516
+ * The most the delivery's timestamp may differ from the clock, in seconds.
517
+ * 300 by default, so a captured delivery cannot be replayed later. A number
518
+ * sets another tolerance; `null` turns the check off.
519
+ */
520
+ toleranceSeconds?: number | null;
521
+ /** The clock the timestamp is compared with, in Unix seconds. Defaults to now. */
522
+ now?: number;
523
+ }
171
524
  export interface ConstructWebhookEventOptions {
172
525
  payload: string | Uint8Array | ArrayBuffer;
173
526
  signatureHeader: string;
@@ -179,34 +532,87 @@ export declare class RunInfraError extends Error {
179
532
  readonly status: number;
180
533
  readonly type: string;
181
534
  readonly requestId?: string;
535
+ /**
536
+ * The wait the API named with the error, in milliseconds: `Retry-After-Ms`
537
+ * when the response carries it, else `Retry-After`. Set on every error whose
538
+ * response named a wait, whatever its status.
539
+ */
182
540
  readonly retryAfterMs?: number;
541
+ readonly code?: string;
542
+ readonly param?: string;
543
+ /**
544
+ * The closed cause word of a batch route's refusal, when its error body
545
+ * names one (`error.reason`): `model`, `partner`, or `price` on
546
+ * `flex_not_available`. Other routes do not set it.
547
+ */
548
+ readonly reason?: string;
549
+ /**
550
+ * What the API said about asking again, when it said it: `x-should-retry` on
551
+ * the response, or `retryable` inside the error object. `false` means the
552
+ * same request will fail again. Left unset when the API said nothing.
553
+ */
554
+ readonly retryable?: boolean;
555
+ /**
556
+ * The `X-Client-Request-Id` the SDK sent with the call, set on a timeout.
557
+ * A call that timed out before any response has no server request id, so
558
+ * this is the id to quote to support.
559
+ */
560
+ readonly clientRequestId?: string;
183
561
  constructor(message: string, input: {
184
562
  status: number;
185
563
  type: string;
186
564
  requestId?: string;
187
565
  retryAfterMs?: number;
566
+ code?: string;
567
+ param?: string;
568
+ reason?: string;
569
+ retryable?: boolean;
570
+ clientRequestId?: string;
188
571
  });
189
572
  }
190
573
  export declare class AuthenticationError extends RunInfraError {
191
- constructor(message: string, status: number, requestId?: string);
574
+ constructor(message: string, status: number, requestId?: string, code?: string, param?: string);
192
575
  }
193
576
  export declare class PermissionDeniedError extends RunInfraError {
194
- constructor(message: string, status: number, requestId?: string);
577
+ constructor(message: string, status: number, requestId?: string, code?: string, param?: string, type?: string);
195
578
  }
196
579
  export declare class RateLimitError extends RunInfraError {
197
- constructor(message: string, status: number, requestId?: string, retryAfterMs?: number);
198
- }
580
+ constructor(message: string, status: number, requestId?: string, retryAfterMs?: number, code?: string, param?: string);
581
+ }
582
+ /**
583
+ * A `402` from the gateway. On a batch route, read `code` to tell
584
+ * `needs_funds` (the account has never added funds) from
585
+ * `key_spend_limit_reached` (this API key reached its own monthly limit;
586
+ * raise the key's limit or use another key).
587
+ */
199
588
  export declare class InsufficientCreditsError extends RunInfraError {
200
- constructor(message: string, status: number, requestId?: string);
589
+ /** Remaining workspace balance in cents, when the gateway reports it. */
590
+ readonly currentBalanceCents?: number;
591
+ /** Credits this request needed, in cents, when the gateway reports it. */
592
+ readonly requiredCents?: number;
593
+ /** Where to top up, when the gateway reports it. */
594
+ readonly topupUrl?: string;
595
+ constructor(message: string, status: number, requestId?: string, code?: string, param?: string, details?: {
596
+ currentBalanceCents?: number;
597
+ requiredCents?: number;
598
+ topupUrl?: string;
599
+ });
201
600
  }
202
601
  export declare class DeploymentError extends RunInfraError {
203
- constructor(message: string, status: number, requestId?: string);
602
+ constructor(message: string, status: number, requestId?: string, code?: string, param?: string);
204
603
  }
205
604
  export declare class ModelNotFoundError extends RunInfraError {
206
- constructor(message: string, status: number, requestId?: string);
207
- }
605
+ constructor(message: string, status: number, requestId?: string, code?: string, param?: string);
606
+ }
607
+ /**
608
+ * A call that ran out of time: the SDK's own timeout, or the runtime's `fetch`
609
+ * giving up on the response headers or the body by its own clock.
610
+ * `clientRequestId` holds the `X-Client-Request-Id` the SDK sent with the
611
+ * call; `requestId` is set only when a response had begun. A call is never
612
+ * sent again after a timeout: the API may still be working on it.
613
+ */
208
614
  export declare class RunInfraTimeoutError extends RunInfraError {
209
- constructor(message?: string, requestId?: string);
615
+ constructor(message?: string, requestId?: string, clientRequestId?: string);
210
616
  }
211
617
  export declare class RunInfraConnectionError extends RunInfraError {
212
618
  constructor(message?: string, requestId?: string);
@@ -214,6 +620,32 @@ export declare class RunInfraConnectionError extends RunInfraError {
214
620
  export declare class RunInfraStreamParseError extends RunInfraError {
215
621
  constructor(message?: string, requestId?: string);
216
622
  }
623
+ /**
624
+ * The API ended an open stream with a failure: a frame that holds an `error`
625
+ * object, or a `response.failed` event on a Responses stream. `type`, `code`
626
+ * and `param` are the API's own, `retryable` is set when the API marked the
627
+ * failure, and `requestId` is the request id the frame names, else the
628
+ * stream's. `status` is `0`: the failure arrived after the HTTP status. The
629
+ * events before the failure were already yielded. The answer is not whole.
630
+ */
631
+ export declare class RunInfraStreamError extends RunInfraError {
632
+ constructor(message: string, input: {
633
+ type: string;
634
+ requestId?: string;
635
+ code?: string;
636
+ param?: string;
637
+ retryable?: boolean;
638
+ });
639
+ }
640
+ /**
641
+ * A stream's body ended without its end marker: `[DONE]` on a chat stream,
642
+ * `response.completed` on a Responses stream. The connection was cut or the
643
+ * stream was closed early, so the answer is not whole even though the HTTP
644
+ * status was 200. The events before the end were already yielded.
645
+ */
646
+ export declare class RunInfraStreamIncompleteError extends RunInfraError {
647
+ constructor(message?: string, requestId?: string);
648
+ }
217
649
  export declare class UnsupportedOperationError extends RunInfraError {
218
650
  constructor(message: string);
219
651
  }
@@ -222,22 +654,82 @@ export declare class WebhookVerificationError extends RunInfraError {
222
654
  }
223
655
  export declare function verifyWebhookSignature(options: ConstructWebhookEventOptions): true;
224
656
  export declare function constructWebhookEvent<T = Record<string, unknown>>(options: ConstructWebhookEventOptions): T;
657
+ /**
658
+ * Verifies one batch delivery posted to your own address and returns it parsed
659
+ * and typed: the test delivery of `batches.create()`, one line's answer, or
660
+ * one line's error.
661
+ *
662
+ * Pass the RAW request body, exactly the bytes that arrived, and the request's
663
+ * headers in any case. The signature is the Standard Webhooks one: header
664
+ * `webhook-signature` holds `v1,` followed by the base64 HMAC-SHA-256 of
665
+ * `<webhook-id>.<webhook-timestamp>.<raw body>`, compared in constant time.
666
+ * Parsing the body and serializing it again changes the bytes and fails the
667
+ * check.
668
+ *
669
+ * `secret` is the workspace's batch signing secret as the dashboard shows it:
670
+ * `whsec_` followed by base64. The HMAC key is the base64-DECODED bytes after
671
+ * the prefix, not the text. Header `x-rightnow-signature-version` names the
672
+ * version of the secret that signed; a rotated secret stops verifying.
673
+ *
674
+ * The delivery's `webhook-timestamp` must be within 300 seconds of the clock
675
+ * by default, so a captured delivery cannot be replayed later. A number in
676
+ * `toleranceSeconds` sets another tolerance, `toleranceSeconds: null` turns
677
+ * the check off, and `now` sets the clock it is compared with.
678
+ *
679
+ * ANSWERING THE TEST DELIVERY: `batches.create()` posts
680
+ * `{ id, test: true, value }` to the destination before it answers, and the
681
+ * address passes only when it replies 2xx with a body that CONTAINS the posted
682
+ * `value`. A fixed `200 OK` fails the create with `destination_unreachable`.
683
+ * Line deliveries (`test: false`) are acknowledged by any 2xx. Each answered
684
+ * line is sent to the address once: if the address does not answer 2xx in
685
+ * time, the line is counted `undelivered`, it is not charged, and it is not
686
+ * sent again.
687
+ *
688
+ * Throws `WebhookVerificationError` when a header is missing, the signature
689
+ * does not match, the timestamp is outside the tolerance, or the body is not a
690
+ * delivery. Every failure of this helper is a `WebhookVerificationError`.
691
+ */
692
+ export declare function verifyBatchDelivery(options: VerifyBatchDeliveryOptions): BatchDelivery;
225
693
  export declare class RunInfraAudioResponse {
226
694
  readonly contentType: string;
227
695
  readonly requestId?: string;
228
696
  private readonly response;
229
697
  private readonly readTimeoutMs?;
230
- constructor(response: Response, readTimeoutMs?: number);
698
+ private readonly sensitiveValues;
699
+ /** The `X-Client-Request-Id` the SDK sent with the call. A timeout while the body is read names it. */
700
+ private readonly clientRequestId?;
701
+ constructor(response: Response, readTimeoutMs?: number, sensitiveValues?: readonly string[], clientRequestId?: string);
231
702
  arrayBuffer(): Promise<ArrayBuffer>;
232
703
  blob(): Promise<Blob>;
233
704
  stream(): ReadableStream<Uint8Array> | null;
234
705
  private readBody;
235
- }
706
+ /** A failed body read as the SDK's error. A timeout names the request id the SDK sent. */
707
+ private bodyReadFailure;
708
+ }
709
+ /**
710
+ * The events of one streamed answer.
711
+ *
712
+ * Iterating yields each event as it arrives. The iteration ends quietly only
713
+ * when the stream carried its end marker: `[DONE]` on a chat stream,
714
+ * `response.completed` on a Responses stream. It throws instead, after
715
+ * yielding every event that came first, when the API reports a failure on the
716
+ * open stream (`RunInfraStreamError`) or when the body ends without the end
717
+ * marker (`RunInfraStreamIncompleteError`). Leaving the loop early throws
718
+ * nothing.
719
+ *
720
+ * When the API answers the call with one JSON object instead of an event
721
+ * stream, the iteration yields that object once and ends quietly. That is the
722
+ * answer to a streamed call that repeats an `Idempotency-Key`: the object
723
+ * carries `_idempotent_replay: true`, as a non-streamed answer does.
724
+ */
236
725
  export declare class RunInfraStream<TEvent extends Record<string, unknown> = Record<string, unknown>> implements AsyncIterable<TEvent> {
237
726
  readonly response: Response;
238
727
  readonly requestId?: string;
239
728
  private readonly readTimeoutMs?;
240
- constructor(response: Response, readTimeoutMs?: number);
729
+ private readonly sensitiveValues;
730
+ /** The `X-Client-Request-Id` the SDK sent with the call. A timeout while the stream is read names it. */
731
+ private readonly clientRequestId?;
732
+ constructor(response: Response, readTimeoutMs?: number, sensitiveValues?: readonly string[], clientRequestId?: string);
241
733
  [Symbol.asyncIterator](): AsyncIterator<TEvent>;
242
734
  }
243
735
  export declare class RunInfra {
@@ -255,11 +747,10 @@ export declare class RunInfra {
255
747
  /**
256
748
  * Audio surfaces (text-to-speech + speech-to-text).
257
749
  *
258
- * @experimental As of v0.1.3, these methods have NOT been verified end-to-end
259
- * against a live deployed pipeline in our canary suite. The HTTP envelope
750
+ * Preview helpers for deployed RunInfra audio routes. The HTTP envelope
260
751
  * matches the OpenAI Audio API contract and the request/response shapes are
261
- * stable, but you should test against your own deployed model before using
262
- * in production. Live-canary verification is tracked for v1.0.0 GA.
752
+ * stable. Supported voices, reference-audio modes, and response formats are
753
+ * deployment-specific.
263
754
  */
264
755
  readonly audio: {
265
756
  speech: {
@@ -276,21 +767,51 @@ export declare class RunInfra {
276
767
  /**
277
768
  * Image generation surface.
278
769
  *
279
- * @experimental As of v0.1.3, this method has NOT been verified end-to-end
280
- * against a live deployed pipeline in our canary suite. The HTTP envelope
281
- * matches the OpenAI Images API contract, but you should test against your
282
- * own deployed model before using in production. Live-canary verification
283
- * is tracked for v1.0.0 GA.
770
+ * Preview helper for deployed RunInfra image routes. The HTTP envelope
771
+ * matches the OpenAI Images API contract. Supported size, response format,
772
+ * quality, style, and user fields depend on the selected deployment.
284
773
  */
285
774
  readonly images: {
286
775
  generate: (request: ImageGenerateRequest, options?: RunInfraRequestOptions) => Promise<ImageGenerationResponse>;
287
776
  };
777
+ /**
778
+ * Batch jobs.
779
+ *
780
+ * Preview. A job takes a JSONL file of chat completion requests and posts
781
+ * each answer, signed, to your webhook address. A job has a window of 24
782
+ * hours. Lines run when the model has spare capacity. A line the job has
783
+ * not run when its window ends is counted `expired` and is not charged. Use
784
+ * a workspace-scoped key; verify deliveries with `verifyBatchDelivery`.
785
+ */
786
+ readonly batches: {
787
+ /**
788
+ * Creates a job, which then starts by itself. The gateway first posts a
789
+ * signed test delivery to `destination.url`, so this call can take 20
790
+ * seconds: its default timeout is never below 30 seconds. Pass
791
+ * `idempotencyKey` to make the call safe to retry; without one it is sent
792
+ * once. Sending the same create again with the same key and the same body
793
+ * answers the earlier job as a normal success: no error and no second
794
+ * job. The same key with a different body is refused with 409.
795
+ */
796
+ create: (request: BatchCreateRequest, options?: RunInfraRequestOptions) => Promise<BatchCreateResponse>;
797
+ /** Lists the workspace's jobs, newest first. Page with `next_cursor`. */
798
+ list: (params?: BatchListParams, options?: RunInfraRequestOptions) => Promise<BatchListResponse>;
799
+ /** Reads one job with the lines its check refused and its quote. */
800
+ retrieve: (batchId: string, options?: RunInfraRequestOptions) => Promise<BatchRetrieveResponse>;
801
+ /** Cancels a job: `cancelled` when no line had run, else `cancelling` while lines in flight settle. Sent once, never retried. */
802
+ cancel: (batchId: string, options?: RunInfraRequestOptions) => Promise<BatchCancelResponse>;
803
+ };
288
804
  readonly webhooks: {
289
- create: (request?: UnsupportedOperationRequest) => Promise<never>;
290
- list: () => Promise<never>;
291
805
  verifySignature: typeof verifyWebhookSignature;
292
806
  constructEvent: typeof constructWebhookEvent;
293
807
  };
808
+ /**
809
+ * Voice pipeline surface.
810
+ *
811
+ * Preview helper for co-located voice pipelines. It requires a
812
+ * pipeline-scoped client and posts binary audio to `/pipeline`; transcript
813
+ * and response behavior depends on the selected deployment.
814
+ */
294
815
  readonly voice: {
295
816
  pipeline: {
296
817
  create: (request: VoicePipelineRequest, options?: RunInfraRequestOptions) => Promise<VoicePipelineResponse>;
@@ -298,13 +819,21 @@ export declare class RunInfra {
298
819
  };
299
820
  private readonly apiKey;
300
821
  private readonly baseURL;
301
- private readonly timeoutMs;
822
+ private readonly hasPipelineScope;
823
+ /** The caller's own client timeout. Left unset, each call uses the default of its kind. */
824
+ private readonly timeoutMs?;
302
825
  private readonly maxRetries;
303
826
  private readonly retryBaseMs;
304
827
  private readonly fetcher;
305
828
  constructor(options: RunInfraOptions);
306
829
  private request;
830
+ /**
831
+ * The timeout of one call. The caller's own setting wins: the call's
832
+ * `timeoutMs`, else the client's. With neither, a non-streamed call is given
833
+ * 750 seconds for the whole call, and a streamed call 190 seconds to its
834
+ * response headers and to each later read. `minDefaultTimeoutMs` is the
835
+ * least a call uses when the caller names no timeout for that call.
836
+ */
307
837
  private requestTimeoutMs;
308
- private rawRequest;
309
838
  private sendWithRetry;
310
839
  }