wriftai 0.48.0 → 0.50.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
@@ -13,6 +13,10 @@ type SchemaIO = {
13
13
  * Schema for output, following JSON Schema Draft 2020-12 standards.
14
14
  */
15
15
  output: Record<string, JsonValue>;
16
+ /**
17
+ * Schema for streaming output, following JSON Schema Draft 2020-12 standards.
18
+ */
19
+ stream_output?: Record<string, JsonValue>;
16
20
  };
17
21
  /**
18
22
  * Represents schemas of a model version.
@@ -153,15 +157,6 @@ declare enum ModelVisibility {
153
157
  public = "public",
154
158
  restricted = "restricted"
155
159
  }
156
- /**
157
- * Represents a hardware item.
158
- */
159
- interface Hardware {
160
- /** The name of the hardware. */
161
- name: string;
162
- /** The identifier of the hardware. */
163
- identifier: string;
164
- }
165
160
  /**
166
161
  * Represents a model.
167
162
  */
@@ -194,10 +189,6 @@ interface Model {
194
189
  * The details of the owner of the model.
195
190
  */
196
191
  owner: BaseUser;
197
- /**
198
- * The hardware used by the model.
199
- */
200
- hardware: Hardware;
201
192
  /**
202
193
  * The total number of predictions created across all versions of the model.
203
194
  */
@@ -222,10 +213,6 @@ interface PaginatedResponse<T> {
222
213
  next_cursor: string | null;
223
214
  /** Cursor pointing to the previous page */
224
215
  previous_cursor: string | null;
225
- /** URL to fetch the next page */
226
- next_url: string | null;
227
- /** URL to fetch the previous page */
228
- previous_url: string | null;
229
216
  }
230
217
  /**
231
218
  * Enumeration of possible sorting options.
@@ -247,6 +234,16 @@ interface ModelCategory {
247
234
  */
248
235
  slug: string;
249
236
  }
237
+ /**
238
+ * Represents the result of a completed upload.
239
+ */
240
+ interface UploadCompletionResult {
241
+ /**
242
+ * A time-limited signed URL for downloading the file.
243
+ * No additional authentication is required.
244
+ */
245
+ download_url: string;
246
+ }
250
247
 
251
248
  /**
252
249
  * Representation of an error from WriftAI's API.
@@ -265,6 +262,7 @@ declare class WriftAIAPIError extends Error {
265
262
  }
266
263
  /**
267
264
  * Client for WriftAI's API.
265
+ * @internal
268
266
  */
269
267
  declare class API {
270
268
  private baseUrl;
@@ -414,6 +412,7 @@ declare enum ErrorSource {
414
412
  */
415
413
  declare enum Status {
416
414
  pending = "pending",
415
+ starting = "starting",
417
416
  started = "started",
418
417
  failed = "failed",
419
418
  succeeded = "succeeded",
@@ -479,9 +478,9 @@ interface Prediction {
479
478
  model: PredictionModel;
480
479
  }
481
480
  /**
482
- * Represents a prediction with I/O details.
481
+ * Represents a prediction with details.
483
482
  */
484
- interface PredictionWithIO extends Prediction {
483
+ interface PredictionWithDetails extends Prediction {
485
484
  /**
486
485
  * Input data provided for the prediction.
487
486
  */
@@ -494,6 +493,10 @@ interface PredictionWithIO extends Prediction {
494
493
  * Error details if the prediction failed.
495
494
  */
496
495
  error: TaskError | null;
496
+ /**
497
+ * Usage metrics returned by the model.
498
+ */
499
+ metrics: Record<string, JsonValue> | null;
497
500
  }
498
501
  /**
499
502
  * Represents webhook details.
@@ -542,7 +545,7 @@ interface WaitOptions {
542
545
  /**
543
546
  * Optional callback that receives the latest prediction after each poll.
544
547
  */
545
- onPoll?: (prediction: PredictionWithIO) => Promise<void>;
548
+ onPoll?: (prediction: PredictionWithDetails) => Promise<void>;
546
549
  }
547
550
  /**
548
551
  * Default wait options.
@@ -568,7 +571,7 @@ declare class PredictionsResource extends Resource {
568
571
  * @param signal Optional AbortSignal to cancel the request.
569
572
  * @returns The prediction object.
570
573
  */
571
- get(id: string, signal?: AbortSignal): Promise<PredictionWithIO>;
574
+ get(id: string, signal?: AbortSignal): Promise<PredictionWithDetails>;
572
575
  /**
573
576
  * Cancel a prediction by its ID.
574
577
  * @param id The ID of the prediction to cancel.
@@ -587,7 +590,7 @@ declare class PredictionsResource extends Resource {
587
590
  * @param signal Optional AbortSignal to cancel the request.
588
591
  * @returns The new prediction.
589
592
  */
590
- create(options: CreatePredictionParams, wait?: boolean, waitOptions?: WaitOptions, signal?: AbortSignal): Promise<PredictionWithIO>;
593
+ create(options: CreatePredictionParams, wait?: boolean, waitOptions?: WaitOptions, signal?: AbortSignal): Promise<PredictionWithDetails>;
591
594
  /**
592
595
  * List predictions.
593
596
  * @param options Optional settings to control pagination behavior.
@@ -606,9 +609,22 @@ declare class PredictionsResource extends Resource {
606
609
  * operation.
607
610
  * @returns Prediction after completion.
608
611
  */
609
- wait(predictionID: string, options?: WaitOptions, signal?: AbortSignal): Promise<PredictionWithIO>;
612
+ wait(predictionID: string, options?: WaitOptions, signal?: AbortSignal): Promise<PredictionWithDetails>;
610
613
  }
611
614
 
615
+ /**
616
+ * Configuration for the model version
617
+ */
618
+ type ModelVersionConfiguration = {
619
+ /**
620
+ * The identifier of the hardware used by the model version.
621
+ */
622
+ hardware_identifier: string;
623
+ /**
624
+ * A list of variable keys for the model version.
625
+ */
626
+ variable_keys: string[];
627
+ };
612
628
  /**
613
629
  * Parameters for creating a version of a model.
614
630
  */
@@ -631,6 +647,11 @@ type CreateModelVersionParams = {
631
647
  * supported by the version.
632
648
  */
633
649
  compatibilities?: Partial<Compatibilities>;
650
+ /**
651
+ * Configuration for the model version.
652
+ * Omit to inherit configuration from the previous version.
653
+ */
654
+ configuration?: ModelVersionConfiguration;
634
655
  };
635
656
  /**
636
657
  * Error thrown when a model version identifier is not in
@@ -643,10 +664,34 @@ declare class InvalidModelVersionIdentifierError extends Error {
643
664
  */
644
665
  constructor(identifier: string);
645
666
  }
667
+ /**
668
+ * Parameters for updating the configuration of a model version.
669
+ */
670
+ type UpdateModelVersionConfigurationParams = {
671
+ /**
672
+ * The identifier of the hardware used by the model version.
673
+ */
674
+ hardware_identifier?: string;
675
+ /**
676
+ * The new list of variable keys to attach to the model version.
677
+ * Replaces all current variable keys.
678
+ */
679
+ variable_keys?: string[];
680
+ };
681
+ /**
682
+ * Represents a model version with it's details and configuration.
683
+ */
684
+ interface ModelVersionWithDetailsAndConfiguration extends ModelVersionWithDetails {
685
+ /**
686
+ * Configuration for the model version.
687
+ */
688
+ configuration: ModelVersionConfiguration;
689
+ }
646
690
  /**
647
691
  * Resource class for interacting with model versions.
648
692
  */
649
693
  declare class ModelVersions extends Resource {
694
+ private readonly CONFIGURATION_PATH;
650
695
  /**
651
696
  * Parses model version identifier into owner, name, and version number.
652
697
  * @param identifier The model version identifier in owner/name:version-number
@@ -673,7 +718,7 @@ declare class ModelVersions extends Resource {
673
718
  * @param signal Optional AbortSignal to cancel the request.
674
719
  * @returns The new version object.
675
720
  */
676
- create(identifier: string, params: CreateModelVersionParams, signal?: AbortSignal): Promise<ModelVersionWithDetails>;
721
+ create(identifier: string, params: CreateModelVersionParams, signal?: AbortSignal): Promise<ModelVersionWithDetailsAndConfiguration>;
677
722
  /**
678
723
  * Delete a model version.
679
724
  * @param identifier The model version identifier in owner/name:version-number
@@ -690,6 +735,23 @@ declare class ModelVersions extends Resource {
690
735
  * @returns A paginated response containing model versions.
691
736
  */
692
737
  list(identifier: string, options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<ModelVersion>>;
738
+ /**
739
+ * Update the configuration of a model version.
740
+ * @param identifier The model version identifier in owner/name:version-number
741
+ * format (for example: deepseek-ai/deepseek-r1:1).
742
+ * @param params Parameters for updating the configuration.
743
+ * @param signal Optional AbortSignal to cancel the request.
744
+ * @returns The updated model version configuration.
745
+ */
746
+ updateConfiguration(identifier: string, params: UpdateModelVersionConfigurationParams, signal?: AbortSignal): Promise<ModelVersionConfiguration>;
747
+ /**
748
+ * Get the configuration of a model version.
749
+ * @param identifier The model version identifier in owner/name:version-number
750
+ * format (for example: deepseek-ai/deepseek-r1:1).
751
+ * @param signal Optional AbortSignal to cancel the request.
752
+ * @returns The model version configuration.
753
+ */
754
+ getConfiguration(identifier: string, signal?: AbortSignal): Promise<ModelVersionConfiguration>;
693
755
  }
694
756
 
695
757
  /**
@@ -708,10 +770,6 @@ type UpdateModelParams = {
708
770
  * The visibility of the model.
709
771
  */
710
772
  visibility?: ModelVisibility;
711
- /**
712
- * The identifier of the hardware used by the model.
713
- */
714
- hardware_identifier?: string;
715
773
  /**
716
774
  * Source url from where the model's code can be referenced.
717
775
  */
@@ -745,10 +803,6 @@ type CreateModelParams = {
745
803
  * The visibility of the model.
746
804
  */
747
805
  visibility?: ModelVisibility;
748
- /**
749
- * The identifier of the hardware used by the model.
750
- */
751
- hardware_identifier: string;
752
806
  /**
753
807
  * Description of the model.
754
808
  */
@@ -929,9 +983,13 @@ declare class Users extends Resource {
929
983
  }
930
984
 
931
985
  /**
932
- * Represents a hardware item with more details.
986
+ * Represents a hardware item.
933
987
  */
934
- interface HardwareWithDetails extends Hardware {
988
+ interface Hardware {
989
+ /**The name of the hardware.*/
990
+ name: string;
991
+ /**The identifier of the hardware.*/
992
+ identifier: string;
935
993
  /** Number of GPUs available on the hardware. */
936
994
  gpus: number;
937
995
  /** Number of CPUs available on the hardware. */
@@ -981,61 +1039,123 @@ declare class ModelCategories extends Resource {
981
1039
  list(options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<ModelCategoryWithDetails>>;
982
1040
  }
983
1041
 
984
- /** Resource a file is related to. */
985
- type FileResource = 'prediction';
986
1042
  /**
987
- * Generated file urls.
1043
+ * Represents contents of a file.
1044
+ */
1045
+ type FileContent = File | Blob | Uint8Array;
1046
+ /**
1047
+ * Represents a file.
1048
+ */
1049
+ declare class FileData {
1050
+ /** Contents of the file. */
1051
+ readonly content: FileContent;
1052
+ /** MIME type of the file. */
1053
+ readonly mimeType: string;
1054
+ /**
1055
+ * Initializes a file.
1056
+ * @param content Contents of the file.
1057
+ * @param mimeType MIME type of the file, overriding the inferred value.
1058
+ * If omitted, it is inferred from the file object's `type` property when
1059
+ * available, otherwise from the file extension in its `name` property.
1060
+ * Falls back to `application/octet-stream` if it cannot be inferred.
1061
+ */
1062
+ constructor(content: FileContent, mimeType?: string);
1063
+ /**
1064
+ * Guesses the MIME type.
1065
+ * Prefers the file's own type, while falling back to
1066
+ * extension lookup.
1067
+ * @param file Contents of the file.
1068
+ * @returns The resolved mime type.
1069
+ */
1070
+ private static resolveMimeType;
1071
+ }
1072
+
1073
+ /**
1074
+ * Represents a variable
988
1075
  */
989
- interface FileUrls {
1076
+ interface Variable {
990
1077
  /**
991
- * The url to use to upload the file.
992
- * The file should be uploaded using a
993
- * PUT request to this URL. The Content-Length
994
- * and Content-type headers are required and
995
- * should match the size and MIME type of the
996
- * file being uploaded.
1078
+ * The unique key that identifies the variable.
997
1079
  */
998
- upload_url: string;
1080
+ key: string;
999
1081
  /**
1000
- * The url to download the file.
1082
+ * The value of the variable.
1083
+ * This is an empty string if the variable is a secret.
1001
1084
  */
1002
- download_url: string;
1085
+ value: string;
1086
+ /**
1087
+ * Indicates whether this variable is a secret.
1088
+ */
1089
+ secret: boolean;
1090
+ /**
1091
+ * The timestamp when the variable was created.
1092
+ */
1093
+ created_at: string;
1094
+ /**
1095
+ * The timestamp when the variable was last updated.
1096
+ */
1097
+ updated_at: string | null;
1003
1098
  }
1004
1099
  /**
1005
- * Parameters for creating file urls.
1100
+ * Parameters for creating a variable.
1006
1101
  */
1007
- type CreateFileUrlsParams = {
1102
+ type CreateVariableParams = {
1008
1103
  /**
1009
- * The name of the file to upload.
1104
+ * The unique key that identifies the variable.
1010
1105
  */
1011
- name: string;
1106
+ key: string;
1012
1107
  /**
1013
- * The size of the file to upload in bytes.
1014
- * This should be the exact size of the file.
1015
- * Any mismatch will result in the url being
1016
- * invalid or a corrupt file being uploaded.
1108
+ * The value of the variable.
1017
1109
  */
1018
- size: number;
1110
+ value: string;
1019
1111
  /**
1020
- * The resource the file will be related to.
1112
+ * Represents whether the variable's value should be treated
1113
+ * as a secret. The values of secrets are not returned.
1021
1114
  */
1022
- resource: FileResource;
1115
+ secret: boolean;
1116
+ };
1117
+ /**
1118
+ * Parameters for updating a variable.
1119
+ */
1120
+ type UpdateVariableParams = {
1023
1121
  /**
1024
- * The MIME type of the file.
1122
+ * The new value of the variable.
1025
1123
  */
1026
- mime_type: string;
1124
+ value?: string;
1027
1125
  };
1028
1126
  /**
1029
- * Resource for operations related to files.
1127
+ * Resource for operations related to variables.
1030
1128
  */
1031
- declare class Files extends Resource {
1129
+ declare class Variables extends Resource {
1130
+ private readonly VARIABLES_API_PREFIX;
1032
1131
  /**
1033
- * Generate urls to upload and download a file for a resource.
1034
- * @param params Parameters for url generation.
1035
- * @param signal Optional AbortSignal to cancel the request.
1036
- * @returns The generated urls.
1132
+ * Create a new variable.
1133
+ * @param params Parameters for creating the variable.
1134
+ * @param signal Optional abort signal.
1135
+ * @returns The created variable.
1136
+ */
1137
+ create(params: CreateVariableParams, signal?: AbortSignal): Promise<Variable>;
1138
+ /**
1139
+ * Delete a variable.
1140
+ * @param key The unique key that identifies the variable to be deleted.
1141
+ * @param signal Optional abort signal.
1037
1142
  */
1038
- createUrls(params: CreateFileUrlsParams, signal?: AbortSignal): Promise<FileUrls>;
1143
+ delete(key: string, signal?: AbortSignal): Promise<void>;
1144
+ /**
1145
+ * Update a variable.
1146
+ * @param key The unique key that identifies the variable to be updated.
1147
+ * @param params The parameters for updating the variable.
1148
+ * @param signal Optional abort signal.
1149
+ * @returns The updated variable.
1150
+ */
1151
+ update(key: string, params: UpdateVariableParams, signal?: AbortSignal): Promise<Variable>;
1152
+ /**
1153
+ * List variables.
1154
+ * @param options Optional settings to control pagination behavior.
1155
+ * @param signal Optional abort signal.
1156
+ * @returns Paginated response containing variables and navigation metadata.
1157
+ */
1158
+ list(options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<Variable>>;
1039
1159
  }
1040
1160
 
1041
1161
  /**
@@ -1102,6 +1222,73 @@ declare class WebhookTimestampOutsideToleranceError extends WebhookSignatureVeri
1102
1222
  */
1103
1223
  declare function verify(payload: Uint8Array, signature: string, secret: string, tolerance?: number, scheme?: string, keyCacheSize?: number): Promise<void>;
1104
1224
 
1225
+ /**
1226
+ * Represents an upload.
1227
+ */
1228
+ interface Upload {
1229
+ /**
1230
+ * The urls used to upload the file.
1231
+ */
1232
+ urls: string[];
1233
+ /**
1234
+ * The identifier for the upload.
1235
+ */
1236
+ id: string;
1237
+ /**
1238
+ * The size, in bytes, of each part. All parts
1239
+ * are this size except the last one, which may be
1240
+ * smaller. If the upload consists of a single part,
1241
+ * this value equals the total file size.
1242
+ */
1243
+ part_size: number;
1244
+ }
1245
+ /**
1246
+ * Parameters for creating an upload.
1247
+ */
1248
+ type CreateUploadParams = {
1249
+ /**
1250
+ * The size of the file to upload in bytes.
1251
+ * This should be the exact size of the file.
1252
+ * Any mismatch will result in an error or a corrupt file being uploaded.
1253
+ */
1254
+ size: number;
1255
+ /**
1256
+ * The MIME type of the file.
1257
+ */
1258
+ mime_type: string;
1259
+ };
1260
+ /**
1261
+ * Parameters for completing an upload.
1262
+ */
1263
+ type CompleteUploadParams = {
1264
+ /**
1265
+ * The list of etags of the uploaded parts
1266
+ * matching the ordering of urls.
1267
+ */
1268
+ etags: string[];
1269
+ };
1270
+ /**
1271
+ * Resource for operations related to uploads.
1272
+ */
1273
+ declare class Uploads extends Resource {
1274
+ private readonly UPLOADS_API_PREFIX;
1275
+ /**
1276
+ * Create an upload.
1277
+ * @param params Upload creation parameters.
1278
+ * @param signal Optional AbortSignal to cancel the request.
1279
+ * @returns The new upload.
1280
+ */
1281
+ create(params: CreateUploadParams, signal?: AbortSignal): Promise<Upload>;
1282
+ /**
1283
+ * Complete an upload.
1284
+ * @param id The unique identifier of the upload.
1285
+ * @param params Parameters to complete an upload.
1286
+ * @param signal Optional AbortSignal to cancel the request.
1287
+ * @returns The completion result.
1288
+ */
1289
+ complete(id: string, params: CompleteUploadParams, signal?: AbortSignal): Promise<UploadCompletionResult>;
1290
+ }
1291
+
1105
1292
  /**
1106
1293
  * Parameters for updating a user.
1107
1294
  */
@@ -1158,6 +1345,34 @@ declare class AuthenticatedUser extends Resource {
1158
1345
  models(options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<Model>>;
1159
1346
  }
1160
1347
 
1348
+ /**
1349
+ * Resource for operations related to files.
1350
+ */
1351
+ declare class Files {
1352
+ private fetchImpl;
1353
+ private headers;
1354
+ private uploads;
1355
+ /**
1356
+ * Create a new Files resource.
1357
+ * @param fetchImpl Fetch implementation to use.
1358
+ * @param headers Additional headers to send with file upload requests.
1359
+ * @param uploads An instance of the uploads resource.
1360
+ */
1361
+ constructor(fetchImpl: typeof fetch, headers: Record<string, string>, uploads: Uploads);
1362
+ /**
1363
+ * Upload a file.
1364
+ * The upload is streamed, but the underlying data may already be
1365
+ * in memory depending on how `file` was constructed.
1366
+ * For example, a browser `File` from an `<input>` or Node's
1367
+ * `openAsBlob()` stream from disk, while `new Blob([buffer])` or
1368
+ * `Uint8Array` require the data to already be in memory.
1369
+ * @param file The file to upload.
1370
+ * @param signal Optional AbortSignal to cancel the request.
1371
+ * @returns Result of the completed upload.
1372
+ */
1373
+ upload(file: FileData, signal?: AbortSignal): Promise<UploadCompletionResult>;
1374
+ }
1375
+
1161
1376
  interface WriftAIClientOptions {
1162
1377
  /**
1163
1378
  * Optional base URL for the API. It must not contain
@@ -1187,10 +1402,7 @@ interface WriftAIClientOptions {
1187
1402
  * Client for WriftAI.
1188
1403
  */
1189
1404
  declare class WriftAI {
1190
- /**
1191
- * The client used to interact with WriftAI's API.
1192
- */
1193
- api: API;
1405
+ private api;
1194
1406
  /**
1195
1407
  * Interface for accessing prediction related
1196
1408
  * resources and operations.
@@ -1227,6 +1439,16 @@ declare class WriftAI {
1227
1439
  * resources and operations.
1228
1440
  */
1229
1441
  files: Files;
1442
+ /**
1443
+ * Interface for accessing variables related
1444
+ * resources and options
1445
+ */
1446
+ variables: Variables;
1447
+ /**
1448
+ * Interface for accessing uploads related
1449
+ * resources and operations
1450
+ */
1451
+ uploads: Uploads;
1230
1452
  /**
1231
1453
  * Create an instance of the WriftAI client.
1232
1454
  * @param options Client options
@@ -1246,5 +1468,5 @@ declare class WriftAI {
1246
1468
  constructor(options?: WriftAIClientOptions);
1247
1469
  }
1248
1470
 
1249
- export { DEFAULT_WAIT_OPTIONS, ErrorSource, InvalidIdentifierError, InvalidModelIdentifierError, InvalidModelVersionIdentifierError, ModelVisibility, ModelsSortBy, SortDirection, Status, UsersSortBy, WebhookNoSignatureError, WebhookNoTimestampError, WebhookSignatureMismatchError, WebhookSignatureVerificationError, WebhookTimestampOutsideToleranceError, WriftAI, WriftAIAPIError, verify as verifyWebhook };
1250
- export type { BaseUser, Compatibilities, FileUrls, HardwareWithDetails, Model, ModelCategory, ModelCategoryWithDetails, ModelVersion, ModelVersionWithDetails, ModelWithDetails, PaginatedResponse, Prediction, PredictionModel, PredictionWithIO, SchemaIO, Schemas, TaskError, User, UserWithDetails, WriftAIClientOptions };
1471
+ export { DEFAULT_WAIT_OPTIONS, ErrorSource, FileData, InvalidIdentifierError, InvalidModelIdentifierError, InvalidModelVersionIdentifierError, ModelVisibility, ModelsSortBy, SortDirection, Status, UsersSortBy, WebhookNoSignatureError, WebhookNoTimestampError, WebhookSignatureMismatchError, WebhookSignatureVerificationError, WebhookTimestampOutsideToleranceError, WriftAI, WriftAIAPIError, verify as verifyWebhook };
1472
+ 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 };