TypeScript SDK

TypeScript SDK

The official TypeScript SDK for the BiOS fine-tuning platform. Build, train, and manage models programmatically with full type safety.

Installation

bash
npm install @usfbios/sdk

Requires Node.js 18+ or any runtime with native fetch support.

API Key Setup

Before using the SDK, create an API key from the BIOS console:

  1. Sign in at https://bios.us.com with your account (e.g. bios@us.inc).
  2. Navigate to Settings → API Keys in the dashboard sidebar.
  3. Click Create API Key and enter a name (e.g. “SDK Development”).
  4. Select the permission scopes your application needs:
ScopeGrants access to
models:readSearch models, fetch configs, check adapter compatibility
datasets:readList datasets, preview rows, check status
datasets:writeUpload, import, validate, and delete datasets
training:readList jobs, view metrics, logs, and checkpoints
training:writeCreate, stop, resume, and delete training jobs
deployments:readPreflight, list, and monitor model-serving inference endpoints
deployments:writeCreate, update, stop, restart, and delete inference endpoints
billing:readView wallet balance and transaction history
analytics:readView usage, audit, training, and inference analytics
integrations:readList connected integrations
integrations:writeConnect and manage HuggingFace integrations
  1. Click Create and copy the key (starts with sk_live_). It is shown only once.
i
Each API key is bound to exactly one workspace in one organization. If you need access to multiple workspaces, create a separate key for each. The SDK resolves the org and workspace automatically from the key, no extra headers needed.

Configuration

Initialize the client with your API key:

typescript
import { USFBios } from '@usfbios/sdk';

const client = new USFBios({
  apiKey: process.env.USFBIOS_API_KEY,  // sk_live_...
});

All configuration options:

OptionTypeDefaultDescription
apiKeystring-API key (recommended). Starts with sk_live_.
accessTokenstring-JWT token (alternative to API key).
baseUrlstringhttps://api.usbios.aiAPI base URL.
orgIdstring-Organization ID (required with JWT, auto-resolved with API key).
workspaceIdstring-Workspace ID (required with JWT, auto-resolved with API key).
timeoutnumber30000Request timeout in milliseconds.

You can also introspect your API key to check permissions:

typescript
const info = await client.introspect();
console.log(`Org: ${info.org.name}`);
console.log(`Workspace: ${info.workspace.name}`);
console.log(`Scopes: ${info.scopes.join(', ')}`);

Resources & Methods

The SDK is organized into resource namespaces. Each method is fully typed with request parameters and response objects.

Models

Search the model catalog, fetch training configs, and check adapter compatibility.

typescript
// Search for models
const results = await client.models.search({
  query: 'llama',
  type: 'llm',
  limit: 10,
});
for (const m of results.models) {
  console.log(`${m.id} - ${m.totalParams}B params`);
}

// Get model config for GPU planning
const config = await client.models.getConfig('meta-llama/Llama-3.1-8B');
console.log(`${config.totalParams}B params, MoE: ${config.isMoE}`);

// Check adapter compatibility
const compat = await client.models.getAdapterCompatibility({
  modelType: 'llama',
  trainingMethod: 'rlhf',
  rlhfAlgorithm: 'dpo',
});
const usable = compat.adapters.filter(a => a.compatible);
console.log(`${usable.length} compatible adapters`);
MethodScopeDescription
models.search(params?)models:readSearch 250+ fine-tunable models
models.getConfig(modelId)models:readGet training config (params, architecture, MoE)
models.getAdapterCompatibility(params?)models:readCheck adapter compatibility for architecture

Datasets

Upload, import, preview, validate, and manage training datasets.

typescript
// Upload a local dataset file
const ds = await client.datasets.upload({
  filePath: './training_data.jsonl',
  name: 'Customer Support SFT',
});
console.log(`Uploaded: ${ds.id}`);

// List all datasets
const datasets = await client.datasets.list();
console.log(`${datasets.length} datasets`);

// Preview rows before training
const preview = await client.datasets.preview('ds_abc123', {
  page: 1,
  pageSize: 5,
});
console.log(preview.columns);

// Validate a file before uploading
const result = await client.datasets.validate('./data.jsonl');
if (result.valid) {
  console.log(`Valid ${result.format} - ${result.row_count} rows`);
} else {
  console.error('Errors:', result.errors);
}

// Import from HuggingFace
const imported = await client.datasets.importFromHuggingFace({
  repoId: 'databricks/dolly-15k',
  integrationId: 'int_abc123',
  name: 'Dolly 15k',
});

// Search HuggingFace Hub
const hubResults = await client.datasets.searchHub({ query: 'code instruct' });

// Delete a dataset
await client.datasets.delete('ds_abc123');
MethodScopeDescription
datasets.list(params?)datasets:readList datasets in workspace
datasets.get(id)datasets:readGet dataset details
datasets.upload(params)datasets:writeUpload a local file (JSONL, CSV, Parquet)
datasets.preview(id, params?)datasets:readPreview rows with pagination
datasets.getStatus(id)datasets:readGet processing status
datasets.validate(filePath)datasets:writeValidate file format before upload
datasets.importFromHuggingFace(params)datasets:writeImport from HuggingFace via integration
datasets.registerHuggingFace(data)datasets:writeRegister a public HF dataset directly
datasets.searchHub(params?)datasets:readSearch public HuggingFace Hub datasets
datasets.previewHub(params)datasets:readPreview rows from a HF Hub dataset
datasets.getFormatSpecs()datasets:readGet supported format specifications
datasets.getStorageUsage(workspaceId?)datasets:readGet storage usage summary
datasets.delete(id)datasets:writeDelete a dataset

Training

Create, monitor, stop, and resume fine-tuning jobs.

typescript
// Create a training job
const job = await client.training.create({
  idempotencyKey: 'training-create-20260711-0001',
  model: 'meta-llama/Llama-3.1-8B-Instruct',
  datasetId: 'ds_abc123',
  method: 'sft',
  adapter: 'lora',
  epochs: 3,
  learningRate: 2e-4,
  loraRank: 16,
  loraAlpha: 32,
  gpuType: 'A100_80GB',
});
console.log(`Job ${job.id} created - status: ${job.status}`);

// Monitor training
const metrics = await client.training.getMetrics(job.id);
console.log(`Loss: ${metrics.current_loss}`);

// View logs
const logs = await client.training.getLogs(job.id);
for (const line of logs.logs) {
  console.log(line);
}

// List checkpoints
const checkpoints = await client.training.getCheckpoints(job.id);
for (const cp of checkpoints) {
  console.log(`Step ${cp.step}: loss ${cp.loss}`);
}

// Stop and resume
await client.training.stop(job.id);
await client.training.resume(job.id, 'training-resume-20260711-0001');
MethodScopeDescription
training.create(params)training:writeLaunch a new fine-tuning job
training.list(params?)training:readList jobs with optional filters
training.get(id)training:readGet job details
training.getMetrics(id)training:readGet loss curves, LR, throughput
training.getCheckpoints(id)training:readList saved checkpoints
training.getLogs(id)training:readGet training stdout/stderr logs
training.stop(id, keepData?)training:writeStop a running job
training.resume(id, idempotencyKey?)training:writeResume from last checkpoint
training.deleteCheckpoint(jobId, cpId)training:writeDelete a specific checkpoint

Billing & GPU

Check wallet balance, view transactions, get GPU pricing, and get hardware recommendations.

typescript
// Check wallet balance
const balance = await client.wallet.getBalance();
console.log(`Balance: $${(balance.balance_cents / 100).toFixed(2)}`);
console.log(`Available: $${(balance.available_cents / 100).toFixed(2)}`);

// View transaction history
const txns = await client.wallet.getTransactions({ limit: 20 });
for (const t of txns) {
  console.log(`${t.type}: $${(t.amount_cents / 100).toFixed(2)} - ${t.description}`);
}

// Get GPU pricing
const pricing = await client.gpu.getPricing();
for (const gpu of pricing.gpus) {
  console.log(`${gpu.display_name}: ${gpu.price_display} - ${gpu.vram_gb}GB VRAM`);
}

// Get recommended GPU for a model
const rec = await client.gpu.getRecommended('meta-llama/Llama-3.1-8B-Instruct');
if (rec) {
  console.log(`Recommended: ${rec.display_name} x${rec.recommended_count}`);
  console.log(`Estimated cost: $${(rec.estimated_cost_per_hour_cents / 100).toFixed(2)}/hr`);
}
MethodScopeDescription
wallet.getBalance()billing:readCurrent balance, available credits, pending charges
wallet.getTransactions(params?)billing:readTransaction history with pagination
wallet.getPricing()billing:readCompute and storage pricing
gpu.getPricing()(public)All GPU types with per-second pricing and VRAM
gpu.getRecommended(modelId)(public)Best GPU configuration for a model

Integrations

The SDK accesses integrations through the datasets resource for HuggingFace import workflows:

typescript
// Import from a connected HuggingFace account
const imported = await client.datasets.importFromHuggingFace({
  repoId: 'your-org/private-dataset',
  integrationId: 'int_abc123',   // from connected HF account
  name: 'My Private Dataset',
  split: 'train',
  maxSamples: 10000,
});
console.log(`Imported: ${imported.id} - ${imported.row_count} rows`);

Error Handling

All SDK methods throw ApiError on non-2xx responses with typed error details:

typescript
import { USFBios, ApiError } from '@usfbios/sdk';

const client = new USFBios({ apiKey: process.env.USFBIOS_API_KEY });

try {
  const job = await client.training.get('job_nonexistent');
} catch (err) {
  if (err instanceof ApiError) {
    console.error(`HTTP ${err.status}: ${err.message}`);
    console.error(`Code: ${err.code}`);           // e.g. "NOT_FOUND"
    console.error(`Request ID: ${err.requestId}`); // for support
  }
}

// Common error status codes:
// 401 - Invalid or expired API key
// 403 - Key missing required scope
// 404 - Resource not found
// 422 - Validation error
// 429 - Rate limit exceeded

TypeScript Support

The SDK ships with full TypeScript definitions. All request parameters and response types are exported:

typescript
import type {
  USFBiosConfig,
  ModelSearchParams,
  ModelSearchResponse,
  ModelConfig,
  Dataset,
  DatasetUploadParams,
  TrainingJob,
  TrainingCreateParams,
  TrainingMetrics,
  TrainingCheckpoint,
  WalletBalance,
  Transaction,
  GPUPricingResponse,
  ApiKeyIntrospection,
} from '@usfbios/sdk';
i
The SDK version is sent as the User-Agent header with every request for debugging and support.

BiOS Documentation. Need help? Email help-bios@us.inc