bios-sdk 0.1.0-dev.1

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.
@@ -0,0 +1,1466 @@
1
+ /** Configuration for initializing the BIOS SDK client. */
2
+ export interface BiOSConfig {
3
+ /** API key for authentication (prefix: usf-). Mutually exclusive with accessToken. */
4
+ apiKey?: string;
5
+ /** JWT access token for authentication. Mutually exclusive with apiKey. */
6
+ accessToken?: string;
7
+ /** Organization ID. Optional when using API keys (resolved from the key). Required for JWT auth. */
8
+ orgId?: string;
9
+ /** Workspace ID. Optional when using API keys (resolved from the key). Can override for multi-workspace keys. */
10
+ workspaceId?: string;
11
+ /** Base URL for the API. Defaults to the canonical https://api-dev.usbios.ai hostname. */
12
+ baseUrl?: string;
13
+ /** Request timeout in milliseconds. Defaults to 30000. */
14
+ timeout?: number;
15
+ /** Default per-deployment inference key. Can be overridden per inference call. */
16
+ inferenceKey?: string;
17
+ /** Inference base URL. Defaults to baseUrl, then https://api-dev.usbios.ai. */
18
+ inferenceBaseUrl?: string;
19
+ /** End-to-end inference timeout in milliseconds. Defaults to 15 minutes. */
20
+ inferenceTimeout?: number;
21
+ }
22
+ /** Paginated list response wrapper. */
23
+ export interface PaginatedResponse<T> {
24
+ items: T[];
25
+ total: number;
26
+ offset: number;
27
+ limit: number;
28
+ hasMore: boolean;
29
+ }
30
+ /** Standard API error response body. */
31
+ export interface ApiErrorBody {
32
+ error?: string | {
33
+ code?: string;
34
+ message?: string;
35
+ detail?: string;
36
+ };
37
+ detail?: string;
38
+ message?: string;
39
+ code?: string;
40
+ request_id?: string;
41
+ }
42
+ /** A model returned from the HuggingFace-backed model search. */
43
+ export interface Model {
44
+ /** Full HuggingFace model ID (e.g. "meta-llama/Llama-3.1-8B"). */
45
+ id: string;
46
+ /** Model author / organization. */
47
+ author: string;
48
+ /** Human-readable model name. */
49
+ name: string;
50
+ /** Total parameter count in billions. */
51
+ totalParams: number;
52
+ /** Active parameter count in billions (differs from total for MoE models). */
53
+ activeParams: number;
54
+ /** Architecture type: "dense" or "moe". */
55
+ architecture: 'dense' | 'moe';
56
+ /** Model type: "llm" or "vlm". */
57
+ modelType: 'llm' | 'vlm';
58
+ /** HuggingFace model_type from config.json. */
59
+ hfModelType: string | null;
60
+ /** Download count on HuggingFace. */
61
+ downloads: number;
62
+ /** Like count on HuggingFace. */
63
+ likes: number;
64
+ /** Whether this is a private model. */
65
+ isPrivate: boolean;
66
+ /** Whether this is an adapter/LoRA model. */
67
+ isAdapter: boolean;
68
+ }
69
+ /** Parameters for searching models. */
70
+ export interface ModelSearchParams {
71
+ /** Search query string. */
72
+ query?: string;
73
+ /** Filter by model type: "all", "llm", or "vlm". */
74
+ type?: 'all' | 'llm' | 'vlm';
75
+ /** Pagination offset. Defaults to 0. */
76
+ offset?: number;
77
+ /** Number of results to return. Max 50, defaults to 20. */
78
+ limit?: number;
79
+ /** Minimum parameter count in billions. */
80
+ minParams?: number;
81
+ /** Maximum parameter count in billions. */
82
+ maxParams?: number;
83
+ /** Sort order: "downloads", "likes", or "trending". */
84
+ sort?: 'downloads' | 'likes' | 'trending';
85
+ /** Filter by author/organization. */
86
+ author?: string;
87
+ /** Visibility filter: "all", "public", or "private". */
88
+ visibility?: 'all' | 'public' | 'private';
89
+ /** Model kind: "full" (base models only) or "adapter". */
90
+ kind?: 'full' | 'adapter';
91
+ /** HuggingFace integration ID for accessing private models. */
92
+ integrationId?: string;
93
+ }
94
+ /** Response from a model search. */
95
+ export interface ModelSearchResponse {
96
+ models: Model[];
97
+ total: number;
98
+ offset: number;
99
+ limit: number;
100
+ hasMore: boolean;
101
+ hfUsername: string;
102
+ }
103
+ /** Model configuration from HuggingFace config.json. */
104
+ export interface ModelConfig {
105
+ /** Full HuggingFace model ID. */
106
+ modelId: string;
107
+ /** Model type from config.json (e.g. "llama", "qwen2"). */
108
+ model_type: string | null;
109
+ /** Model architecture classes. */
110
+ architectures: string[];
111
+ /** Total parameter count in billions. */
112
+ totalParams: number;
113
+ /** Active parameter count in billions. */
114
+ activeParams: number;
115
+ /** Whether this is a Mixture-of-Experts model. */
116
+ isMoE: boolean;
117
+ /** Whether config was successfully resolved. */
118
+ resolved: boolean;
119
+ }
120
+ /** A dataset in the user's workspace. */
121
+ export interface Dataset {
122
+ id: string;
123
+ name: string;
124
+ description?: string;
125
+ workspace_id?: string;
126
+ source?: string;
127
+ hf_dataset_id?: string | null;
128
+ hf_subset?: string | null;
129
+ hf_split?: string | null;
130
+ dataset_type?: string;
131
+ detected_format?: string | null;
132
+ num_samples?: number | null;
133
+ num_columns?: number | null;
134
+ column_info?: Array<Record<string, unknown>>;
135
+ column_mapping?: Record<string, string> | null;
136
+ compatible_training_methods?: string[];
137
+ compatible_rlhf_algorithms?: string[];
138
+ detected_fields?: string[];
139
+ file_format?: string | null;
140
+ file_size_bytes?: number;
141
+ status?: string;
142
+ max_samples?: number | null;
143
+ error_message?: string | null;
144
+ progress_percent?: number;
145
+ progress_message?: string;
146
+ storage_mode?: string;
147
+ num_shards?: number | null;
148
+ method_usable_counts?: Record<string, number> | null;
149
+ consistency_info?: Record<string, unknown> | null;
150
+ validation_warnings?: string[];
151
+ created_at?: string;
152
+ /** @deprecated Use file_size_bytes. Populated as a compatibility alias. */
153
+ file_size?: number;
154
+ /** @deprecated Use num_samples. Populated as a compatibility alias. */
155
+ row_count?: number;
156
+ /** @deprecated Use num_columns. Populated as a compatibility alias. */
157
+ column_count?: number;
158
+ /** @deprecated Use file_format or detected_format. Populated as a compatibility alias. */
159
+ format?: string;
160
+ }
161
+ /** Parameters for listing datasets. */
162
+ export interface DatasetListParams {
163
+ /** Filter by workspace ID. */
164
+ workspaceId?: string;
165
+ /** Filter by dataset type. */
166
+ datasetType?: string;
167
+ /** Lifecycle bucket: ready, processing, or failed. */
168
+ status?: 'ready' | 'processing' | 'failed';
169
+ /** Case-insensitive name search. */
170
+ query?: string;
171
+ /** Server-side ordering. */
172
+ sort?: 'newest' | 'oldest' | 'name' | 'size';
173
+ /** Page size (maximum 200). */
174
+ limit?: number;
175
+ /** Page offset. */
176
+ offset?: number;
177
+ }
178
+ /** Server-driven dataset page returned by GET /api/datasets. */
179
+ export interface DatasetListResponse {
180
+ datasets: Dataset[];
181
+ total: number;
182
+ counts: {
183
+ all: number;
184
+ ready: number;
185
+ processing: number;
186
+ failed: number;
187
+ };
188
+ total_samples: number;
189
+ limit: number;
190
+ offset: number;
191
+ }
192
+ /** Parameters for uploading a dataset. */
193
+ export interface DatasetUploadParams {
194
+ /** Path to the file on disk (Node.js only). */
195
+ filePath: string;
196
+ /** Display name for the dataset. */
197
+ name: string;
198
+ /** Optional description. */
199
+ description?: string;
200
+ /** Target workspace ID. */
201
+ workspaceId?: string;
202
+ /** Dataset format hint (e.g. "jsonl", "csv", "parquet"). */
203
+ format?: string;
204
+ /** Maximum number of samples to retain. */
205
+ maxSamples?: number;
206
+ /** Optional source-to-canonical column mapping. */
207
+ columnMapping?: Record<string, string>;
208
+ }
209
+ /** Parameters for previewing dataset rows. */
210
+ export interface DatasetPreviewParams {
211
+ /** Page number (1-indexed). Defaults to 1. */
212
+ page?: number;
213
+ /** Number of rows per page. Defaults to 10. */
214
+ pageSize?: number;
215
+ }
216
+ /** Dataset preview response. */
217
+ export interface DatasetPreview {
218
+ samples: Record<string, unknown>[];
219
+ total: number;
220
+ page: number;
221
+ page_size: number;
222
+ total_pages: number;
223
+ /** @deprecated Use samples. Populated as a compatibility alias. */
224
+ rows?: Record<string, unknown>[];
225
+ /** @deprecated Use total. Populated as a compatibility alias. */
226
+ total_rows?: number;
227
+ }
228
+ /** Parameters for importing a dataset from HuggingFace Hub. */
229
+ export interface DatasetImportHFParams {
230
+ /** HuggingFace dataset repository ID (e.g. "databricks/dolly-15k"). */
231
+ repoId: string;
232
+ /** Display name for the imported dataset. */
233
+ name?: string;
234
+ /** Dataset subset/config to import. */
235
+ subset?: string;
236
+ /** Dataset split to import (e.g. "train", "test"). */
237
+ split?: string;
238
+ /** Maximum number of samples to import. */
239
+ maxSamples?: number;
240
+ /** HuggingFace integration ID for private datasets. */
241
+ integrationId?: string;
242
+ /** Sampling strategy used with maxSamples. */
243
+ sampleStrategy?: 'first' | 'random';
244
+ /** Optional source-to-canonical column mapping. */
245
+ columnMapping?: Record<string, string>;
246
+ /** Whether to reference or materialize the source dataset. */
247
+ importMode?: 'auto' | 'reference' | 'materialize';
248
+ }
249
+ /** Parameters for registering a HuggingFace dataset without an integration. */
250
+ export interface DatasetRegisterHFParams {
251
+ repoId: string;
252
+ name?: string;
253
+ workspaceId?: string;
254
+ description?: string;
255
+ subset?: string;
256
+ split?: string;
257
+ maxSamples?: number;
258
+ sampleStrategy?: 'first' | 'random';
259
+ columnMapping?: Record<string, string>;
260
+ importMode?: 'auto' | 'reference' | 'materialize';
261
+ }
262
+ /** Parameters for searching HuggingFace Hub datasets. */
263
+ export interface DatasetHubSearchParams {
264
+ /** Search query. */
265
+ query?: string;
266
+ /** Page number (1-indexed). Defaults to 1. */
267
+ page?: number;
268
+ /** Sort order. Defaults to "downloads". */
269
+ sort?: 'downloads' | 'likes' | 'trending';
270
+ }
271
+ /** Parameters for previewing a HuggingFace Hub dataset. */
272
+ export interface DatasetHubPreviewParams {
273
+ /** HuggingFace dataset ID. */
274
+ datasetId: string;
275
+ /** Split to preview. Defaults to "train". */
276
+ split?: string;
277
+ /** Subset/config name. */
278
+ subset?: string;
279
+ /** Number of rows to preview. Defaults to 10. */
280
+ limit?: number;
281
+ }
282
+ /** Dataset validation result. */
283
+ export interface DatasetValidation {
284
+ dataset_type: string;
285
+ detected_format?: string | null;
286
+ confidence: number;
287
+ format_valid: boolean;
288
+ num_samples: number;
289
+ num_columns: number;
290
+ detected_fields: string[];
291
+ column_info: Array<Record<string, unknown>>;
292
+ compatible_training_methods: string[];
293
+ compatible_rlhf_algorithms: string[];
294
+ method_usable_counts?: Record<string, number> | null;
295
+ validation_errors: string[];
296
+ validation_warnings: string[];
297
+ consistency?: Record<string, unknown> | null;
298
+ preview_samples: Record<string, unknown>[];
299
+ }
300
+ /** One accepted row shape for a dataset type. */
301
+ export interface DatasetFormatVariant {
302
+ name: string;
303
+ required_fields: string[];
304
+ description: string;
305
+ example: string;
306
+ needs_conversion?: boolean;
307
+ }
308
+ /** Dataset format specification for one training family. */
309
+ export interface DatasetFormatSpec {
310
+ label: string;
311
+ formats: DatasetFormatVariant[];
312
+ }
313
+ /** Mapping keyed by dataset type (sft, rlhf_offline_preference, pt, etc.). */
314
+ export type DatasetFormatSpecs = Record<string, DatasetFormatSpec>;
315
+ /** Dataset storage usage info. */
316
+ export interface DatasetStorageUsage {
317
+ total_bytes: number;
318
+ total_mb?: number;
319
+ total_gb?: number;
320
+ dataset_count: number;
321
+ workspace_id?: string | null;
322
+ pricing?: Record<string, number>;
323
+ recent_charges?: Array<Record<string, unknown>>;
324
+ }
325
+ /** Supported training methods. */
326
+ export type TrainingMethod = 'sft' | 'rlhf' | 'pt' | 'vlm';
327
+ /** Supported RLHF algorithms. */
328
+ export type RLHFAlgorithm = 'dpo' | 'simpo' | 'cpo' | 'orpo' | 'kto' | 'rm';
329
+ /** Supported adapter types. */
330
+ export type AdapterType = 'lora' | 'qlora' | 'adalora' | 'full' | 'loha' | 'lokr' | 'boft' | 'oft' | 'vera' | 'fourierft' | 'bone' | 'adapter' | 'reft' | 'llamapro' | 'longlora';
331
+ /** Training job status values. */
332
+ export type TrainingJobStatus = 'pending' | 'queued' | 'provisioning' | 'preparing' | 'starting' | 'downloading' | 'running' | 'completed' | 'failed' | 'saving' | 'stopped' | 'stopping' | 'resuming' | 'cancelled';
333
+ /** Status values accepted by GET /api/training/jobs?status=. */
334
+ export type TrainingStatusFilter = 'pending' | 'queued' | 'provisioning' | 'preparing' | 'starting' | 'running' | 'saving' | 'completed' | 'failed' | 'stopped';
335
+ /** One ranked GPU fallback choice. The first choice is the primary. */
336
+ export interface GPUChoice {
337
+ gpuType: string;
338
+ gpuCount: number;
339
+ /** Neutral USF Cloud placement selector; omit to let the platform choose. */
340
+ provider?: string;
341
+ /** Placement region; omit for the default global market. */
342
+ region?: string;
343
+ /** Native market tier; training and deployment capacity are secure-only. */
344
+ tier?: 'secure';
345
+ }
346
+ /** Parameters for creating a training job. */
347
+ export interface TrainingCreateParams {
348
+ /** Stable retry key. Reuse it after a timeout; a new value creates a new job. Auto-generated when omitted. */
349
+ idempotencyKey?: string;
350
+ /** HuggingFace model ID to fine-tune. */
351
+ model: string;
352
+ /** Optional Hugging Face branch, tag, or commit; the API canonicalizes it to an exact commit. */
353
+ modelRevision?: string;
354
+ /** One dataset ID to train on. Kept for compatibility with single-dataset jobs. */
355
+ datasetId?: string;
356
+ /** Ordered dataset IDs for multi-dataset training. */
357
+ datasetIds?: string[];
358
+ /**
359
+ * Optional per-dataset row cap: keep only the first N rows of a dataset
360
+ * (key = a dataset ID from datasetIds, value = row count). Omit an entry, or
361
+ * use 0, to train on the whole dataset. Useful for training on a slice of a
362
+ * large dataset without importing a trimmed copy.
363
+ */
364
+ datasetSampleLimits?: Record<string, number>;
365
+ /** Training method. */
366
+ method: TrainingMethod;
367
+ /** Adapter type. */
368
+ adapter: AdapterType;
369
+ /** RLHF algorithm (required when method is "rlhf"). */
370
+ rlhfAlgorithm?: RLHFAlgorithm;
371
+ /** GPU type identifier. */
372
+ gpuType?: string;
373
+ /** Number of GPUs to use. */
374
+ gpuCount?: number;
375
+ /** Primary and backup GPU choices, in priority order (maximum five). */
376
+ gpuPriorities?: GPUChoice[];
377
+ /** Consent to try 3-5 ranked, distinct GPU types when the primary is unavailable. */
378
+ queueIfUnavailable?: boolean;
379
+ /** Optional RFC 3339 queue deadline, from one minute through seven days in the future. */
380
+ queueDeadline?: string | Date;
381
+ /** Maximum accepted total hourly price for the complete GPU count, in cents. */
382
+ maxPriceHourCents?: number;
383
+ /** Display name for the job. */
384
+ name?: string;
385
+ /** Target workspace ID. */
386
+ workspaceId?: string;
387
+ /** Number of training epochs. */
388
+ epochs?: number;
389
+ /** Training batch size per device. */
390
+ batchSize?: number;
391
+ /** Gradient accumulation steps. */
392
+ gradientAccumulation?: number;
393
+ /** Learning rate. */
394
+ learningRate?: number;
395
+ /** Learning rate scheduler type. */
396
+ lrScheduler?: string;
397
+ /** Warmup ratio (0-1). */
398
+ warmupRatio?: number;
399
+ /** Warmup steps (overrides warmupRatio). */
400
+ warmupSteps?: number;
401
+ /** Weight decay. */
402
+ weightDecay?: number;
403
+ /** Maximum gradient norm for clipping. */
404
+ maxGradNorm?: number;
405
+ /** Maximum sequence length. */
406
+ maxSeqLength?: number;
407
+ /** Enable gradient checkpointing. */
408
+ gradientCheckpointing?: boolean;
409
+ /** Enable mixed precision training (bf16/fp16). */
410
+ mixedPrecision?: 'bf16' | 'fp16' | 'no';
411
+ /** Random seed. */
412
+ seed?: number;
413
+ /** LoRA rank. */
414
+ loraRank?: number;
415
+ /** LoRA alpha scaling factor. */
416
+ loraAlpha?: number;
417
+ /** LoRA dropout rate. */
418
+ loraDropout?: number;
419
+ /** LoRA target modules (comma-separated or array). */
420
+ loraTargetModules?: string | string[];
421
+ /** Quantization bit width (4 or 8). */
422
+ quantizationBit?: 4 | 8;
423
+ /** DeepSpeed stage ("zero2" or "zero3"). */
424
+ deepspeed?: 'zero2' | 'zero3';
425
+ /** Storage size in GB. */
426
+ storageGb?: number;
427
+ /** Number of checkpoints to retain at the platform level. */
428
+ numCheckpoints?: number;
429
+ /** Model parameter hint in billions; the server resolves and floors it. */
430
+ modelParamsB?: number;
431
+ /** Active-parameter hint for MoE models in billions. */
432
+ modelActiveParamsB?: number;
433
+ /** HuggingFace integration used for gated/private model access. */
434
+ integrationId?: string;
435
+ /** Existing network volume to attach. */
436
+ networkVolumeId?: string;
437
+ /** Cache the composed dataset for retry/resume. Defaults to true server-side. */
438
+ cacheDataset?: boolean;
439
+ /** Legacy dataset ordering mode. Prefer mixing for weighted/phased plans. */
440
+ datasetMixing?: 'shuffle' | 'sequential' | 'interleave' | 'random' | 'curriculum';
441
+ /** Structured multi-dataset mixing plan. */
442
+ mixing?: Record<string, unknown>;
443
+ /** Save checkpoint every N steps. */
444
+ saveSteps?: number;
445
+ /** Save checkpoint every N epochs. */
446
+ saveEpochs?: number;
447
+ /** Maximum number of checkpoints to keep. */
448
+ maxCheckpoints?: number;
449
+ /** Evaluate every N steps. */
450
+ evalSteps?: number;
451
+ /** Evaluation dataset split. */
452
+ evalSplit?: string | number;
453
+ /** Additional configuration passed directly to the training backend. */
454
+ extraConfig?: Record<string, unknown>;
455
+ }
456
+ /** Parameters for listing training jobs. */
457
+ export interface TrainingListParams {
458
+ /** Filter by workspace ID. */
459
+ workspaceId?: string;
460
+ /** Filter by status. */
461
+ status?: TrainingStatusFilter;
462
+ /** Page size (maximum 100). */
463
+ limit?: number;
464
+ /** Page offset. */
465
+ offset?: number;
466
+ }
467
+ /** One phase of a training job's lifecycle (Progress Frame v2). */
468
+ export interface TrainingJobPhase {
469
+ /** Canonical phase id, e.g. "dataset_download", "model_load", "training", "checkpoint_upload". */
470
+ phase: string;
471
+ state: 'pending' | 'active' | 'done' | 'failed' | 'skipped';
472
+ /** Percent complete for the active phase, 0-100. */
473
+ pct?: number;
474
+ done_bytes?: number;
475
+ total_bytes?: number;
476
+ done_units?: number;
477
+ total_units?: number;
478
+ /** Unit for done_units/total_units, e.g. "bytes", "shards", "steps", "examples". */
479
+ units?: string;
480
+ /** Measured throughput in units per second. */
481
+ rate?: number;
482
+ eta_seconds?: number;
483
+ /** Per-item breakdown for fan-out phases (one entry per dataset in dataset_download). */
484
+ items?: Array<Record<string, unknown>>;
485
+ started_at?: string;
486
+ ended_at?: string;
487
+ updated_at?: string;
488
+ }
489
+ /** A training job. */
490
+ export interface TrainingJob {
491
+ id: string;
492
+ /** Present on create/resume responses; id is always normalized from this value. */
493
+ job_id?: string;
494
+ name?: string;
495
+ model_id?: string;
496
+ model_revision?: string;
497
+ training_method?: TrainingMethod;
498
+ train_type?: AdapterType;
499
+ rlhf_type?: RLHFAlgorithm | null;
500
+ dataset_ids?: string[];
501
+ gpu_type?: string;
502
+ gpu_count?: number;
503
+ storage_gb?: number;
504
+ status: TrainingJobStatus;
505
+ error_message?: string | null;
506
+ error_code?: string | null;
507
+ current_step?: number;
508
+ total_steps?: number;
509
+ current_loss?: number | null;
510
+ best_loss?: number | null;
511
+ config?: Record<string, unknown>;
512
+ started_at?: string;
513
+ completed_at?: string;
514
+ created_at?: string;
515
+ billing_started_at?: string;
516
+ resume_from_job_id?: string | null;
517
+ resume_count?: number;
518
+ can_resume?: boolean;
519
+ has_cached_dataset?: boolean;
520
+ final_model_s3_key?: string | null;
521
+ mix_manifest?: Record<string, unknown> | null;
522
+ preserve_on_stop?: boolean;
523
+ desired_state?: 'running' | 'stopped';
524
+ stop_state?: 'idle' | 'requested' | 'signalled' | 'terminating' | 'applied' | 'superseded';
525
+ stop_requested_at?: string | null;
526
+ stop_bios_accepted_at?: string | null;
527
+ stop_last_error?: string | null;
528
+ s3_upload_status?: string | null;
529
+ progress?: unknown;
530
+ stage?: string;
531
+ stage_detail?: string;
532
+ attempt?: number;
533
+ attempts_max?: number;
534
+ billed_cents?: number;
535
+ billable_seconds?: number;
536
+ stage_elapsed_seconds?: number;
537
+ stage_estimate_seconds?: number;
538
+ dl_done_bytes?: number;
539
+ dl_total_bytes?: number;
540
+ ds_done_bytes?: number;
541
+ ds_total_bytes?: number;
542
+ checkpoint_count?: number;
543
+ /** The current machine attempt's per-phase records, in canonical order. */
544
+ phases?: TrainingJobPhase[];
545
+ /** Estimated seconds until the job finishes (absent when unknown). */
546
+ eta_seconds?: number;
547
+ /** How the ETA was derived: measured from the pod, or from historical medians. */
548
+ eta_confidence?: 'measured' | 'historical';
549
+ /** Most recent per-phase update time. */
550
+ last_phase_update_at?: string;
551
+ /** The current machine attempt id. */
552
+ attempt_id?: string;
553
+ /** The provisioned pod id for the current attempt. */
554
+ pod_id?: string;
555
+ /** Last time the pod pushed a callback. */
556
+ last_callback_at?: string;
557
+ /** How the platform is hearing from the machine right now. */
558
+ push_channel_state?: 'live' | 'delayed' | 'poll_only';
559
+ /** @deprecated Use model_id. Populated as a compatibility alias when known. */
560
+ model?: string;
561
+ /** @deprecated Use training_method. Populated as a compatibility alias when known. */
562
+ method?: TrainingMethod;
563
+ /** @deprecated Use train_type. Populated as a compatibility alias when known. */
564
+ adapter?: AdapterType;
565
+ /** @deprecated Use rlhf_type. Populated as a compatibility alias when known. */
566
+ rlhf_algorithm?: RLHFAlgorithm;
567
+ /** @deprecated Use dataset_ids. Populated from the first dataset when known. */
568
+ dataset_id?: string;
569
+ /** @deprecated Use error_message. */
570
+ error?: string;
571
+ }
572
+ /** Paginated response from GET /api/training/jobs. */
573
+ export interface TrainingListResponse {
574
+ jobs: TrainingJob[];
575
+ total: number;
576
+ limit: number;
577
+ offset: number;
578
+ }
579
+ /** Training metrics for a job. */
580
+ export interface TrainingMetrics {
581
+ metrics: MetricPoint[];
582
+ training_method?: string | null;
583
+ rlhf_type?: string | null;
584
+ graph_configs: MetricGraphConfig[];
585
+ /** @deprecated Use metrics. Populated as a compatibility alias. */
586
+ steps?: MetricPoint[];
587
+ }
588
+ /** A single metric data point. */
589
+ export interface MetricPoint {
590
+ step: number;
591
+ epoch?: number;
592
+ loss?: number;
593
+ eval_loss?: number;
594
+ learning_rate?: number;
595
+ grad_norm?: number;
596
+ reward?: number;
597
+ gpu_memory_mb?: number;
598
+ gpu_utilization_pct?: number;
599
+ extra_metrics?: Record<string, unknown>;
600
+ timestamp: string;
601
+ [key: string]: unknown;
602
+ }
603
+ /** Metric series configuration returned for the selected training method. */
604
+ export interface MetricGraphConfig {
605
+ key: string;
606
+ label: string;
607
+ color: string;
608
+ }
609
+ /** A training checkpoint. */
610
+ export interface TrainingCheckpoint {
611
+ id: string;
612
+ name: string;
613
+ step: number;
614
+ epoch?: number | null;
615
+ size_bytes: number;
616
+ is_final: boolean;
617
+ is_best: boolean;
618
+ base_model_id: string;
619
+ base_model_revision: string;
620
+ created_at: string;
621
+ }
622
+ /** Training logs response. */
623
+ export interface TrainingLogs {
624
+ logs: TrainingLogEntry[];
625
+ /** Plain-text compatibility view of logs, oldest API clients can migrate to entries. */
626
+ lines?: string[];
627
+ }
628
+ /** One structured training log entry. */
629
+ export interface TrainingLogEntry {
630
+ level: string;
631
+ message: string;
632
+ timestamp: string;
633
+ }
634
+ /** Response from stopping a training job. */
635
+ export interface TrainingStopResponse {
636
+ message: string;
637
+ job_id: string;
638
+ status: TrainingJobStatus;
639
+ desired_state: 'stopped';
640
+ stop_state: 'requested' | 'signalled' | 'terminating' | 'applied';
641
+ keep_data: boolean;
642
+ requested_at?: string | null;
643
+ }
644
+ /** Response from resuming a training job into a new job. */
645
+ export interface TrainingResumeResponse {
646
+ id: string;
647
+ job_id: string;
648
+ name: string;
649
+ status: TrainingJobStatus;
650
+ resume_from: string;
651
+ checkpoint: string;
652
+ resume_count: number;
653
+ model_id: string;
654
+ model_revision: string;
655
+ }
656
+ /** Canonical snake_case request echoed by the side-effect-free preflight API. */
657
+ export interface CanonicalTrainingRequest {
658
+ workspace_id: string;
659
+ name: string;
660
+ dataset_id: string;
661
+ dataset_ids: string[];
662
+ hf_dataset_ids?: string;
663
+ dataset_mixing?: string;
664
+ mixing?: Record<string, unknown>;
665
+ model_id: string;
666
+ model_revision?: string;
667
+ training_method: TrainingMethod;
668
+ train_type: AdapterType;
669
+ rlhf_type?: RLHFAlgorithm;
670
+ gpu_type: string;
671
+ gpu_count: number;
672
+ gpu_priorities?: Array<{
673
+ gpu_type: string;
674
+ gpu_count: number;
675
+ provider?: string;
676
+ region?: string;
677
+ tier?: 'secure';
678
+ }>;
679
+ queue_if_unavailable?: boolean;
680
+ queue_deadline?: string;
681
+ max_price_hour_cents?: number;
682
+ storage_gb: number;
683
+ num_checkpoints?: number;
684
+ model_params_b?: number;
685
+ model_active_params_b?: number;
686
+ integration_id?: string;
687
+ network_volume_id?: string;
688
+ cache_dataset?: boolean;
689
+ config: Record<string, unknown>;
690
+ }
691
+ export interface TrainingPreflightDataset {
692
+ id: string;
693
+ status: string;
694
+ dataset_type?: string;
695
+ storage_mode?: string;
696
+ method_usable_counts?: Record<string, number>;
697
+ requires_revalidation: boolean;
698
+ }
699
+ export interface TrainingPreflightWarning {
700
+ code: string;
701
+ message: string;
702
+ }
703
+ /** Side-effect-free validation/sizing result; this endpoint never creates or bills a job. */
704
+ export interface TrainingPreflightResponse {
705
+ valid: boolean;
706
+ contract_version: string;
707
+ request_hash: string;
708
+ canonical_request: CanonicalTrainingRequest;
709
+ datasets: TrainingPreflightDataset[];
710
+ model_params_b: number;
711
+ model_active_params_b?: number;
712
+ minimum_vram_gb: number;
713
+ minimum_storage_gb: number;
714
+ gpu_options: GPUOption[];
715
+ recommended?: GPUOption;
716
+ suggestions: GPUOptionSuggestion[];
717
+ availability_known: boolean;
718
+ availability_checked_at?: string;
719
+ queue_eligible: boolean;
720
+ warnings: TrainingPreflightWarning[];
721
+ checked_at: string;
722
+ }
723
+ /** One method, algorithm, or adapter reported by the pinned training engine. */
724
+ export interface TrainingCapabilityChoice {
725
+ id: string;
726
+ name: string;
727
+ enabled: boolean;
728
+ engine_supported: boolean;
729
+ disabled_reason?: string;
730
+ aliases?: string[];
731
+ supported_methods?: string[];
732
+ supported_algorithms?: string[];
733
+ dependencies?: string[];
734
+ }
735
+ /** JSON-schema-like description of one accepted config field. */
736
+ export interface TrainingConfigFieldCapability {
737
+ name: string;
738
+ label: string;
739
+ type: 'integer' | 'number' | 'boolean' | 'string' | 'string_array' | 'string_or_string_array' | 'object';
740
+ default: unknown;
741
+ enabled: boolean;
742
+ disabled_reason?: string;
743
+ aliases?: string[];
744
+ enum?: string[];
745
+ minimum?: number;
746
+ maximum?: number;
747
+ exclusive_minimum?: boolean;
748
+ methods?: string[];
749
+ algorithms?: string[];
750
+ adapters?: string[];
751
+ description?: string;
752
+ }
753
+ /** Dynamic contract returned by GET /api/training/capabilities. */
754
+ export interface TrainingCapabilities {
755
+ contract_version: string;
756
+ schema_version: string;
757
+ image_compatibility: {
758
+ minimum: string;
759
+ maximum_exclusive: string;
760
+ };
761
+ methods: TrainingCapabilityChoice[];
762
+ algorithms: TrainingCapabilityChoice[];
763
+ adapters: TrainingCapabilityChoice[];
764
+ fields: TrainingConfigFieldCapability[];
765
+ incompatibilities: Array<{
766
+ code: string;
767
+ when: Record<string, unknown>;
768
+ message: string;
769
+ }>;
770
+ }
771
+ /** Wallet balance information. */
772
+ export interface WalletBalance {
773
+ balance_cents: number;
774
+ available_cents: number;
775
+ pending_charges_cents: number;
776
+ currency: string;
777
+ auto_topup?: {
778
+ enabled: boolean;
779
+ threshold_cents: number;
780
+ amount_cents: number;
781
+ };
782
+ }
783
+ /** A billing transaction record. */
784
+ export interface Transaction {
785
+ id: string;
786
+ type: string;
787
+ amount_cents: number;
788
+ description?: string;
789
+ status: string;
790
+ created_at: string;
791
+ job_id?: string;
792
+ }
793
+ /** Parameters for listing transactions. */
794
+ export interface TransactionListParams {
795
+ /** Maximum number of transactions. Defaults to 50. */
796
+ limit?: number;
797
+ /** Pagination offset. Defaults to 0. */
798
+ offset?: number;
799
+ }
800
+ /** GPU pricing and availability info. */
801
+ export interface GPUInfo {
802
+ gpu_type: string;
803
+ display_name: string;
804
+ vram_gb: number;
805
+ tier: string;
806
+ best_for: string;
807
+ max_gpu_count: number;
808
+ default_storage_gb: number;
809
+ param_range: string;
810
+ methods: string;
811
+ available: boolean;
812
+ available_count: number;
813
+ price_per_hour_cents: number;
814
+ price_display: string;
815
+ }
816
+ /** Response from the GPU pricing endpoint. */
817
+ export interface GPUPricingResponse {
818
+ gpus: GPUInfo[];
819
+ stale?: boolean;
820
+ stale_message?: string;
821
+ }
822
+ /** Parameters understood by the authenticated training GPU-options endpoint. */
823
+ export interface GPUOptionsParams {
824
+ modelId: string;
825
+ /** Requested Hugging Face branch, tag, or commit; response returns the exact commit. */
826
+ modelRevision?: string;
827
+ /** Stored Hugging Face integration used for gated or private repositories. */
828
+ integrationId?: string;
829
+ /** Canonical adapter/train type. */
830
+ trainType?: AdapterType | string;
831
+ /** @deprecated Use trainType. */
832
+ adapter?: AdapterType | string;
833
+ method?: TrainingMethod | string;
834
+ rlhfType?: RLHFAlgorithm | string;
835
+ modelParamsB?: number;
836
+ modelActiveParamsB?: number;
837
+ }
838
+ /** One model-aware GPU option with live stock and total-price context. */
839
+ export interface GPUOption {
840
+ gpu_type: string;
841
+ display_name: string;
842
+ vram_gb: number;
843
+ price_per_hour_cents: number;
844
+ available: boolean;
845
+ available_count: number;
846
+ max_gpu_count: number;
847
+ min_gpu_count: number;
848
+ required_count: number;
849
+ recommended_count: number;
850
+ total_price_per_hour_cents?: number;
851
+ default_storage_gb: number;
852
+ min_storage_gb: number;
853
+ selectable: boolean;
854
+ bookable: boolean;
855
+ reason?: string;
856
+ checked_at?: string;
857
+ }
858
+ /** Actionable alternative returned when no GPU option is currently bookable. */
859
+ export interface GPUOptionSuggestion {
860
+ type: 'adapter' | 'smaller_model' | 'wait' | string;
861
+ adapter?: string;
862
+ adapter_label?: string;
863
+ gpu_type?: string;
864
+ gpu_display_name?: string;
865
+ gpu_count?: number;
866
+ price_per_hour_cents?: number;
867
+ message: string;
868
+ }
869
+ export interface GPUOptionsResponse {
870
+ options: GPUOption[];
871
+ /** Canonical Hugging Face owner/repository identity. */
872
+ model_id: string;
873
+ /** Exact immutable 40-hex Hugging Face commit used for sizing. */
874
+ model_revision: string;
875
+ model_params_b: number;
876
+ min_vram_gb: number;
877
+ min_storage_gb: number;
878
+ availability_known: boolean;
879
+ checked_at: string;
880
+ recommended?: {
881
+ gpu_type: string;
882
+ gpu_count: number;
883
+ storage_gb: number;
884
+ price_per_hour_cents: number;
885
+ total_price_per_hour_cents: number;
886
+ };
887
+ suggestions?: GPUOptionSuggestion[];
888
+ }
889
+ export type InferenceStatus = 'provisioning' | 'queued_capacity' | 'downloading_weights' | 'loading_model' | 'running' | 'degraded' | 'stopped' | 'paused_insufficient_funds' | 'crash_loop' | 'failed' | 'deleting' | 'deleted' | string;
890
+ export type InferenceToolCallParser = 'deepseekv3' | 'deepseekv31' | 'deepseekv32' | 'glm' | 'glm45' | 'glm47' | 'gpt-oss' | 'kimi_k2' | 'lfm2' | 'llama3' | 'mimo' | 'mistral' | 'omega17' | 'omega17_exp' | 'omega17_vl_exp' | 'pythonic' | 'qwen' | 'qwen25' | 'qwen3_coder' | 'step3' | 'step3p5' | 'minimax-m2' | 'trinity' | 'interns1' | 'hermes' | 'gigachat3' | 'usf_omega' | 'usf_milli' | 'usf_mini';
891
+ export type InferenceReasoningParser = 'deepseek-r1' | 'deepseek-v3' | 'glm45' | 'gpt-oss' | 'kimi' | 'kimi_k2' | 'mimo' | 'qwen3' | 'qwen3-thinking' | 'minimax' | 'minimax-append-think' | 'step3' | 'step3p5' | 'mistral' | 'nemotron_3' | 'interns1' | 'usf_omega' | 'usf_milli' | 'usf_mini';
892
+ /** How the tool-call verdict was reached and what callers can expect. */
893
+ export type InferenceToolCallMode = 'native' | 'best_effort' | 'off' | 'unsupported';
894
+ export interface InferenceServingConfig {
895
+ /**
896
+ * 'auto' (default) derives the format from the model's own chat template;
897
+ * 'off' disables tool calling for this deployment; a concrete family name
898
+ * forces that parser. Unknown names are rejected before GPU allocation.
899
+ */
900
+ tool_call_parser?: InferenceToolCallParser | 'auto' | 'off';
901
+ /** Same semantics as tool_call_parser, for reasoning extraction. */
902
+ reasoning_parser?: InferenceReasoningParser | 'auto' | 'off';
903
+ /**
904
+ * Custom chat template (Jinja text, 64 KB max). Validated at save time and
905
+ * applied at the next restart. A template with a known tool format enables
906
+ * full tool support; an unknown format runs tools in best-effort mode.
907
+ */
908
+ chat_template?: string;
909
+ [key: string]: unknown;
910
+ }
911
+ export interface InferenceCreateParams {
912
+ name: string;
913
+ sourceType: 'checkpoint' | 'hf_model';
914
+ sourceJobId?: string;
915
+ sourceCheckpointId?: string;
916
+ hfModelId?: string;
917
+ /** Exact 40-hex commit returned by deployment preflight. */
918
+ hfModelRevision?: string;
919
+ hfIntegrationId?: string;
920
+ baseModelId?: string;
921
+ /** Exact base-model commit returned by deployment preflight. */
922
+ baseModelRevision?: string;
923
+ /** Optional assertion; the API derives the authoritative mode from the verified source artifact. */
924
+ servingMode?: 'full' | 'adapter' | 'merged';
925
+ modelTask?: 'chat' | 'completion' | 'embedding' | 'rerank';
926
+ supportsImages?: boolean;
927
+ gpuType: string;
928
+ gpuCount: number;
929
+ /** Primary plus ranked fallback GPU types; queueing requires 3-5 distinct types. */
930
+ gpuPriorities?: GPUChoice[];
931
+ /** Deployment serving currently supports only the secure capacity tier. */
932
+ gpuTier?: 'secure';
933
+ /** Explicit consent to wait up to seven days when the selected SKU is unavailable. */
934
+ allowCapacityQueue?: boolean;
935
+ /** Maximum accepted total hourly price across all selected GPUs, in cents. */
936
+ maxPriceHourCents?: number;
937
+ storageGb?: number;
938
+ contextLength?: number;
939
+ quant?: string;
940
+ servingConfig?: InferenceServingConfig;
941
+ }
942
+ export interface InferenceUpdateParams {
943
+ allowCapacityQueue?: boolean;
944
+ maxPriceHourCents?: number;
945
+ contextLength?: number;
946
+ quant?: string;
947
+ servingConfig?: InferenceServingConfig;
948
+ }
949
+ export interface InferenceDeployment {
950
+ id: string;
951
+ name: string;
952
+ model?: string;
953
+ workspace_id?: string;
954
+ status: InferenceStatus;
955
+ /** Stable machine-readable terminal reason; queue expiry is `queue_expired`. */
956
+ status_reason?: string | null;
957
+ /** Compatibility alias for status_reason. */
958
+ error_code?: string | null;
959
+ desired_state: 'running' | 'stopped';
960
+ source_type: 'checkpoint' | 'hf_model';
961
+ source_job_id?: string;
962
+ source_checkpoint_id?: string;
963
+ hf_model_id?: string;
964
+ hf_model_revision?: string | null;
965
+ base_model_id?: string;
966
+ base_model_revision?: string;
967
+ immutable_base_model_source?: string;
968
+ serving_mode?: 'full' | 'adapter' | 'merged';
969
+ supports_tool_calls?: boolean;
970
+ tool_call_parser?: InferenceToolCallParser | null;
971
+ reasoning_parser?: InferenceReasoningParser | null;
972
+ tool_call_mode?: InferenceToolCallMode;
973
+ tool_calls_unsupported_reason?: string;
974
+ tool_calls_note?: string;
975
+ model_task?: 'chat' | 'completion' | 'embedding' | 'rerank';
976
+ architecture?: string;
977
+ params_total_b?: number;
978
+ is_moe?: boolean;
979
+ quantization?: string;
980
+ context_length?: number;
981
+ gpu_type: string;
982
+ gpu_count: number;
983
+ gpu_tier: 'secure';
984
+ gpu_provider?: string;
985
+ gpu_region?: string;
986
+ cost_per_hour_cents?: number;
987
+ max_price_hour_cents?: number;
988
+ allow_capacity_queue?: boolean;
989
+ queued_since?: string | null;
990
+ queue_expires_at?: string | null;
991
+ queue_position?: number | null;
992
+ gpu_priorities?: Array<{
993
+ gpu_type: string;
994
+ gpu_count: number;
995
+ provider?: string;
996
+ region?: string;
997
+ tier?: 'secure';
998
+ }>;
999
+ selected_gpu_rank?: number | null;
1000
+ queue?: InferenceQueue | null;
1001
+ provision_generation?: number;
1002
+ restart_generation?: number;
1003
+ restart_state?: 'idle' | 'in_progress' | 'waiting_ready';
1004
+ restart_requested_at?: string | null;
1005
+ restart_completed_at?: string | null;
1006
+ restart_claimed_until?: string | null;
1007
+ restart_last_error?: string | null;
1008
+ wallet_authorization_status?: 'active' | 'captured' | 'released' | 'refunded' | 'expired' | string;
1009
+ billing_contract_version?: number;
1010
+ endpoint_url?: string;
1011
+ inference_key_prefix?: string;
1012
+ last_error?: string;
1013
+ created_at: string;
1014
+ started_at?: string | null;
1015
+ stopped_at?: string | null;
1016
+ notification_delivery?: InferenceNotificationSummary;
1017
+ }
1018
+ export type InferenceNotificationState = 'pending' | 'sending' | 'delivered' | 'dead_letter';
1019
+ export interface InferenceNotification {
1020
+ id: number;
1021
+ deployment_id: string;
1022
+ event_type: string;
1023
+ template: string;
1024
+ template_data: Record<string, string>;
1025
+ idempotency_key: string;
1026
+ state: InferenceNotificationState;
1027
+ attempt_count: number;
1028
+ last_error?: string | null;
1029
+ created_at: string;
1030
+ updated_at: string;
1031
+ delivered_at?: string | null;
1032
+ dead_lettered_at?: string | null;
1033
+ }
1034
+ export interface InferenceNotificationSummary {
1035
+ pending: number;
1036
+ sending: number;
1037
+ delivered: number;
1038
+ dead_letter: number;
1039
+ }
1040
+ export interface InferenceNotificationListResponse {
1041
+ notifications: InferenceNotification[];
1042
+ }
1043
+ export interface InferenceCreateResponse {
1044
+ id: string;
1045
+ deployment_id: string;
1046
+ model: string;
1047
+ workspace_id: string;
1048
+ endpoint_url: string;
1049
+ status: InferenceStatus;
1050
+ /** Returned exactly once. Store it securely. */
1051
+ inference_key: string;
1052
+ inference_key_prefix: string;
1053
+ hf_model_revision?: string | null;
1054
+ base_model_revision: string;
1055
+ immutable_base_model_source: string;
1056
+ supports_tool_calls: boolean;
1057
+ tool_call_parser?: InferenceToolCallParser | null;
1058
+ reasoning_parser?: InferenceReasoningParser | null;
1059
+ tool_call_mode?: InferenceToolCallMode;
1060
+ tool_calls_unsupported_reason?: string;
1061
+ tool_calls_note?: string;
1062
+ gpu: string;
1063
+ gpu_provider: string;
1064
+ gpu_region: string;
1065
+ gpu_tier: 'secure';
1066
+ estimated_hourly_cents: number;
1067
+ max_price_hour_cents: number;
1068
+ /** Runtime-supported ranked choices whose frozen price is within the accepted cap. */
1069
+ eligible_gpu_choice_count: number;
1070
+ authorized_cents: number;
1071
+ gpu_priorities: Array<{
1072
+ gpu_type: string;
1073
+ gpu_count: number;
1074
+ provider?: string;
1075
+ region?: string;
1076
+ tier?: 'secure';
1077
+ }>;
1078
+ }
1079
+ export type InferenceListStatusFilter = 'all' | 'running' | 'provisioning' | 'stopped' | 'failed' | 'queued_capacity' | 'degraded' | 'paused_insufficient_funds' | 'crash_loop' | 'downloading_weights' | 'loading_model';
1080
+ export interface InferenceListParams {
1081
+ /** Bounded page size. The server defaults to 50 and caps at 200. */
1082
+ limit?: number;
1083
+ /** Opaque nextCursor returned by the preceding page. */
1084
+ cursor?: string;
1085
+ status?: InferenceListStatusFilter;
1086
+ /** Case-insensitive deployment-name prefix, maximum 120 characters. */
1087
+ search?: string;
1088
+ }
1089
+ export interface InferenceListResponse {
1090
+ deployments: InferenceDeployment[];
1091
+ has_more: boolean;
1092
+ next_cursor?: string | null;
1093
+ limit: number;
1094
+ }
1095
+ export interface InferenceQueueChoice {
1096
+ choice_id?: string;
1097
+ rank: number;
1098
+ gpu_type: string;
1099
+ gpu_count: number;
1100
+ provider?: string;
1101
+ region?: string;
1102
+ tier?: 'secure';
1103
+ price_per_gpu_hour_cents?: number;
1104
+ total_price_hour_cents?: number;
1105
+ eligible: boolean;
1106
+ selected: boolean;
1107
+ }
1108
+ export interface InferenceQueue {
1109
+ request_id?: string | null;
1110
+ state?: string | null;
1111
+ position?: number | null;
1112
+ position_scope?: 'shared_capacity_fair_queue' | 'shared_capacity_position_unavailable';
1113
+ position_estimated?: boolean;
1114
+ position_as_of?: string | null;
1115
+ position_lower_bound?: number | null;
1116
+ position_truncated?: boolean;
1117
+ position_unavailable_reason?: string;
1118
+ priority?: number;
1119
+ enqueue_sequence?: number | null;
1120
+ deadline_at?: string | null;
1121
+ max_price_hour_cents?: number;
1122
+ eligible_gpu_choice_count?: number;
1123
+ all_choices?: InferenceQueueChoice[];
1124
+ selected_choice?: InferenceQueueChoice | null;
1125
+ allocation_claimed_until?: string | null;
1126
+ reservation_expires_at?: string | null;
1127
+ provision_retry_at?: string | null;
1128
+ last_error?: string | null;
1129
+ }
1130
+ export interface InferenceLifecycleResponse {
1131
+ status: string;
1132
+ action: 'stop' | 'resume' | 'restart';
1133
+ in_place?: boolean;
1134
+ restart_generation?: number;
1135
+ }
1136
+ export interface InferenceDeleteResponse {
1137
+ status: 'deleted' | 'deleting';
1138
+ detail?: string;
1139
+ }
1140
+ export interface InferenceUpdateResponse {
1141
+ status: 'updated' | string;
1142
+ restart_required: boolean;
1143
+ }
1144
+ export interface InferenceGPUOptionMarket {
1145
+ availability_status: 'available' | 'out_of_stock' | 'unknown';
1146
+ /** Null/omitted when provider inventory could not be verified. */
1147
+ available_count?: number | null;
1148
+ price_per_gpu_hour_cents: number;
1149
+ minimum_configuration_hour_cents: number;
1150
+ recommended_configuration_hour_cents: number;
1151
+ }
1152
+ export interface InferenceGPUOption {
1153
+ gpu_type: string;
1154
+ vram_gb: number;
1155
+ min_gpus: number;
1156
+ recommended_gpus: number;
1157
+ valid_counts?: number[];
1158
+ selectable: boolean;
1159
+ reason?: string;
1160
+ market?: InferenceGPUOptionMarket;
1161
+ }
1162
+ export interface InferenceGPUPlacementOption extends InferenceGPUOption {
1163
+ provider: string;
1164
+ region: string;
1165
+ tier: 'secure';
1166
+ market: InferenceGPUOptionMarket;
1167
+ }
1168
+ export interface InferenceGPUAlternative {
1169
+ gpu_type: string;
1170
+ gpu_count: number;
1171
+ vram_gb: number;
1172
+ price_hour_cents: number;
1173
+ availability_status: 'available' | 'out_of_stock' | 'unknown';
1174
+ }
1175
+ export interface InferenceGPUOptionsParams {
1176
+ paramsB: number;
1177
+ activeParamsB?: number;
1178
+ isMoe?: boolean;
1179
+ quant?: string;
1180
+ contextLength?: number;
1181
+ kvHeads?: number;
1182
+ numLayers?: number;
1183
+ kvLayers?: number;
1184
+ headDim?: number;
1185
+ attention?: 'gqa' | 'mla';
1186
+ numAttentionHeads?: number;
1187
+ kvLoraRank?: number;
1188
+ qkRopeHeadDim?: number;
1189
+ gpuTier?: 'secure';
1190
+ }
1191
+ export interface InferenceGPUOptionsResponse {
1192
+ options: InferenceGPUOption[];
1193
+ /** Exact provider/region/tier markets; clients must select from this list. */
1194
+ placements: InferenceGPUPlacementOption[];
1195
+ cheapest_recommended?: InferenceGPUOption | null;
1196
+ best_available?: InferenceGPUAlternative | null;
1197
+ alternatives?: InferenceGPUAlternative[];
1198
+ availability_known: boolean;
1199
+ availability_checked_at?: string;
1200
+ }
1201
+ export interface InferencePreflightWarning {
1202
+ code: string;
1203
+ message: string;
1204
+ }
1205
+ export interface InferenceCanonicalRequest {
1206
+ name: string;
1207
+ source_type: 'checkpoint' | 'hf_model';
1208
+ source_job_id?: string;
1209
+ source_checkpoint_id?: string;
1210
+ hf_model_id?: string;
1211
+ hf_model_revision?: string;
1212
+ hf_integration_id?: string;
1213
+ base_model_id: string;
1214
+ base_model_revision: string;
1215
+ serving_mode?: 'full' | 'adapter' | 'merged';
1216
+ model_task?: 'chat' | 'completion' | 'embedding' | 'rerank';
1217
+ supports_images?: boolean;
1218
+ gpu_type: string;
1219
+ gpu_count: number;
1220
+ gpu_priorities?: Array<{
1221
+ gpu_type: string;
1222
+ gpu_count: number;
1223
+ provider?: string;
1224
+ region?: string;
1225
+ tier?: 'secure';
1226
+ }>;
1227
+ allow_capacity_queue: boolean;
1228
+ max_price_hour_cents: number;
1229
+ [key: string]: unknown;
1230
+ }
1231
+ export interface InferencePreflightResponse {
1232
+ valid: boolean;
1233
+ contract_version: 'deployment.v3' | string;
1234
+ request_hash: string;
1235
+ workspace_id: string;
1236
+ canonical_request: InferenceCanonicalRequest;
1237
+ model: {
1238
+ repo_id: string;
1239
+ revision: string;
1240
+ immutable_source: string;
1241
+ architecture: string;
1242
+ model_type: string;
1243
+ params_total_b: number;
1244
+ params_active_b: number;
1245
+ is_moe: boolean;
1246
+ native_max_context: number;
1247
+ quant_locked: boolean;
1248
+ supports_tool_calls: boolean;
1249
+ tool_call_parser?: InferenceToolCallParser | null;
1250
+ reasoning_parser?: InferenceReasoningParser | null;
1251
+ tool_call_mode?: InferenceToolCallMode;
1252
+ tool_calls_unsupported_reason?: string;
1253
+ tool_calls_note?: string;
1254
+ };
1255
+ selected_gpu: {
1256
+ gpu_type: string;
1257
+ gpu_count: number;
1258
+ provider: string;
1259
+ region: string;
1260
+ tier: 'secure';
1261
+ availability_status: 'available' | 'out_of_stock' | 'unknown';
1262
+ available_count: number;
1263
+ price_per_gpu_hour_cents: number;
1264
+ total_price_hour_cents: number;
1265
+ };
1266
+ gpu_options: InferenceGPUOption[];
1267
+ gpu_placements: InferenceGPUPlacementOption[];
1268
+ alternatives: InferenceGPUAlternative[];
1269
+ best_available?: InferenceGPUAlternative | null;
1270
+ availability_known: boolean;
1271
+ availability_checked_at: string;
1272
+ eligible_gpu_choice_count: number;
1273
+ supports_tool_calls: boolean;
1274
+ tool_call_parser?: InferenceToolCallParser | null;
1275
+ reasoning_parser?: InferenceReasoningParser | null;
1276
+ tool_call_mode?: InferenceToolCallMode;
1277
+ tool_calls_unsupported_reason?: string;
1278
+ tool_calls_note?: string;
1279
+ queue_eligible: boolean;
1280
+ queue_required: boolean;
1281
+ billing: {
1282
+ max_price_hour_cents: number;
1283
+ authorization_amount_cents: number;
1284
+ capture_amount_cents: number;
1285
+ authorization_ttl_seconds: number;
1286
+ authorization_mutates_balance: false;
1287
+ };
1288
+ warnings: InferencePreflightWarning[];
1289
+ }
1290
+ /** Adapter compatibility info. */
1291
+ export interface AdapterCompatibility {
1292
+ id: string;
1293
+ name: string;
1294
+ fullName: string;
1295
+ category: 'popular' | 'advanced' | 'specialized';
1296
+ description: string;
1297
+ compatible: boolean;
1298
+ reason: string | null;
1299
+ defaultConfig: Record<string, unknown>;
1300
+ rlhfAlgorithms: string[];
1301
+ }
1302
+ /** Response from the adapter compatibility endpoint. */
1303
+ export interface AdapterCompatibilityResponse {
1304
+ architecture: string;
1305
+ architectureName: string;
1306
+ type: 'llm' | 'vlm';
1307
+ trainingMethod: string;
1308
+ rlhfAlgorithm: string | null;
1309
+ unsupported: string | null;
1310
+ gated: boolean;
1311
+ adapters: AdapterCompatibility[];
1312
+ compatibleCount: number;
1313
+ incompatibleCount: number;
1314
+ }
1315
+ /** One entry in the supported-architecture registry. */
1316
+ export interface SupportedArchitecture {
1317
+ /** For inference: the HF architecture class (e.g. "LlamaForCausalLM"). For training: the arch key (e.g. "llama"). */
1318
+ architecture: string;
1319
+ display_name: string;
1320
+ /** Comma-separated HF model_type aliases this entry covers. */
1321
+ model_types: string;
1322
+ enabled: boolean;
1323
+ notes: string;
1324
+ }
1325
+ /** Which registry to read. */
1326
+ export type ArchitectureScope = 'inference' | 'training';
1327
+ /** Response from getSupportedArchitectures. When `count` is 0 the registry is empty (nothing is explicitly gated). */
1328
+ export interface SupportedArchitecturesResponse {
1329
+ scope: ArchitectureScope;
1330
+ architectures: SupportedArchitecture[];
1331
+ count: number;
1332
+ }
1333
+ /** Parameters for checking adapter compatibility. */
1334
+ export interface AdapterCompatibilityParams {
1335
+ /** Architecture key (e.g. "llama", "qwen2"). */
1336
+ architecture?: string;
1337
+ /** HuggingFace model_type for automatic architecture detection. */
1338
+ modelType?: string;
1339
+ /** Training method. Defaults to "sft". */
1340
+ trainingMethod?: TrainingMethod;
1341
+ /** RLHF algorithm (relevant when trainingMethod is "rlhf"). */
1342
+ rlhfAlgorithm?: RLHFAlgorithm;
1343
+ }
1344
+ /** An API key. */
1345
+ export interface ApiKey {
1346
+ id: string;
1347
+ name: string;
1348
+ prefix: string;
1349
+ /** The full key value — only present on creation. */
1350
+ key?: string;
1351
+ scopes: ApiKeyScope[];
1352
+ scope_preset: string;
1353
+ created_at: string;
1354
+ last_used_at?: string | null;
1355
+ expires_at?: string | null;
1356
+ status: 'active' | 'revoked' | 'expired';
1357
+ }
1358
+ /** Valid API key permission scope. */
1359
+ export type ApiKeyScope = 'models:read' | 'datasets:read' | 'datasets:write' | 'training:read' | 'training:write' | 'billing:read' | 'deployments:read' | 'deployments:write' | 'analytics:read' | 'integrations:read' | 'integrations:write';
1360
+ /** Result of introspecting an API key — shows what it can do. */
1361
+ export interface ApiKeyIntrospection {
1362
+ auth_type: 'api_key' | 'jwt';
1363
+ key_id: string | null;
1364
+ key_name: string | null;
1365
+ key_prefix: string | null;
1366
+ status: string;
1367
+ org: {
1368
+ id: string;
1369
+ name: string;
1370
+ };
1371
+ workspace: {
1372
+ id: string;
1373
+ name: string;
1374
+ };
1375
+ user: {
1376
+ id: string;
1377
+ name: string;
1378
+ email: string;
1379
+ role: string;
1380
+ };
1381
+ scopes: ApiKeyScope[];
1382
+ scope_preset: string;
1383
+ scope_details: Array<{
1384
+ scope: ApiKeyScope;
1385
+ description: string;
1386
+ tools: string[];
1387
+ sdk_methods: string[];
1388
+ }>;
1389
+ allowed_mcp_tools: string[];
1390
+ allowed_sdk_methods: string[];
1391
+ rate_limit: {
1392
+ requests_per_minute: number;
1393
+ requests_per_hour: number;
1394
+ };
1395
+ expires_at: string | null;
1396
+ created_at: string;
1397
+ last_used_at: string | null;
1398
+ }
1399
+ /** An organization. */
1400
+ export interface Organization {
1401
+ id: string;
1402
+ name: string;
1403
+ avatar_url?: string;
1404
+ created_at?: string;
1405
+ }
1406
+ /** An organization member. */
1407
+ export interface OrgMember {
1408
+ user_id: string;
1409
+ name: string;
1410
+ email: string;
1411
+ role: string;
1412
+ avatar_url?: string;
1413
+ joined_at?: string;
1414
+ }
1415
+ /** An organization invite. */
1416
+ export interface OrgInvite {
1417
+ id: string;
1418
+ email: string;
1419
+ role: string;
1420
+ status: string;
1421
+ created_at: string;
1422
+ expires_at?: string;
1423
+ }
1424
+ /** A workspace within an organization. */
1425
+ export interface Workspace {
1426
+ id: string;
1427
+ name: string;
1428
+ description?: string;
1429
+ org_id: string;
1430
+ created_at?: string;
1431
+ updated_at?: string;
1432
+ }
1433
+ /** A HuggingFace integration connection. */
1434
+ export interface Integration {
1435
+ id: string;
1436
+ provider: string;
1437
+ label: string;
1438
+ hf_username: string;
1439
+ key_last4: string;
1440
+ scope: string;
1441
+ status: string;
1442
+ created_at?: string;
1443
+ }
1444
+ /** Parameters for creating an integration. */
1445
+ export interface IntegrationCreateParams {
1446
+ /** Display label for this integration. */
1447
+ label: string;
1448
+ /** HuggingFace API key. */
1449
+ apiKey: string;
1450
+ /** Provider name. Defaults to "huggingface". */
1451
+ provider?: string;
1452
+ }
1453
+ /** Storage usage info. */
1454
+ export interface StorageUsage {
1455
+ total_bytes: number;
1456
+ object_count: number;
1457
+ by_type?: Record<string, number>;
1458
+ }
1459
+ /** A storage object. */
1460
+ export interface StorageObject {
1461
+ id: string;
1462
+ type: string;
1463
+ name: string;
1464
+ size_bytes: number;
1465
+ created_at: string;
1466
+ }