wriftai 0.54.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/README.md +6 -8
- package/dist/index.cjs +328 -169
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +249 -142
- package/dist/index.mjs +328 -170
- package/dist/index.mjs.map +1 -1
- package/dist/wriftai.umd.min.js +2 -2
- package/dist/wriftai.umd.min.js.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
624
|
+
* @param options Options for the call.
|
|
564
625
|
* @returns Result of the completed upload.
|
|
565
626
|
*/
|
|
566
|
-
upload(file: FileData,
|
|
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
|
-
|
|
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
|
|
776
|
+
interface PredictionWaitOptions {
|
|
712
777
|
/**
|
|
713
778
|
* Time in milliseconds between polling attempts to check the
|
|
714
779
|
* prediction status.
|
|
@@ -719,19 +784,42 @@ interface WaitOptions {
|
|
|
719
784
|
*/
|
|
720
785
|
onPoll?: (prediction: PredictionWithDetails) => Promise<void>;
|
|
721
786
|
}
|
|
787
|
+
/**
|
|
788
|
+
* Options for customizing wait behaviour when creating a prediction.
|
|
789
|
+
*/
|
|
790
|
+
interface CreatePredictionWaitOptions extends PredictionWaitOptions {
|
|
791
|
+
/**
|
|
792
|
+
* Max seconds the server holds the connection open while waiting
|
|
793
|
+
* for the prediction to finish. If not set, the server's default is used.
|
|
794
|
+
*/
|
|
795
|
+
duration?: number;
|
|
796
|
+
/**
|
|
797
|
+
* If the prediction isn't finished when the server responds, keep
|
|
798
|
+
* polling until it reaches a terminal state. If false, return it as is,
|
|
799
|
+
* which may not be terminal.
|
|
800
|
+
*/
|
|
801
|
+
poll: boolean;
|
|
802
|
+
}
|
|
722
803
|
/**
|
|
723
804
|
* Default wait options.
|
|
724
805
|
*/
|
|
725
806
|
declare const DEFAULT_WAIT_OPTIONS: {
|
|
726
807
|
pollInterval: number;
|
|
727
808
|
};
|
|
728
|
-
/**
|
|
729
|
-
|
|
809
|
+
/**
|
|
810
|
+
* Default wait options for prediction creation.
|
|
811
|
+
*/
|
|
812
|
+
declare const DEFAULT_CREATE_WAIT_OPTIONS: {
|
|
813
|
+
poll: boolean;
|
|
814
|
+
pollInterval: number;
|
|
815
|
+
};
|
|
816
|
+
/** Options for listing predictions. */
|
|
817
|
+
interface PredictionListOptions extends ListOptions {
|
|
730
818
|
/**
|
|
731
819
|
* The list of statuses to filter predictions.
|
|
732
820
|
*/
|
|
733
821
|
statuses?: Status[];
|
|
734
|
-
}
|
|
822
|
+
}
|
|
735
823
|
/**
|
|
736
824
|
* Resource class for interacting with predictions.
|
|
737
825
|
*/
|
|
@@ -747,16 +835,16 @@ declare class PredictionsResource extends Resource {
|
|
|
747
835
|
/**
|
|
748
836
|
* Get a prediction by its ID.
|
|
749
837
|
* @param id The ID of the prediction to fetch.
|
|
750
|
-
* @param
|
|
838
|
+
* @param options Options for the call.
|
|
751
839
|
* @returns The prediction object.
|
|
752
840
|
*/
|
|
753
|
-
get(id: string,
|
|
841
|
+
get(id: string, options?: CallOptions): Promise<PredictionWithDetails>;
|
|
754
842
|
/**
|
|
755
843
|
* Cancel a prediction by its ID.
|
|
756
844
|
* @param id The ID of the prediction to cancel.
|
|
757
|
-
* @param
|
|
845
|
+
* @param options Options for the call.
|
|
758
846
|
*/
|
|
759
|
-
cancel(id: string,
|
|
847
|
+
cancel(id: string, options?: CallOptions): Promise<void>;
|
|
760
848
|
/**
|
|
761
849
|
* Recursively uploads FileData instances and
|
|
762
850
|
* replaces them with download URLs.
|
|
@@ -765,39 +853,47 @@ declare class PredictionsResource extends Resource {
|
|
|
765
853
|
* @returns The rebuilt input with files replaced by download URLs.
|
|
766
854
|
*/
|
|
767
855
|
private fileUploader;
|
|
856
|
+
/**
|
|
857
|
+
* Build request headers for a prediction create call.
|
|
858
|
+
* @param params Parameters for prediction creation.
|
|
859
|
+
* @param waitOptions Wait options, or undefined if not waiting.
|
|
860
|
+
* @returns The headers to send.
|
|
861
|
+
*/
|
|
862
|
+
private buildCreateHeaders;
|
|
863
|
+
/**
|
|
864
|
+
* Determines whether a prediction status is terminal.
|
|
865
|
+
* @param status The current prediction status.
|
|
866
|
+
* @returns whether the status is terminal.
|
|
867
|
+
*/
|
|
868
|
+
private static isStatusTerminal;
|
|
768
869
|
/**
|
|
769
870
|
* Create a prediction.
|
|
770
871
|
* This method creates a prediction using either the latest version of a model
|
|
771
872
|
* or a specific model version. Files in the input are uploaded concurrently
|
|
772
873
|
* before the prediction is created.
|
|
773
|
-
* @param
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
* {@link DEFAULT_WAIT_OPTIONS} are used.
|
|
778
|
-
* @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.
|
|
779
878
|
* @returns The new prediction.
|
|
780
879
|
*/
|
|
781
|
-
create(
|
|
880
|
+
create(params: CreatePredictionParams): Promise<PredictionWithDetails>;
|
|
782
881
|
/**
|
|
783
882
|
* List predictions.
|
|
784
|
-
* @param options
|
|
785
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
883
|
+
* @param options Options for listing predictions.
|
|
786
884
|
* @returns Paginated response containing predictions and navigation metadata.
|
|
787
885
|
*/
|
|
788
|
-
list(options?:
|
|
886
|
+
list(options?: PredictionListOptions): Promise<PaginatedResponse<Prediction>>;
|
|
789
887
|
/**
|
|
790
888
|
* Waits for a prediction to complete.
|
|
791
889
|
* This method uses short polling to check the prediction status at
|
|
792
890
|
* regular intervals until it reaches a terminal state.
|
|
793
891
|
* @param predictionID The ID of the prediction.
|
|
794
|
-
* @param options Options for
|
|
795
|
-
* {@link DEFAULT_WAIT_OPTIONS}
|
|
796
|
-
* @param signal Optional AbortSignal that can be used to cancel the polling
|
|
797
|
-
* operation.
|
|
892
|
+
* @param options Options for waiting. Any omitted values use
|
|
893
|
+
* {@link DEFAULT_WAIT_OPTIONS}.
|
|
798
894
|
* @returns Prediction after completion.
|
|
799
895
|
*/
|
|
800
|
-
wait(predictionID: string, options?:
|
|
896
|
+
wait(predictionID: string, options?: Partial<PredictionWaitOptions> & CallOptions): Promise<PredictionWithDetails>;
|
|
801
897
|
}
|
|
802
898
|
|
|
803
899
|
/**
|
|
@@ -816,7 +912,7 @@ type ModelVersionConfiguration = {
|
|
|
816
912
|
/**
|
|
817
913
|
* Parameters for creating a version of a model.
|
|
818
914
|
*/
|
|
819
|
-
|
|
915
|
+
interface CreateModelVersionParams extends CallOptions {
|
|
820
916
|
/**
|
|
821
917
|
* Information about changes such as new features,
|
|
822
918
|
* bug fixes, or optimizations in this model version.
|
|
@@ -840,7 +936,7 @@ type CreateModelVersionParams = {
|
|
|
840
936
|
* Omit to inherit configuration from the previous version.
|
|
841
937
|
*/
|
|
842
938
|
configuration?: ModelVersionConfiguration;
|
|
843
|
-
}
|
|
939
|
+
}
|
|
844
940
|
/**
|
|
845
941
|
* Error thrown when a model version identifier is not in
|
|
846
942
|
* owner/name:version-number format.
|
|
@@ -855,7 +951,7 @@ declare class InvalidModelVersionIdentifierError extends Error {
|
|
|
855
951
|
/**
|
|
856
952
|
* Parameters for updating the configuration of a model version.
|
|
857
953
|
*/
|
|
858
|
-
|
|
954
|
+
interface UpdateModelVersionConfigurationParams extends CallOptions {
|
|
859
955
|
/**
|
|
860
956
|
* The identifier of the hardware used by the model version.
|
|
861
957
|
*/
|
|
@@ -865,7 +961,7 @@ type UpdateModelVersionConfigurationParams = {
|
|
|
865
961
|
* Replaces all current variable names.
|
|
866
962
|
*/
|
|
867
963
|
variable_names?: string[];
|
|
868
|
-
}
|
|
964
|
+
}
|
|
869
965
|
/**
|
|
870
966
|
* Represents a model version with it's details and configuration.
|
|
871
967
|
*/
|
|
@@ -894,58 +990,55 @@ declare class ModelVersions extends Resource {
|
|
|
894
990
|
* Get a model version.
|
|
895
991
|
* @param identifier The model version identifier in owner/name:version-number
|
|
896
992
|
* format (for example: deepseek-ai/deepseek-r1:2).
|
|
897
|
-
* @param
|
|
993
|
+
* @param options Options for the call.
|
|
898
994
|
* @returns The model version object.
|
|
899
995
|
*/
|
|
900
|
-
get(identifier: string,
|
|
996
|
+
get(identifier: string, options?: CallOptions): Promise<ModelVersionWithDetails>;
|
|
901
997
|
/**
|
|
902
998
|
* Create a version of a model.
|
|
903
999
|
* @param identifier The model identifier in owner/name format
|
|
904
1000
|
* (for example: deepseek-ai/deepseek-r1).
|
|
905
1001
|
* @param params Model version creation parameters.
|
|
906
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
907
1002
|
* @returns The new version object.
|
|
908
1003
|
*/
|
|
909
|
-
create(identifier: string, params: CreateModelVersionParams
|
|
1004
|
+
create(identifier: string, params: CreateModelVersionParams): Promise<ModelVersionWithDetailsAndConfiguration>;
|
|
910
1005
|
/**
|
|
911
1006
|
* Delete a model version.
|
|
912
1007
|
* @param identifier The model version identifier in owner/name:version-number
|
|
913
1008
|
* format (for example: deepseek-ai/deepseek-r1:2).
|
|
914
|
-
* @param
|
|
1009
|
+
* @param options Options for the call.
|
|
915
1010
|
*/
|
|
916
|
-
delete(identifier: string,
|
|
1011
|
+
delete(identifier: string, options?: CallOptions): Promise<void>;
|
|
917
1012
|
/**
|
|
918
1013
|
* List model versions.
|
|
919
1014
|
* @param identifier The model identifier in owner/name format
|
|
920
1015
|
* (for example: deepseek-ai/deepseek-r1).
|
|
921
|
-
* @param options
|
|
922
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1016
|
+
* @param options Options for listing model versions.
|
|
923
1017
|
* @returns A paginated response containing model versions.
|
|
924
1018
|
*/
|
|
925
|
-
list(identifier: string, options?:
|
|
1019
|
+
list(identifier: string, options?: ListOptions): Promise<PaginatedResponse<ModelVersion>>;
|
|
926
1020
|
/**
|
|
927
1021
|
* Update the configuration of a model version.
|
|
928
1022
|
* @param identifier The model version identifier in owner/name:version-number
|
|
929
1023
|
* format (for example: deepseek-ai/deepseek-r1:1).
|
|
930
1024
|
* @param params Parameters for updating the configuration.
|
|
931
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
932
1025
|
* @returns The updated model version configuration.
|
|
933
1026
|
*/
|
|
934
|
-
updateConfiguration(identifier: string, params: UpdateModelVersionConfigurationParams
|
|
1027
|
+
updateConfiguration(identifier: string, params: UpdateModelVersionConfigurationParams): Promise<ModelVersionConfiguration>;
|
|
935
1028
|
/**
|
|
936
1029
|
* Get the configuration of a model version.
|
|
937
1030
|
* @param identifier The model version identifier in owner/name:version-number
|
|
938
1031
|
* format (for example: deepseek-ai/deepseek-r1:1).
|
|
939
|
-
* @param
|
|
1032
|
+
* @param options Options for the call.
|
|
940
1033
|
* @returns The model version configuration.
|
|
941
1034
|
*/
|
|
942
|
-
getConfiguration(identifier: string,
|
|
1035
|
+
getConfiguration(identifier: string, options?: CallOptions): Promise<ModelVersionConfiguration>;
|
|
943
1036
|
}
|
|
944
1037
|
|
|
945
1038
|
/**
|
|
946
1039
|
* Parameters for updating a model.
|
|
947
1040
|
*/
|
|
948
|
-
|
|
1041
|
+
interface UpdateModelParams extends CallOptions {
|
|
949
1042
|
/**
|
|
950
1043
|
* The name of the model.
|
|
951
1044
|
*/
|
|
@@ -978,11 +1071,11 @@ type UpdateModelParams = {
|
|
|
978
1071
|
* List of model category slugs.
|
|
979
1072
|
*/
|
|
980
1073
|
category_slugs?: string[];
|
|
981
|
-
}
|
|
1074
|
+
}
|
|
982
1075
|
/**
|
|
983
1076
|
* Parameters for creating a model.
|
|
984
1077
|
*/
|
|
985
|
-
|
|
1078
|
+
interface CreateModelParams extends CallOptions {
|
|
986
1079
|
/**
|
|
987
1080
|
* The name of the model.
|
|
988
1081
|
*/
|
|
@@ -1015,7 +1108,7 @@ type CreateModelParams = {
|
|
|
1015
1108
|
* List of model category slugs.
|
|
1016
1109
|
*/
|
|
1017
1110
|
category_slugs?: string[];
|
|
1018
|
-
}
|
|
1111
|
+
}
|
|
1019
1112
|
/**
|
|
1020
1113
|
* Represents a model with details.
|
|
1021
1114
|
*/
|
|
@@ -1048,8 +1141,12 @@ declare enum ModelsSortBy {
|
|
|
1048
1141
|
created_at = "created_at",
|
|
1049
1142
|
predictions_count = "predictions_count"
|
|
1050
1143
|
}
|
|
1051
|
-
/**
|
|
1052
|
-
|
|
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;
|
|
1053
1150
|
/**
|
|
1054
1151
|
* The sorting criteria
|
|
1055
1152
|
*/
|
|
@@ -1062,7 +1159,7 @@ type ModelPaginationOptions = PaginationOptions & {
|
|
|
1062
1159
|
* The list of category slugs to filter models.
|
|
1063
1160
|
*/
|
|
1064
1161
|
category_slugs?: string[];
|
|
1065
|
-
}
|
|
1162
|
+
}
|
|
1066
1163
|
/**
|
|
1067
1164
|
* Resource for operations related to models.
|
|
1068
1165
|
*/
|
|
@@ -1071,24 +1168,23 @@ declare class Models extends Resource {
|
|
|
1071
1168
|
* Delete a model.
|
|
1072
1169
|
* @param identifier The model identifier in owner/name format
|
|
1073
1170
|
* (for example: deepseek-ai/deepseek-r1).
|
|
1074
|
-
* @param
|
|
1171
|
+
* @param options Options for the call.
|
|
1075
1172
|
*/
|
|
1076
|
-
delete(identifier: string,
|
|
1173
|
+
delete(identifier: string, options?: CallOptions): Promise<void>;
|
|
1077
1174
|
/**
|
|
1078
1175
|
* Create a model.
|
|
1079
|
-
* @param
|
|
1080
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1176
|
+
* @param params Parameters for creating a model.
|
|
1081
1177
|
* @returns The new model.
|
|
1082
1178
|
*/
|
|
1083
|
-
create(
|
|
1179
|
+
create(params: CreateModelParams): Promise<ModelWithDetails>;
|
|
1084
1180
|
/**
|
|
1085
1181
|
* Get a model.
|
|
1086
1182
|
* @param identifier The model identifier in owner/name format
|
|
1087
1183
|
* (for example: deepseek-ai/deepseek-r1).
|
|
1088
|
-
* @param
|
|
1184
|
+
* @param options Options for the call.
|
|
1089
1185
|
* @returns A model object.
|
|
1090
1186
|
*/
|
|
1091
|
-
get(identifier: string,
|
|
1187
|
+
get(identifier: string, options?: CallOptions): Promise<ModelWithDetails>;
|
|
1092
1188
|
/**
|
|
1093
1189
|
* Constructs the API path for listing models.
|
|
1094
1190
|
* @param owner - Name of the model's owner to fetch models for.
|
|
@@ -1098,30 +1194,26 @@ declare class Models extends Resource {
|
|
|
1098
1194
|
private buildListPath;
|
|
1099
1195
|
/**
|
|
1100
1196
|
* List models.
|
|
1101
|
-
* @param options
|
|
1102
|
-
*
|
|
1103
|
-
* If not passed, all models are fetched.
|
|
1104
|
-
* @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.
|
|
1105
1199
|
* @returns Paginated response containing models and navigation metadata.
|
|
1106
1200
|
*/
|
|
1107
|
-
list(options?:
|
|
1201
|
+
list(options?: ModelListOptions): Promise<PaginatedResponse<Model>>;
|
|
1108
1202
|
/**
|
|
1109
1203
|
* Update a model.
|
|
1110
1204
|
* @param identifier The model identifier in owner/name format
|
|
1111
1205
|
* (for example: deepseek-ai/deepseek-r1).
|
|
1112
|
-
* @param params
|
|
1113
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1206
|
+
* @param params Parameters for updating the model.
|
|
1114
1207
|
* @returns The updated model.
|
|
1115
1208
|
*/
|
|
1116
|
-
update(identifier: string, params: UpdateModelParams
|
|
1209
|
+
update(identifier: string, params: UpdateModelParams): Promise<ModelWithDetails>;
|
|
1117
1210
|
/**
|
|
1118
1211
|
* Search models.
|
|
1119
1212
|
* @param q The search query.
|
|
1120
|
-
* @param options
|
|
1121
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1213
|
+
* @param options Options for the search.
|
|
1122
1214
|
* @returns Paginated response containing models and navigation metadata.
|
|
1123
1215
|
*/
|
|
1124
|
-
search(q: string, options?:
|
|
1216
|
+
search(q: string, options?: ListOptions): Promise<PaginatedResponse<Model>>;
|
|
1125
1217
|
}
|
|
1126
1218
|
|
|
1127
1219
|
/**
|
|
@@ -1130,8 +1222,8 @@ declare class Models extends Resource {
|
|
|
1130
1222
|
declare enum UsersSortBy {
|
|
1131
1223
|
created_at = "created_at"
|
|
1132
1224
|
}
|
|
1133
|
-
/**
|
|
1134
|
-
|
|
1225
|
+
/** Options for listing users. */
|
|
1226
|
+
interface UserListOptions extends ListOptions {
|
|
1135
1227
|
/**
|
|
1136
1228
|
* The sorting criteria
|
|
1137
1229
|
*/
|
|
@@ -1140,7 +1232,7 @@ type UserPaginationOptions = PaginationOptions & {
|
|
|
1140
1232
|
* The sorting direction
|
|
1141
1233
|
*/
|
|
1142
1234
|
sort_direction?: SortDirection;
|
|
1143
|
-
}
|
|
1235
|
+
}
|
|
1144
1236
|
/**
|
|
1145
1237
|
* Resource class for interacting with users.
|
|
1146
1238
|
*/
|
|
@@ -1149,25 +1241,23 @@ declare class Users extends Resource {
|
|
|
1149
1241
|
/**
|
|
1150
1242
|
* Fetch a user by their name.
|
|
1151
1243
|
* @param name The name of the user.
|
|
1152
|
-
* @param
|
|
1244
|
+
* @param options Options for the call.
|
|
1153
1245
|
* @returns The user object.
|
|
1154
1246
|
*/
|
|
1155
|
-
get(name: string,
|
|
1247
|
+
get(name: string, options?: CallOptions): Promise<UserWithDetails>;
|
|
1156
1248
|
/**
|
|
1157
1249
|
* List users.
|
|
1158
|
-
* @param options
|
|
1159
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1250
|
+
* @param options Options for listing users.
|
|
1160
1251
|
* @returns Paginated response containing users and navigation metadata.
|
|
1161
1252
|
*/
|
|
1162
|
-
list(options?:
|
|
1253
|
+
list(options?: UserListOptions): Promise<PaginatedResponse<User>>;
|
|
1163
1254
|
/**
|
|
1164
1255
|
* Search users.
|
|
1165
1256
|
* @param q The search query.
|
|
1166
|
-
* @param options
|
|
1167
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1257
|
+
* @param options Options for the search.
|
|
1168
1258
|
* @returns Paginated response containing users and navigation metadata.
|
|
1169
1259
|
*/
|
|
1170
|
-
search(q: string, options?:
|
|
1260
|
+
search(q: string, options?: ListOptions): Promise<PaginatedResponse<User>>;
|
|
1171
1261
|
}
|
|
1172
1262
|
|
|
1173
1263
|
/**
|
|
@@ -1197,11 +1287,10 @@ interface Hardware {
|
|
|
1197
1287
|
declare class HardwareResource extends Resource {
|
|
1198
1288
|
/**
|
|
1199
1289
|
* List hardware.
|
|
1200
|
-
* @param options
|
|
1201
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1290
|
+
* @param options Options for listing hardware.
|
|
1202
1291
|
* @returns Paginated response containing hardware and navigation metadata.
|
|
1203
1292
|
*/
|
|
1204
|
-
list(options?:
|
|
1293
|
+
list(options?: ListOptions): Promise<PaginatedResponse<Hardware>>;
|
|
1205
1294
|
}
|
|
1206
1295
|
|
|
1207
1296
|
/**
|
|
@@ -1219,12 +1308,11 @@ interface ModelCategoryWithDetails extends ModelCategory {
|
|
|
1219
1308
|
declare class ModelCategories extends Resource {
|
|
1220
1309
|
/**
|
|
1221
1310
|
* List model categories.
|
|
1222
|
-
* @param options
|
|
1223
|
-
* @param signal Optional AbortSignal to cancel request.
|
|
1311
|
+
* @param options Options for listing model categories.
|
|
1224
1312
|
* @returns Paginated response containing model categories and
|
|
1225
1313
|
* navigation metadata.
|
|
1226
1314
|
*/
|
|
1227
|
-
list(options?:
|
|
1315
|
+
list(options?: ListOptions): Promise<PaginatedResponse<ModelCategoryWithDetails>>;
|
|
1228
1316
|
}
|
|
1229
1317
|
|
|
1230
1318
|
/**
|
|
@@ -1260,7 +1348,7 @@ interface Variable {
|
|
|
1260
1348
|
/**
|
|
1261
1349
|
* Parameters for creating a variable.
|
|
1262
1350
|
*/
|
|
1263
|
-
|
|
1351
|
+
interface CreateVariableParams extends CallOptions {
|
|
1264
1352
|
/**
|
|
1265
1353
|
* The name of the variable.
|
|
1266
1354
|
*/
|
|
@@ -1278,11 +1366,11 @@ type CreateVariableParams = {
|
|
|
1278
1366
|
* as a secret. The values of secrets are not returned.
|
|
1279
1367
|
*/
|
|
1280
1368
|
secret: boolean;
|
|
1281
|
-
}
|
|
1369
|
+
}
|
|
1282
1370
|
/**
|
|
1283
1371
|
* Parameters for updating a variable.
|
|
1284
1372
|
*/
|
|
1285
|
-
|
|
1373
|
+
interface UpdateVariableParams extends CallOptions {
|
|
1286
1374
|
/**
|
|
1287
1375
|
* The new value of the variable.
|
|
1288
1376
|
*/
|
|
@@ -1291,7 +1379,7 @@ type UpdateVariableParams = {
|
|
|
1291
1379
|
* The new key of the variable.
|
|
1292
1380
|
*/
|
|
1293
1381
|
key?: string;
|
|
1294
|
-
}
|
|
1382
|
+
}
|
|
1295
1383
|
/**
|
|
1296
1384
|
* Resource for operations related to variables.
|
|
1297
1385
|
*/
|
|
@@ -1300,31 +1388,28 @@ declare class Variables extends Resource {
|
|
|
1300
1388
|
/**
|
|
1301
1389
|
* Create a new variable.
|
|
1302
1390
|
* @param params Parameters for creating the variable.
|
|
1303
|
-
* @param signal Optional abort signal.
|
|
1304
1391
|
* @returns The created variable.
|
|
1305
1392
|
*/
|
|
1306
|
-
create(params: CreateVariableParams
|
|
1393
|
+
create(params: CreateVariableParams): Promise<Variable>;
|
|
1307
1394
|
/**
|
|
1308
1395
|
* Delete a variable.
|
|
1309
1396
|
* @param name The name of the variable to be deleted.
|
|
1310
|
-
* @param
|
|
1397
|
+
* @param options Options for the call.
|
|
1311
1398
|
*/
|
|
1312
|
-
delete(name: string,
|
|
1399
|
+
delete(name: string, options?: CallOptions): Promise<void>;
|
|
1313
1400
|
/**
|
|
1314
1401
|
* Update a variable.
|
|
1315
1402
|
* @param name The name of the variable to be updated.
|
|
1316
1403
|
* @param params The parameters for updating the variable.
|
|
1317
|
-
* @param signal Optional abort signal.
|
|
1318
1404
|
* @returns The updated variable.
|
|
1319
1405
|
*/
|
|
1320
|
-
update(name: string, params: UpdateVariableParams
|
|
1406
|
+
update(name: string, params: UpdateVariableParams): Promise<Variable>;
|
|
1321
1407
|
/**
|
|
1322
1408
|
* List variables.
|
|
1323
|
-
* @param options
|
|
1324
|
-
* @param signal Optional abort signal.
|
|
1409
|
+
* @param options Options for listing variables.
|
|
1325
1410
|
* @returns Paginated response containing variables and navigation metadata.
|
|
1326
1411
|
*/
|
|
1327
|
-
list(options?:
|
|
1412
|
+
list(options?: ListOptions): Promise<PaginatedResponse<Variable>>;
|
|
1328
1413
|
}
|
|
1329
1414
|
|
|
1330
1415
|
/**
|
|
@@ -1368,18 +1453,42 @@ declare class WebhookTimestampOutsideToleranceError extends WebhookSignatureVeri
|
|
|
1368
1453
|
*/
|
|
1369
1454
|
constructor();
|
|
1370
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
|
+
}
|
|
1371
1485
|
/**
|
|
1372
1486
|
* Verify webhook signature.
|
|
1373
|
-
* @param
|
|
1374
|
-
*
|
|
1375
|
-
*
|
|
1376
|
-
*
|
|
1377
|
-
*
|
|
1378
|
-
* @param scheme Key for signatures in the signature. Defaults to "v1".
|
|
1379
|
-
* @param keyCacheSize Maximum number of HMAC keys to keep in the
|
|
1380
|
-
* module-scoped cache. When exceeded, the oldest cached key is evicted.
|
|
1381
|
-
* This is a performance optimization only. Defaults to 50. Set to 0 or
|
|
1382
|
-
* 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.
|
|
1383
1492
|
* @throws {WebhookNoTimestampError} Error thrown when the timestamp is
|
|
1384
1493
|
* missing from the signature.
|
|
1385
1494
|
* @throws {WebhookNoSignatureError} Error thrown when a signature
|
|
@@ -1389,12 +1498,12 @@ declare class WebhookTimestampOutsideToleranceError extends WebhookSignatureVeri
|
|
|
1389
1498
|
* @throws {WebhookTimestampOutsideToleranceError} Error thrown when the
|
|
1390
1499
|
* timestamp is outside the tolerance window.
|
|
1391
1500
|
*/
|
|
1392
|
-
declare function verify(
|
|
1501
|
+
declare function verify(params: VerifyWebhookParams): Promise<void>;
|
|
1393
1502
|
|
|
1394
1503
|
/**
|
|
1395
1504
|
* Parameters for updating a user.
|
|
1396
1505
|
*/
|
|
1397
|
-
|
|
1506
|
+
interface UpdateUserParams extends CallOptions {
|
|
1398
1507
|
/**
|
|
1399
1508
|
* The new name of the user.
|
|
1400
1509
|
*/
|
|
@@ -1419,7 +1528,7 @@ type UpdateUserParams = {
|
|
|
1419
1528
|
* The new location of the user.
|
|
1420
1529
|
*/
|
|
1421
1530
|
location?: string | null;
|
|
1422
|
-
}
|
|
1531
|
+
}
|
|
1423
1532
|
/**
|
|
1424
1533
|
* Resource for operations related to the authenticated user.
|
|
1425
1534
|
*/
|
|
@@ -1427,24 +1536,22 @@ declare class AuthenticatedUser extends Resource {
|
|
|
1427
1536
|
private readonly API_PREFIX;
|
|
1428
1537
|
/**
|
|
1429
1538
|
* Get the authenticated user.
|
|
1430
|
-
* @param
|
|
1539
|
+
* @param options - Options for the call.
|
|
1431
1540
|
* @returns The user object.
|
|
1432
1541
|
*/
|
|
1433
|
-
get(
|
|
1542
|
+
get(options?: CallOptions): Promise<UserWithDetails>;
|
|
1434
1543
|
/**
|
|
1435
1544
|
* Update the authenticated user.
|
|
1436
|
-
* @param params -
|
|
1437
|
-
* @param signal - Optional AbortSignal to cancel the request.
|
|
1545
|
+
* @param params - Parameters for updating the user.
|
|
1438
1546
|
* @returns The updated user object.
|
|
1439
1547
|
*/
|
|
1440
|
-
update(params: UpdateUserParams
|
|
1548
|
+
update(params: UpdateUserParams): Promise<UserWithDetails>;
|
|
1441
1549
|
/**
|
|
1442
1550
|
* List models of the authenticated user.
|
|
1443
|
-
* @param options -
|
|
1444
|
-
* @param signal - Optional AbortSignal to cancel the request.
|
|
1551
|
+
* @param options - Options for listing models.
|
|
1445
1552
|
* @returns A paginated response containing models and navigation metadata.
|
|
1446
1553
|
*/
|
|
1447
|
-
models(options?:
|
|
1554
|
+
models(options?: ListOptions): Promise<PaginatedResponse<Model>>;
|
|
1448
1555
|
}
|
|
1449
1556
|
|
|
1450
1557
|
interface WriftAIClientOptions {
|
|
@@ -1542,5 +1649,5 @@ declare class WriftAI {
|
|
|
1542
1649
|
constructor(options?: WriftAIClientOptions);
|
|
1543
1650
|
}
|
|
1544
1651
|
|
|
1545
|
-
export { DEFAULT_WAIT_OPTIONS, ErrorSource, FileData, InvalidIdentifierError, InvalidModelIdentifierError, InvalidModelVersionIdentifierError, ModelVisibility, ModelsSortBy, SortDirection, Status, UsersSortBy, WebhookNoSignatureError, WebhookNoTimestampError, WebhookSignatureMismatchError, WebhookSignatureVerificationError, WebhookTimestampOutsideToleranceError, WriftAI, WriftAIAPIError, verify as verifyWebhook };
|
|
1652
|
+
export { DEFAULT_CREATE_WAIT_OPTIONS, DEFAULT_WAIT_OPTIONS, ErrorSource, FileData, InvalidIdentifierError, InvalidModelIdentifierError, InvalidModelVersionIdentifierError, ModelVisibility, ModelsSortBy, SortDirection, Status, UsersSortBy, WebhookNoSignatureError, WebhookNoTimestampError, WebhookSignatureMismatchError, WebhookSignatureVerificationError, WebhookTimestampOutsideToleranceError, WriftAI, WriftAIAPIError, verify as verifyWebhook };
|
|
1546
1653
|
export type { BaseUser, Compatibilities, Hardware, Model, ModelCategory, ModelCategoryWithDetails, ModelVersion, ModelVersionConfiguration, ModelVersionWithDetails, ModelVersionWithDetailsAndConfiguration, ModelWithDetails, PaginatedResponse, Prediction, PredictionModel, PredictionWithDetails, SchemaIO, Schemas, TaskError, Upload, UploadCompletionResult, User, UserWithDetails, Variable, WriftAIClientOptions };
|