TypeScript SDK
Official TypeScript SDK for the Bastion sovereign Canadian LLM API. Typed clients for chat, models, images, speech, and transcription.
@qubittron/bastion-sdk is the official TypeScript SDK for Bastion. It wraps the OpenAI-compatible HTTP API with strongly typed resources, async iterables for streaming, and a structured error hierarchy. It runs on Node 20+, Bun, Deno, Cloudflare Workers, Vercel Edge, and modern browsers.
npm install @qubittron/bastion-sdkimport { Bastion } from "@qubittron/bastion-sdk";
const client = new Bastion({ apiKey: process.env.BASTION_API_KEY });
const res = await client.chat.completions.create({
model: "gpt-oss-120b",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(res.choices[0]?.message.content);Getting started
Install the SDK, configure a client, and make your first request.
API reference
Every public class, method, and type — generated from the SDK source.
Guides
Streaming, errors, runtime environments, and custom fetch.
Examples
Copy-paste recipes for common integrations.
Best practices
Secrets handling, retries, timeouts, and observability.
What's in the box
| Resource | Methods |
|---|---|
client.chat.completions | create() — sync + streaming chat completions |
client.models | list() — list available models for your account |
client.images | generate() — text-to-image generation |
client.audio | speech() — TTS via NVIDIA Riva |
client.audio.transcriptions | create() — speech-to-text (Whisper) |
All resources return strongly typed responses. Streaming returns an AsyncIterable over typed chunks. Errors throw subclasses of BastionError (AuthenticationError, RateLimitError, UpstreamError, …) so you can branch on instanceof.
Versioning
Pre-1.0 (v0.x) the public surface may change between minors. Pin to a minor for production. The SDK reads BASTION_API_KEY from the environment when no apiKey is passed, so promotion across environments is just an env-var swap.
Source
The SDK lives at packages/sdk in the Bastion monorepo. Issues and feature requests go on the main repo.