JavaScript SDK

TypeScript-first AlphaChat client with streaming support.

Installation

npm install alphachat

Chat Completions

import { AlphaChat } from 'alphachat';

const client = new AlphaChat({ apiKey: 'sk-alphachat-xxxxx' });

// Non-streaming
const response = await client.chat.completions.create({
  model: 'deepseek-v4-flash',
  messages: [{ role: 'user', content: 'hello' }],
});
console.log(response.choices[0].message.content);

// Streaming
const stream = await client.chat.completions.create({
  model: 'deepseek-v4-flash',
  messages: [{ role: 'user', content: 'explain quantum computing' }],
  stream: true,
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0].delta.content || '');
}

Training

// Submit job
const job = await client.training.createJob({
  base_model: 'deepseek-v4-flash',
  training_data_url: 's3://bucket/data.jsonl',
  mode: 'lora',
  security_mode: 'private',
  budget_usd: 50.0,
});

// Check status
const status = await client.training.getJob(job.job_id);

// List jobs
const jobs = await client.training.listJobs();

// Cancel
await client.training.cancelJob(job.job_id);

// Estimate cost
const estimate = await client.training.estimate('deepseek-v4-flash');

Other Methods

const models = await client.models();
const balance = await client.balance();
console.log(`Balance: $${balance.balance_usd}`);

TypeScript Types

import type {
  AlphaChatConfig,
  ChatCompletionRequest,
  ChatCompletion,
  ChatCompletionChunk,
  ChatMessage,
  Usage,
} from 'alphachat';