wriftai 0.55.0 → 0.56.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/dist/index.d.ts CHANGED
@@ -246,6 +246,11 @@ interface Model {
246
246
  */
247
247
  cover_image_url: string | null;
248
248
  }
249
+ /** Options for a method call. */
250
+ interface CallOptions {
251
+ /** Optional AbortSignal to cancel the call. */
252
+ signal?: AbortSignal;
253
+ }
249
254
  /** Pagination options interface */
250
255
  type PaginationOptions = {
251
256
  /** Cursor for pagination */
@@ -253,6 +258,9 @@ type PaginationOptions = {
253
258
  /** Number of items per page */
254
259
  page_size?: number;
255
260
  };
261
+ /** Options for listing resources. */
262
+ interface ListOptions extends PaginationOptions, CallOptions {
263
+ }
256
264
  /** Paginated response interface */
257
265
  interface PaginatedResponse<T> {
258
266
  /** List of items returned in the current page */
@@ -293,6 +301,19 @@ interface UploadCompletionResult {
293
301
  download_url: string;
294
302
  }
295
303
 
304
+ /**
305
+ * A single decoded server-sent event.
306
+ *
307
+ * Stricter than the WHATWG spec: the API always returns `id` and `event`,
308
+ * so both are always present as strings. `data` is parsed JSON.
309
+ * @internal
310
+ */
311
+ interface ServerSentEvent<E extends string = string> {
312
+ id: string;
313
+ event: E;
314
+ data: JsonValue;
315
+ }
316
+
296
317
  /**
297
318
  * Representation of an error from WriftAI's API.
298
319
  */
@@ -308,6 +329,32 @@ declare class WriftAIAPIError extends Error {
308
329
  */
309
330
  constructor(status: number, body: string, url: string);
310
331
  }
332
+ /**
333
+ * Options for creating the http request.
334
+ * @internal
335
+ */
336
+ interface RequestOptions {
337
+ /**
338
+ * The http method.
339
+ */
340
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
341
+ /**
342
+ * Optional query parameters.
343
+ */
344
+ params?: Record<string, string | number | boolean | string[] | undefined>;
345
+ /**
346
+ * Optional JSON-serializeable body.
347
+ */
348
+ body?: JsonValue;
349
+ /**
350
+ * Optional extra request headers.
351
+ */
352
+ headers?: Record<string, string>;
353
+ /**
354
+ * Optional abort signal to cancel the request.
355
+ */
356
+ signal?: AbortSignal;
357
+ }
311
358
  /**
312
359
  * Client for WriftAI's API.
313
360
  * @internal
@@ -317,6 +364,7 @@ declare class API {
317
364
  private fetchImpl;
318
365
  private maxRetries;
319
366
  private defaultHeaders;
367
+ private static readonly SSE_HEADERS;
320
368
  /**
321
369
  * Create an instance of the API client.
322
370
  * @param baseUrl Base URL for the API without trailing slashes.
@@ -364,17 +412,18 @@ declare class API {
364
412
  * @returns A promise that resolves after the delay.
365
413
  */
366
414
  private sleep;
415
+ /**
416
+ * Sends an HTTP request with automatic retries on transient errors.
417
+ * @param path The path relative to `baseUrl` (e.g. `/users`)
418
+ * @param options Request options
419
+ * @returns The successful response with its body not yet read.
420
+ */
421
+ private send;
367
422
  /**
368
423
  * Sends an HTTP request with automatic retries on transient errors.
369
424
  * @template T The expected JSON response shape
370
425
  * @param path The path relative to `baseUrl` (e.g. `/users`)
371
426
  * @param options Request options
372
- * @param options.method The HTTP method to use
373
- * @param options.params Optional query parameters. Entries
374
- * with `undefined` values are silently skipped.
375
- * @param options.body Optional JSON-serializable body
376
- * @param options.headers Optional extra request headers
377
- * @param options.signal Optional AbortSignal to cancel the request.
378
427
  * @returns The parsed JSON response
379
428
  * @throws {WriftAIAPIError} If the response is not ok (`!res.ok`)
380
429
  * @example
@@ -382,13 +431,27 @@ declare class API {
382
431
  * const users = await client.request<User[]>("/users", { method: "GET" });
383
432
  * ```
384
433
  */
385
- request<T>(path: string, options: {
386
- method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
387
- params?: Record<string, string | number | boolean | string[] | undefined>;
388
- body?: JsonValue;
389
- headers?: Record<string, string>;
390
- signal?: AbortSignal;
391
- }): Promise<T>;
434
+ request<T>(path: string, options: RequestOptions): Promise<T>;
435
+ /**
436
+ * Iterates over server-sent events from a streaming HTTP response.
437
+ * Consumes the response body incrementally, decodes SSE messages as
438
+ * chunks arrive, and yields each completed event in order.
439
+ * @param response The streaming HTTP response containing SSE data.
440
+ * @yields Decoded server-sent events from the response stream.
441
+ */
442
+ private static iterEvents;
443
+ /**
444
+ * Opens a single server-sent events (SSE) connection.
445
+ * The request is sent when iteration begins and the connection remains
446
+ * open until the stream ends, iteration stops, or the consumer cancels
447
+ * the operation. Retries on transient errors apply only while opening
448
+ * the connection.
449
+ * @param path The path relative to `baseUrl` (e.g. `/events`)
450
+ * @param options Request options
451
+ * @yields Decoded server-sent events from the connection in the order
452
+ * they are received.
453
+ */
454
+ streamSSE<E extends string>(path: string, options: RequestOptions): AsyncIterable<ServerSentEvent<E>>;
392
455
  }
393
456
 
394
457
  /**
@@ -471,7 +534,7 @@ interface Upload {
471
534
  /**
472
535
  * Parameters for creating an upload.
473
536
  */
474
- type CreateUploadParams = {
537
+ interface CreateUploadParams extends CallOptions {
475
538
  /**
476
539
  * The size of the file to upload in bytes.
477
540
  * This should be the exact size of the file.
@@ -482,17 +545,17 @@ type CreateUploadParams = {
482
545
  * The MIME type of the file.
483
546
  */
484
547
  mime_type: string;
485
- };
548
+ }
486
549
  /**
487
550
  * Parameters for completing an upload.
488
551
  */
489
- type CompleteUploadParams = {
552
+ interface CompleteUploadParams extends CallOptions {
490
553
  /**
491
554
  * The list of etags of the uploaded parts
492
555
  * matching the ordering of urls.
493
556
  */
494
557
  etags: string[];
495
- };
558
+ }
496
559
  /**
497
560
  * Resource for operations related to uploads.
498
561
  */
@@ -501,18 +564,16 @@ declare class Uploads extends Resource {
501
564
  /**
502
565
  * Create an upload.
503
566
  * @param params Upload creation parameters.
504
- * @param signal Optional AbortSignal to cancel the request.
505
567
  * @returns The new upload.
506
568
  */
507
- create(params: CreateUploadParams, signal?: AbortSignal): Promise<Upload>;
569
+ create(params: CreateUploadParams): Promise<Upload>;
508
570
  /**
509
571
  * Complete an upload.
510
572
  * @param id The unique identifier of the upload.
511
573
  * @param params Parameters to complete an upload.
512
- * @param signal Optional AbortSignal to cancel the request.
513
574
  * @returns The completion result.
514
575
  */
515
- complete(id: string, params: CompleteUploadParams, signal?: AbortSignal): Promise<UploadCompletionResult>;
576
+ complete(id: string, params: CompleteUploadParams): Promise<UploadCompletionResult>;
516
577
  }
517
578
 
518
579
  /**
@@ -560,10 +621,10 @@ declare class Files {
560
621
  * `Uint8Array` require the data to already be in memory.
561
622
  * Large files are split into parts by the server and uploaded concurrently.
562
623
  * @param file The file to upload.
563
- * @param signal Optional AbortSignal to cancel the request.
624
+ * @param options Options for the call.
564
625
  * @returns Result of the completed upload.
565
626
  */
566
- upload(file: FileData, signal?: AbortSignal): Promise<UploadCompletionResult>;
627
+ upload(file: FileData, options?: CallOptions): Promise<UploadCompletionResult>;
567
628
  }
568
629
 
569
630
  /**
@@ -686,7 +747,7 @@ type Webhook = {
686
747
  /**
687
748
  * Prediction creation parameters.
688
749
  */
689
- interface CreatePredictionParams {
750
+ interface CreatePredictionParams extends CallOptions {
690
751
  /**
691
752
  * Input data provided for the prediction.
692
753
  */
@@ -698,17 +759,21 @@ interface CreatePredictionParams {
698
759
  /**
699
760
  * Enable input validation against the schema before processing.
700
761
  */
701
- validate_input?: boolean;
762
+ validateInput?: boolean;
702
763
  /**
703
764
  * The model reference in either owner/name or owner/name:version-number
704
765
  * format (for example: deepseek-ai/deepseek-r1 or deepseek-ai/deepseek-r1:1).
705
766
  */
706
767
  model: string;
768
+ /**
769
+ * Options for waiting for the prediction to finish.
770
+ */
771
+ wait?: boolean | Partial<CreatePredictionWaitOptions>;
707
772
  }
708
773
  /**
709
774
  * Options for customizing wait behaviour.
710
775
  */
711
- interface WaitOptions {
776
+ interface PredictionWaitOptions {
712
777
  /**
713
778
  * Time in milliseconds between polling attempts to check the
714
779
  * prediction status.
@@ -722,7 +787,7 @@ interface WaitOptions {
722
787
  /**
723
788
  * Options for customizing wait behaviour when creating a prediction.
724
789
  */
725
- interface CreateWaitOptions extends WaitOptions {
790
+ interface CreatePredictionWaitOptions extends PredictionWaitOptions {
726
791
  /**
727
792
  * Max seconds the server holds the connection open while waiting
728
793
  * for the prediction to finish. If not set, the server's default is used.
@@ -748,13 +813,13 @@ declare const DEFAULT_CREATE_WAIT_OPTIONS: {
748
813
  poll: boolean;
749
814
  pollInterval: number;
750
815
  };
751
- /** Pagination options for querying predictions */
752
- type PredictionPaginationOptions = PaginationOptions & {
816
+ /** Options for listing predictions. */
817
+ interface PredictionListOptions extends ListOptions {
753
818
  /**
754
819
  * The list of statuses to filter predictions.
755
820
  */
756
821
  statuses?: Status[];
757
- };
822
+ }
758
823
  /**
759
824
  * Resource class for interacting with predictions.
760
825
  */
@@ -770,16 +835,16 @@ declare class PredictionsResource extends Resource {
770
835
  /**
771
836
  * Get a prediction by its ID.
772
837
  * @param id The ID of the prediction to fetch.
773
- * @param signal Optional AbortSignal to cancel the request.
838
+ * @param options Options for the call.
774
839
  * @returns The prediction object.
775
840
  */
776
- get(id: string, signal?: AbortSignal): Promise<PredictionWithDetails>;
841
+ get(id: string, options?: CallOptions): Promise<PredictionWithDetails>;
777
842
  /**
778
843
  * Cancel a prediction by its ID.
779
844
  * @param id The ID of the prediction to cancel.
780
- * @param signal Optional AbortSignal to cancel the request.
845
+ * @param options Options for the call.
781
846
  */
782
- cancel(id: string, signal?: AbortSignal): Promise<void>;
847
+ cancel(id: string, options?: CallOptions): Promise<void>;
783
848
  /**
784
849
  * Recursively uploads FileData instances and
785
850
  * replaces them with download URLs.
@@ -790,10 +855,8 @@ declare class PredictionsResource extends Resource {
790
855
  private fileUploader;
791
856
  /**
792
857
  * Build request headers for a prediction create call.
793
- * @param options Options for prediction creation.
794
- * @param wait Whether the caller is waiting for a terminal state.
795
- * @param waitOptions Options for customizing wait behaviour.
796
- * Only used when wait is true.
858
+ * @param params Parameters for prediction creation.
859
+ * @param waitOptions Wait options, or undefined if not waiting.
797
860
  * @returns The headers to send.
798
861
  */
799
862
  private buildCreateHeaders;
@@ -808,35 +871,29 @@ declare class PredictionsResource extends Resource {
808
871
  * This method creates a prediction using either the latest version of a model
809
872
  * or a specific model version. Files in the input are uploaded concurrently
810
873
  * before the prediction is created.
811
- * @param options Options for prediction creation.
812
- * @param wait If true, waits for the prediction to finish, as configured by
813
- *`waitOptions`. If false, returns the prediction immediately.
814
- * Defaults to false.
815
- * @param waitOptions Optional overrides for wait behavior. Any omitted values
816
- * use {@link DEFAULT_CREATE_WAIT_OPTIONS}.
817
- * @param signal Optional AbortSignal to cancel the request.
874
+ * @param params Parameters for prediction creation.
875
+ * If `wait` is set, the prediction is awaited until it finishes; `true`
876
+ * uses {@link DEFAULT_CREATE_WAIT_OPTIONS} and an object overrides
877
+ * individual values. Otherwise it is returned immediately.
818
878
  * @returns The new prediction.
819
879
  */
820
- create(options: CreatePredictionParams, wait?: boolean, waitOptions?: Partial<CreateWaitOptions>, signal?: AbortSignal): Promise<PredictionWithDetails>;
880
+ create(params: CreatePredictionParams): Promise<PredictionWithDetails>;
821
881
  /**
822
882
  * List predictions.
823
- * @param options Optional settings to control pagination behavior.
824
- * @param signal Optional AbortSignal to cancel the request.
883
+ * @param options Options for listing predictions.
825
884
  * @returns Paginated response containing predictions and navigation metadata.
826
885
  */
827
- list(options?: PredictionPaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<Prediction>>;
886
+ list(options?: PredictionListOptions): Promise<PaginatedResponse<Prediction>>;
828
887
  /**
829
888
  * Waits for a prediction to complete.
830
889
  * This method uses short polling to check the prediction status at
831
890
  * regular intervals until it reaches a terminal state.
832
891
  * @param predictionID The ID of the prediction.
833
- * @param options Optional overrides for wait behavior. Any omitted values
834
- * use {@link DEFAULT_WAIT_OPTIONS}.
835
- * @param signal Optional AbortSignal that can be used to cancel the polling
836
- * operation.
892
+ * @param options Options for waiting. Any omitted values use
893
+ * {@link DEFAULT_WAIT_OPTIONS}.
837
894
  * @returns Prediction after completion.
838
895
  */
839
- wait(predictionID: string, options?: Partial<WaitOptions>, signal?: AbortSignal): Promise<PredictionWithDetails>;
896
+ wait(predictionID: string, options?: Partial<PredictionWaitOptions> & CallOptions): Promise<PredictionWithDetails>;
840
897
  }
841
898
 
842
899
  /**
@@ -855,7 +912,7 @@ type ModelVersionConfiguration = {
855
912
  /**
856
913
  * Parameters for creating a version of a model.
857
914
  */
858
- type CreateModelVersionParams = {
915
+ interface CreateModelVersionParams extends CallOptions {
859
916
  /**
860
917
  * Information about changes such as new features,
861
918
  * bug fixes, or optimizations in this model version.
@@ -879,7 +936,7 @@ type CreateModelVersionParams = {
879
936
  * Omit to inherit configuration from the previous version.
880
937
  */
881
938
  configuration?: ModelVersionConfiguration;
882
- };
939
+ }
883
940
  /**
884
941
  * Error thrown when a model version identifier is not in
885
942
  * owner/name:version-number format.
@@ -894,7 +951,7 @@ declare class InvalidModelVersionIdentifierError extends Error {
894
951
  /**
895
952
  * Parameters for updating the configuration of a model version.
896
953
  */
897
- type UpdateModelVersionConfigurationParams = {
954
+ interface UpdateModelVersionConfigurationParams extends CallOptions {
898
955
  /**
899
956
  * The identifier of the hardware used by the model version.
900
957
  */
@@ -904,7 +961,7 @@ type UpdateModelVersionConfigurationParams = {
904
961
  * Replaces all current variable names.
905
962
  */
906
963
  variable_names?: string[];
907
- };
964
+ }
908
965
  /**
909
966
  * Represents a model version with it's details and configuration.
910
967
  */
@@ -933,58 +990,55 @@ declare class ModelVersions extends Resource {
933
990
  * Get a model version.
934
991
  * @param identifier The model version identifier in owner/name:version-number
935
992
  * format (for example: deepseek-ai/deepseek-r1:2).
936
- * @param signal Optional AbortSignal to cancel the request.
993
+ * @param options Options for the call.
937
994
  * @returns The model version object.
938
995
  */
939
- get(identifier: string, signal?: AbortSignal): Promise<ModelVersionWithDetails>;
996
+ get(identifier: string, options?: CallOptions): Promise<ModelVersionWithDetails>;
940
997
  /**
941
998
  * Create a version of a model.
942
999
  * @param identifier The model identifier in owner/name format
943
1000
  * (for example: deepseek-ai/deepseek-r1).
944
1001
  * @param params Model version creation parameters.
945
- * @param signal Optional AbortSignal to cancel the request.
946
1002
  * @returns The new version object.
947
1003
  */
948
- create(identifier: string, params: CreateModelVersionParams, signal?: AbortSignal): Promise<ModelVersionWithDetailsAndConfiguration>;
1004
+ create(identifier: string, params: CreateModelVersionParams): Promise<ModelVersionWithDetailsAndConfiguration>;
949
1005
  /**
950
1006
  * Delete a model version.
951
1007
  * @param identifier The model version identifier in owner/name:version-number
952
1008
  * format (for example: deepseek-ai/deepseek-r1:2).
953
- * @param signal Optional AbortSignal to cancel the request.
1009
+ * @param options Options for the call.
954
1010
  */
955
- delete(identifier: string, signal?: AbortSignal): Promise<void>;
1011
+ delete(identifier: string, options?: CallOptions): Promise<void>;
956
1012
  /**
957
1013
  * List model versions.
958
1014
  * @param identifier The model identifier in owner/name format
959
1015
  * (for example: deepseek-ai/deepseek-r1).
960
- * @param options Pagination options.
961
- * @param signal Optional AbortSignal to cancel the request.
1016
+ * @param options Options for listing model versions.
962
1017
  * @returns A paginated response containing model versions.
963
1018
  */
964
- list(identifier: string, options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<ModelVersion>>;
1019
+ list(identifier: string, options?: ListOptions): Promise<PaginatedResponse<ModelVersion>>;
965
1020
  /**
966
1021
  * Update the configuration of a model version.
967
1022
  * @param identifier The model version identifier in owner/name:version-number
968
1023
  * format (for example: deepseek-ai/deepseek-r1:1).
969
1024
  * @param params Parameters for updating the configuration.
970
- * @param signal Optional AbortSignal to cancel the request.
971
1025
  * @returns The updated model version configuration.
972
1026
  */
973
- updateConfiguration(identifier: string, params: UpdateModelVersionConfigurationParams, signal?: AbortSignal): Promise<ModelVersionConfiguration>;
1027
+ updateConfiguration(identifier: string, params: UpdateModelVersionConfigurationParams): Promise<ModelVersionConfiguration>;
974
1028
  /**
975
1029
  * Get the configuration of a model version.
976
1030
  * @param identifier The model version identifier in owner/name:version-number
977
1031
  * format (for example: deepseek-ai/deepseek-r1:1).
978
- * @param signal Optional AbortSignal to cancel the request.
1032
+ * @param options Options for the call.
979
1033
  * @returns The model version configuration.
980
1034
  */
981
- getConfiguration(identifier: string, signal?: AbortSignal): Promise<ModelVersionConfiguration>;
1035
+ getConfiguration(identifier: string, options?: CallOptions): Promise<ModelVersionConfiguration>;
982
1036
  }
983
1037
 
984
1038
  /**
985
1039
  * Parameters for updating a model.
986
1040
  */
987
- type UpdateModelParams = {
1041
+ interface UpdateModelParams extends CallOptions {
988
1042
  /**
989
1043
  * The name of the model.
990
1044
  */
@@ -1017,11 +1071,11 @@ type UpdateModelParams = {
1017
1071
  * List of model category slugs.
1018
1072
  */
1019
1073
  category_slugs?: string[];
1020
- };
1074
+ }
1021
1075
  /**
1022
1076
  * Parameters for creating a model.
1023
1077
  */
1024
- type CreateModelParams = {
1078
+ interface CreateModelParams extends CallOptions {
1025
1079
  /**
1026
1080
  * The name of the model.
1027
1081
  */
@@ -1054,7 +1108,7 @@ type CreateModelParams = {
1054
1108
  * List of model category slugs.
1055
1109
  */
1056
1110
  category_slugs?: string[];
1057
- };
1111
+ }
1058
1112
  /**
1059
1113
  * Represents a model with details.
1060
1114
  */
@@ -1087,8 +1141,12 @@ declare enum ModelsSortBy {
1087
1141
  created_at = "created_at",
1088
1142
  predictions_count = "predictions_count"
1089
1143
  }
1090
- /** Pagination options for querying models */
1091
- type ModelPaginationOptions = PaginationOptions & {
1144
+ /** Options for listing models. */
1145
+ interface ModelListOptions extends ListOptions {
1146
+ /**
1147
+ * Name of the model's owner to list models for.
1148
+ */
1149
+ owner?: string;
1092
1150
  /**
1093
1151
  * The sorting criteria
1094
1152
  */
@@ -1101,7 +1159,7 @@ type ModelPaginationOptions = PaginationOptions & {
1101
1159
  * The list of category slugs to filter models.
1102
1160
  */
1103
1161
  category_slugs?: string[];
1104
- };
1162
+ }
1105
1163
  /**
1106
1164
  * Resource for operations related to models.
1107
1165
  */
@@ -1110,24 +1168,23 @@ declare class Models extends Resource {
1110
1168
  * Delete a model.
1111
1169
  * @param identifier The model identifier in owner/name format
1112
1170
  * (for example: deepseek-ai/deepseek-r1).
1113
- * @param signal Optional AbortSignal to cancel the request.
1171
+ * @param options Options for the call.
1114
1172
  */
1115
- delete(identifier: string, signal?: AbortSignal): Promise<void>;
1173
+ delete(identifier: string, options?: CallOptions): Promise<void>;
1116
1174
  /**
1117
1175
  * Create a model.
1118
- * @param options Parameters for creating a model.
1119
- * @param signal Optional AbortSignal to cancel the request.
1176
+ * @param params Parameters for creating a model.
1120
1177
  * @returns The new model.
1121
1178
  */
1122
- create(options: CreateModelParams, signal?: AbortSignal): Promise<ModelWithDetails>;
1179
+ create(params: CreateModelParams): Promise<ModelWithDetails>;
1123
1180
  /**
1124
1181
  * Get a model.
1125
1182
  * @param identifier The model identifier in owner/name format
1126
1183
  * (for example: deepseek-ai/deepseek-r1).
1127
- * @param signal Optional AbortSignal to cancel the request.
1184
+ * @param options Options for the call.
1128
1185
  * @returns A model object.
1129
1186
  */
1130
- get(identifier: string, signal?: AbortSignal): Promise<ModelWithDetails>;
1187
+ get(identifier: string, options?: CallOptions): Promise<ModelWithDetails>;
1131
1188
  /**
1132
1189
  * Constructs the API path for listing models.
1133
1190
  * @param owner - Name of the model's owner to fetch models for.
@@ -1137,30 +1194,26 @@ declare class Models extends Resource {
1137
1194
  private buildListPath;
1138
1195
  /**
1139
1196
  * List models.
1140
- * @param options Optional settings to control pagination behavior.
1141
- * @param owner Optional name of the model's owner to fetch models for.
1142
- * If not passed, all models are fetched.
1143
- * @param signal Optional AbortSignal to cancel the request.
1197
+ * @param options Options for listing models. If no owner is given,
1198
+ * all models are listed.
1144
1199
  * @returns Paginated response containing models and navigation metadata.
1145
1200
  */
1146
- list(options?: ModelPaginationOptions, owner?: string, signal?: AbortSignal): Promise<PaginatedResponse<Model>>;
1201
+ list(options?: ModelListOptions): Promise<PaginatedResponse<Model>>;
1147
1202
  /**
1148
1203
  * Update a model.
1149
1204
  * @param identifier The model identifier in owner/name format
1150
1205
  * (for example: deepseek-ai/deepseek-r1).
1151
- * @param params The fields to update.
1152
- * @param signal Optional AbortSignal to cancel the request.
1206
+ * @param params Parameters for updating the model.
1153
1207
  * @returns The updated model.
1154
1208
  */
1155
- update(identifier: string, params: UpdateModelParams, signal?: AbortSignal): Promise<ModelWithDetails>;
1209
+ update(identifier: string, params: UpdateModelParams): Promise<ModelWithDetails>;
1156
1210
  /**
1157
1211
  * Search models.
1158
1212
  * @param q The search query.
1159
- * @param options Optional settings to control pagination behavior.
1160
- * @param signal Optional AbortSignal to cancel the request.
1213
+ * @param options Options for the search.
1161
1214
  * @returns Paginated response containing models and navigation metadata.
1162
1215
  */
1163
- search(q: string, options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<Model>>;
1216
+ search(q: string, options?: ListOptions): Promise<PaginatedResponse<Model>>;
1164
1217
  }
1165
1218
 
1166
1219
  /**
@@ -1169,8 +1222,8 @@ declare class Models extends Resource {
1169
1222
  declare enum UsersSortBy {
1170
1223
  created_at = "created_at"
1171
1224
  }
1172
- /** Pagination options for querying users */
1173
- type UserPaginationOptions = PaginationOptions & {
1225
+ /** Options for listing users. */
1226
+ interface UserListOptions extends ListOptions {
1174
1227
  /**
1175
1228
  * The sorting criteria
1176
1229
  */
@@ -1179,7 +1232,7 @@ type UserPaginationOptions = PaginationOptions & {
1179
1232
  * The sorting direction
1180
1233
  */
1181
1234
  sort_direction?: SortDirection;
1182
- };
1235
+ }
1183
1236
  /**
1184
1237
  * Resource class for interacting with users.
1185
1238
  */
@@ -1188,25 +1241,23 @@ declare class Users extends Resource {
1188
1241
  /**
1189
1242
  * Fetch a user by their name.
1190
1243
  * @param name The name of the user.
1191
- * @param signal Optional AbortSignal to cancel the request.
1244
+ * @param options Options for the call.
1192
1245
  * @returns The user object.
1193
1246
  */
1194
- get(name: string, signal?: AbortSignal): Promise<UserWithDetails>;
1247
+ get(name: string, options?: CallOptions): Promise<UserWithDetails>;
1195
1248
  /**
1196
1249
  * List users.
1197
- * @param options Optional settings to control pagination behavior.
1198
- * @param signal Optional AbortSignal to cancel the request.
1250
+ * @param options Options for listing users.
1199
1251
  * @returns Paginated response containing users and navigation metadata.
1200
1252
  */
1201
- list(options?: UserPaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<User>>;
1253
+ list(options?: UserListOptions): Promise<PaginatedResponse<User>>;
1202
1254
  /**
1203
1255
  * Search users.
1204
1256
  * @param q The search query.
1205
- * @param options Optional settings to control pagination behavior.
1206
- * @param signal Optional AbortSignal to cancel the request.
1257
+ * @param options Options for the search.
1207
1258
  * @returns Paginated response containing users and navigation metadata.
1208
1259
  */
1209
- search(q: string, options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<User>>;
1260
+ search(q: string, options?: ListOptions): Promise<PaginatedResponse<User>>;
1210
1261
  }
1211
1262
 
1212
1263
  /**
@@ -1236,11 +1287,10 @@ interface Hardware {
1236
1287
  declare class HardwareResource extends Resource {
1237
1288
  /**
1238
1289
  * List hardware.
1239
- * @param options Optional settings to control pagination behavior.
1240
- * @param signal Optional AbortSignal to cancel the request.
1290
+ * @param options Options for listing hardware.
1241
1291
  * @returns Paginated response containing hardware and navigation metadata.
1242
1292
  */
1243
- list(options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<Hardware>>;
1293
+ list(options?: ListOptions): Promise<PaginatedResponse<Hardware>>;
1244
1294
  }
1245
1295
 
1246
1296
  /**
@@ -1258,12 +1308,11 @@ interface ModelCategoryWithDetails extends ModelCategory {
1258
1308
  declare class ModelCategories extends Resource {
1259
1309
  /**
1260
1310
  * List model categories.
1261
- * @param options Optional settings to control pagiantion behavior.
1262
- * @param signal Optional AbortSignal to cancel request.
1311
+ * @param options Options for listing model categories.
1263
1312
  * @returns Paginated response containing model categories and
1264
1313
  * navigation metadata.
1265
1314
  */
1266
- list(options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<ModelCategoryWithDetails>>;
1315
+ list(options?: ListOptions): Promise<PaginatedResponse<ModelCategoryWithDetails>>;
1267
1316
  }
1268
1317
 
1269
1318
  /**
@@ -1299,7 +1348,7 @@ interface Variable {
1299
1348
  /**
1300
1349
  * Parameters for creating a variable.
1301
1350
  */
1302
- type CreateVariableParams = {
1351
+ interface CreateVariableParams extends CallOptions {
1303
1352
  /**
1304
1353
  * The name of the variable.
1305
1354
  */
@@ -1317,11 +1366,11 @@ type CreateVariableParams = {
1317
1366
  * as a secret. The values of secrets are not returned.
1318
1367
  */
1319
1368
  secret: boolean;
1320
- };
1369
+ }
1321
1370
  /**
1322
1371
  * Parameters for updating a variable.
1323
1372
  */
1324
- type UpdateVariableParams = {
1373
+ interface UpdateVariableParams extends CallOptions {
1325
1374
  /**
1326
1375
  * The new value of the variable.
1327
1376
  */
@@ -1330,7 +1379,7 @@ type UpdateVariableParams = {
1330
1379
  * The new key of the variable.
1331
1380
  */
1332
1381
  key?: string;
1333
- };
1382
+ }
1334
1383
  /**
1335
1384
  * Resource for operations related to variables.
1336
1385
  */
@@ -1339,31 +1388,28 @@ declare class Variables extends Resource {
1339
1388
  /**
1340
1389
  * Create a new variable.
1341
1390
  * @param params Parameters for creating the variable.
1342
- * @param signal Optional abort signal.
1343
1391
  * @returns The created variable.
1344
1392
  */
1345
- create(params: CreateVariableParams, signal?: AbortSignal): Promise<Variable>;
1393
+ create(params: CreateVariableParams): Promise<Variable>;
1346
1394
  /**
1347
1395
  * Delete a variable.
1348
1396
  * @param name The name of the variable to be deleted.
1349
- * @param signal Optional abort signal.
1397
+ * @param options Options for the call.
1350
1398
  */
1351
- delete(name: string, signal?: AbortSignal): Promise<void>;
1399
+ delete(name: string, options?: CallOptions): Promise<void>;
1352
1400
  /**
1353
1401
  * Update a variable.
1354
1402
  * @param name The name of the variable to be updated.
1355
1403
  * @param params The parameters for updating the variable.
1356
- * @param signal Optional abort signal.
1357
1404
  * @returns The updated variable.
1358
1405
  */
1359
- update(name: string, params: UpdateVariableParams, signal?: AbortSignal): Promise<Variable>;
1406
+ update(name: string, params: UpdateVariableParams): Promise<Variable>;
1360
1407
  /**
1361
1408
  * List variables.
1362
- * @param options Optional settings to control pagination behavior.
1363
- * @param signal Optional abort signal.
1409
+ * @param options Options for listing variables.
1364
1410
  * @returns Paginated response containing variables and navigation metadata.
1365
1411
  */
1366
- list(options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<Variable>>;
1412
+ list(options?: ListOptions): Promise<PaginatedResponse<Variable>>;
1367
1413
  }
1368
1414
 
1369
1415
  /**
@@ -1407,18 +1453,42 @@ declare class WebhookTimestampOutsideToleranceError extends WebhookSignatureVeri
1407
1453
  */
1408
1454
  constructor();
1409
1455
  }
1456
+ /**
1457
+ * Parameters for verifying a webhook signature.
1458
+ */
1459
+ interface VerifyWebhookParams {
1460
+ /**
1461
+ * Raw webhook request body.
1462
+ */
1463
+ payload: Uint8Array;
1464
+ /**
1465
+ * The signature to verify.
1466
+ */
1467
+ signature: string;
1468
+ /**
1469
+ * The webhook secret.
1470
+ */
1471
+ secret: string;
1472
+ /**
1473
+ * Maximum allowed age of the timestamp in seconds.
1474
+ */
1475
+ tolerance?: number;
1476
+ /**
1477
+ * Key for signatures in the signature.
1478
+ */
1479
+ scheme?: string;
1480
+ /**
1481
+ * Maximum number of HMAC keys to keep in the module-scoped cache.
1482
+ */
1483
+ keyCacheSize?: number;
1484
+ }
1410
1485
  /**
1411
1486
  * Verify webhook signature.
1412
- * @param payload Raw webhook request body.
1413
- * @param signature The signature to verify.
1414
- * @param secret The webhook secret.
1415
- * @param tolerance Maximum allowed age of the timestamp in seconds.
1416
- * Defaults to 300.
1417
- * @param scheme Key for signatures in the signature. Defaults to "v1".
1418
- * @param keyCacheSize Maximum number of HMAC keys to keep in the
1419
- * module-scoped cache. When exceeded, the oldest cached key is evicted.
1420
- * This is a performance optimization only. Defaults to 50. Set to 0 or
1421
- * a negative value to disable caching.
1487
+ * @param params Parameters for verifying the webhook signature.
1488
+ * `tolerance` defaults to 300, `scheme` defaults to "v1" and `keyCacheSize`
1489
+ * defaults to 50. When the cache size is exceeded, the oldest cached key is
1490
+ * evicted. The cache is a performance optimization only, and a size of 0 or
1491
+ * a negative value disables caching.
1422
1492
  * @throws {WebhookNoTimestampError} Error thrown when the timestamp is
1423
1493
  * missing from the signature.
1424
1494
  * @throws {WebhookNoSignatureError} Error thrown when a signature
@@ -1428,12 +1498,12 @@ declare class WebhookTimestampOutsideToleranceError extends WebhookSignatureVeri
1428
1498
  * @throws {WebhookTimestampOutsideToleranceError} Error thrown when the
1429
1499
  * timestamp is outside the tolerance window.
1430
1500
  */
1431
- declare function verify(payload: Uint8Array, signature: string, secret: string, tolerance?: number, scheme?: string, keyCacheSize?: number): Promise<void>;
1501
+ declare function verify(params: VerifyWebhookParams): Promise<void>;
1432
1502
 
1433
1503
  /**
1434
1504
  * Parameters for updating a user.
1435
1505
  */
1436
- type UpdateUserParams = {
1506
+ interface UpdateUserParams extends CallOptions {
1437
1507
  /**
1438
1508
  * The new name of the user.
1439
1509
  */
@@ -1458,7 +1528,7 @@ type UpdateUserParams = {
1458
1528
  * The new location of the user.
1459
1529
  */
1460
1530
  location?: string | null;
1461
- };
1531
+ }
1462
1532
  /**
1463
1533
  * Resource for operations related to the authenticated user.
1464
1534
  */
@@ -1466,24 +1536,22 @@ declare class AuthenticatedUser extends Resource {
1466
1536
  private readonly API_PREFIX;
1467
1537
  /**
1468
1538
  * Get the authenticated user.
1469
- * @param signal - Optional AbortSignal to cancel the request.
1539
+ * @param options - Options for the call.
1470
1540
  * @returns The user object.
1471
1541
  */
1472
- get(signal?: AbortSignal): Promise<UserWithDetails>;
1542
+ get(options?: CallOptions): Promise<UserWithDetails>;
1473
1543
  /**
1474
1544
  * Update the authenticated user.
1475
- * @param params - The fields to update.
1476
- * @param signal - Optional AbortSignal to cancel the request.
1545
+ * @param params - Parameters for updating the user.
1477
1546
  * @returns The updated user object.
1478
1547
  */
1479
- update(params: UpdateUserParams, signal?: AbortSignal): Promise<UserWithDetails>;
1548
+ update(params: UpdateUserParams): Promise<UserWithDetails>;
1480
1549
  /**
1481
1550
  * List models of the authenticated user.
1482
- * @param options - Optional settings to control pagination behavior.
1483
- * @param signal - Optional AbortSignal to cancel the request.
1551
+ * @param options - Options for listing models.
1484
1552
  * @returns A paginated response containing models and navigation metadata.
1485
1553
  */
1486
- models(options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<Model>>;
1554
+ models(options?: ListOptions): Promise<PaginatedResponse<Model>>;
1487
1555
  }
1488
1556
 
1489
1557
  interface WriftAIClientOptions {