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,101 @@
1
+ /**
2
+ * View GPU pricing, availability, and get recommendations for your model.
3
+ */
4
+ export class GPU {
5
+ _http;
6
+ /** @internal */
7
+ constructor(_http) {
8
+ this._http = _http;
9
+ }
10
+ /**
11
+ * Get pricing and availability for all GPU types.
12
+ *
13
+ * Returns the full catalog of GPUs with per-hour pricing, VRAM,
14
+ * and which training methods each supports.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const pricing = await client.gpu.getPricing();
19
+ * for (const gpu of pricing.gpus) {
20
+ * console.log(`${gpu.display_name}: ${gpu.price_display} -- ${gpu.vram_gb}GB VRAM`);
21
+ * }
22
+ * ```
23
+ */
24
+ async getPricing() {
25
+ return this._http.fetchGet('/api/public/gpu-pricing');
26
+ }
27
+ /**
28
+ * Get authoritative, model-aware training GPU options with live stock,
29
+ * required counts, total prices, and alternatives when nothing is bookable.
30
+ */
31
+ async getOptions(params) {
32
+ const q = new URLSearchParams({
33
+ model_id: params.modelId,
34
+ train_type: String(params.trainType || params.adapter || 'lora'),
35
+ });
36
+ if (params.modelRevision)
37
+ q.set('model_revision', params.modelRevision);
38
+ if (params.integrationId)
39
+ q.set('integration_id', params.integrationId);
40
+ if (params.method)
41
+ q.set('method', params.method);
42
+ if (params.rlhfType)
43
+ q.set('rlhf_type', params.rlhfType);
44
+ if (params.modelParamsB !== undefined)
45
+ q.set('model_params_b', String(params.modelParamsB));
46
+ if (params.modelActiveParamsB !== undefined) {
47
+ q.set('model_active_params_b', String(params.modelActiveParamsB));
48
+ }
49
+ return this._http.fetchGet(`/api/training/gpu-options?${q}`);
50
+ }
51
+ /**
52
+ * Get the recommended GPU configuration for a specific model.
53
+ *
54
+ * Uses the model's parameter count and architecture to suggest
55
+ * the best GPU type and count for training.
56
+ *
57
+ * @param modelId - Full HuggingFace model ID (e.g. "meta-llama/Llama-3.1-8B-Instruct").
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const rec = await client.gpu.getRecommended('meta-llama/Llama-3.1-8B-Instruct');
62
+ * if (rec) {
63
+ * console.log(`Recommended: ${rec.display_name} x${rec.recommended_count}`);
64
+ * }
65
+ * ```
66
+ */
67
+ async getRecommended(modelId) {
68
+ const options = await this.getOptions({ modelId, trainType: 'lora', method: 'sft' });
69
+ const recommended = options.recommended;
70
+ if (!recommended)
71
+ return null;
72
+ const option = options.options.find((item) => item.gpu_type === recommended.gpu_type);
73
+ if (!option?.bookable)
74
+ return null;
75
+ // Preserve the legacy recommendation shape while deriving sizing, stock,
76
+ // and total cost from the same authoritative endpoint as job creation.
77
+ const pricing = await this.getPricing();
78
+ const catalog = pricing.gpus.find((item) => item.gpu_type === recommended.gpu_type);
79
+ const pricePerGPU = recommended.price_per_hour_cents || option.price_per_hour_cents;
80
+ return {
81
+ gpu_type: recommended.gpu_type,
82
+ display_name: catalog?.display_name || option.display_name,
83
+ vram_gb: catalog?.vram_gb || option.vram_gb,
84
+ tier: catalog?.tier || '',
85
+ best_for: catalog?.best_for || '',
86
+ max_gpu_count: catalog?.max_gpu_count || option.max_gpu_count,
87
+ default_storage_gb: recommended.storage_gb,
88
+ param_range: catalog?.param_range || '',
89
+ methods: catalog?.methods || '',
90
+ available: option.available,
91
+ available_count: option.available_count,
92
+ price_per_hour_cents: pricePerGPU,
93
+ price_display: catalog?.price_display || `$${(pricePerGPU / 100).toFixed(2)}/hr`,
94
+ recommended_count: recommended.gpu_count,
95
+ total_vram_gb: option.vram_gb * recommended.gpu_count,
96
+ estimated_cost_per_hour_cents: recommended.total_price_per_hour_cents,
97
+ model_params_b: options.model_params_b,
98
+ reason: 'Cheapest currently bookable configuration that meets the model and adapter requirements',
99
+ };
100
+ }
101
+ }
@@ -0,0 +1,82 @@
1
+ import type { HttpClient } from '../client.js';
2
+ import type { InferenceDeployment, InferenceCreateParams, InferenceCreateResponse, InferenceDeleteResponse, InferenceGPUOptionsParams, InferenceGPUOptionsResponse, InferenceLifecycleResponse, InferenceListParams, InferenceListResponse, InferenceNotificationListResponse, InferencePreflightResponse, InferenceUpdateResponse, InferenceUpdateParams } from '../types.js';
3
+ declare function buildInferenceRequest(params: InferenceCreateParams): Record<string, unknown>;
4
+ export interface ChatMessage extends Record<string, unknown> {
5
+ role: 'system' | 'developer' | 'user' | 'assistant' | 'tool' | 'function';
6
+ content?: unknown;
7
+ }
8
+ export interface FunctionTool extends Record<string, unknown> {
9
+ type: 'function';
10
+ function: {
11
+ name: string;
12
+ description?: string;
13
+ parameters?: Record<string, unknown>;
14
+ strict?: boolean;
15
+ };
16
+ }
17
+ export interface ChatCompletionParams extends Record<string, unknown> {
18
+ messages: ChatMessage[];
19
+ model?: string;
20
+ tools?: FunctionTool[];
21
+ toolChoice?: 'none' | 'auto' | 'required' | {
22
+ type: 'function';
23
+ function: {
24
+ name: string;
25
+ };
26
+ };
27
+ inferenceKey?: string;
28
+ idempotencyKey?: string;
29
+ requestId?: string;
30
+ signal?: AbortSignal;
31
+ }
32
+ export type ChatCompletionResponse = Record<string, unknown>;
33
+ export type ChatCompletionChunk = Record<string, unknown>;
34
+ export declare function validateChatRequest(body: Record<string, unknown>): void;
35
+ export declare function parseSSE(body: ReadableStream<Uint8Array>): AsyncGenerator<string>;
36
+ /**
37
+ * Inference surface. Combines control-plane management of model-serving
38
+ * deployments (`/api/inference*`) with OpenAI-compatible key-scoped inference
39
+ * (`/v1/chat/completions`). Requests are dispatched once; an idempotency header
40
+ * is forwarded but server-side replay is not assumed.
41
+ */
42
+ export declare class Inference {
43
+ private readonly key;
44
+ private readonly baseUrl;
45
+ private readonly timeout;
46
+ private readonly _http;
47
+ constructor(config?: {
48
+ inferenceKey?: string;
49
+ baseUrl?: string;
50
+ timeout?: number;
51
+ }, http?: HttpClient);
52
+ /** @internal Control-plane transport; present when constructed by the SDK client. */
53
+ private get http();
54
+ /** Side-effect-free validation with authoritative stock, prices, alternatives, and hold terms. */
55
+ preflight(params: InferenceCreateParams): Promise<InferencePreflightResponse>;
56
+ /** Create after preflight. Reuse idempotencyKey after a timeout to recover the same deployment and inference key. */
57
+ create(params: InferenceCreateParams, idempotencyKey: string): Promise<InferenceCreateResponse>;
58
+ /** Fetch one bounded newest-first page. Reuse next_cursor with unchanged filters. */
59
+ listPage(params?: InferenceListParams): Promise<InferenceListResponse>;
60
+ /** Compatibility helper returning only one bounded page. Prefer listPage for pagination. */
61
+ list(params?: InferenceListParams): Promise<InferenceDeployment[]>;
62
+ /** Lazily traverse pages without materializing an unbounded tenant list. */
63
+ iterate(params?: Omit<InferenceListParams, 'cursor'>): AsyncGenerator<InferenceDeployment, void, void>;
64
+ /** Current durable lifecycle, queue, price-cap, and wallet-authorization state. */
65
+ get(id: string): Promise<InferenceDeployment>;
66
+ /** Alias for get(), useful in polling automations. */
67
+ status(id: string): Promise<InferenceDeployment>;
68
+ /** Durable email delivery history, including bounded retries and dead letters. */
69
+ notifications(id: string, limit?: number): Promise<InferenceNotificationListResponse['notifications']>;
70
+ stop(id: string): Promise<InferenceLifecycleResponse>;
71
+ resume(id: string): Promise<InferenceLifecycleResponse>;
72
+ restart(id: string): Promise<InferenceLifecycleResponse>;
73
+ update(id: string, params: InferenceUpdateParams): Promise<InferenceUpdateResponse>;
74
+ delete(id: string): Promise<InferenceDeleteResponse>;
75
+ /** Model-fit GPU choices joined to the authoritative deployment market snapshot. */
76
+ getGPUOptions(params: InferenceGPUOptionsParams): Promise<InferenceGPUOptionsResponse>;
77
+ private prepare;
78
+ private abortContext;
79
+ chatCompletions(params: ChatCompletionParams): Promise<ChatCompletionResponse>;
80
+ streamChatCompletions(params: ChatCompletionParams): AsyncGenerator<ChatCompletionChunk>;
81
+ }
82
+ export { buildInferenceRequest };