spine-sdk
v0.2.1
Published
Official TypeScript SDK for the Spine API — canvas runs, polling, artifacts.
Readme
spine-sdk
Official TypeScript SDK for the Spine API.
Universal runtime support: Node 18+, modern browsers, Deno, Bun, and Cloudflare Workers.
Install
npm install spine-sdkQuickstart
import { Spine } from 'spine-sdk';
const client = new Spine({ apiKey: process.env.SPINE_API_KEY! });
const run = await client.runs.create({
prompt: 'Draft a 2-pager on quantum batteries',
template: 'report',
});
const result = await client.runs.waitForCompletion(run.run_id);
if (result.status === 'completed') {
for (const artifact of result.result.artifacts) {
console.log(artifact.name, artifact.download_url);
}
}Documentation
Full reference, guides, and examples: https://docs.getspine.ai/sdks/typescript
Features
- Typed discriminated unions for run status (
running/completed/partial/failed) — compiler guides you through status narrowing. waitForCompletionhelper with configurable polling, timeout, andAbortSignalsupport.- Automatic retry with jittered exponential backoff on transient 5xx errors.
- Typed error hierarchy:
SpineBadRequestError,SpineAuthError,SpineNotFoundError,SpineServerError,SpineConnectionError,SpineTimeoutError,SpineRunFailedError,SpineWebhookSignatureError. client.webhooks.constructEvent(body, sigHeader, secret)— verify inbound webhook signatures and parse the event, using WebCrypto (no new dependencies).- Universal file uploads via native
FormData— acceptsFile,Blob,ArrayBuffer,Uint8Array. - Zero runtime dependencies.
Requirements
- Node.js 18 or later (for native
fetch). - A Spine API key — create one at platform.getspine.ai.
License
MIT
