@spekoai/sdk
Official TypeScript SDK — one API, every voice provider.
@spekoai/sdk is the server-side TypeScript SDK for the Speko voice gateway. It wraps the one-shot proxy endpoints — /v1/transcribe, /v1/synthesize, /v1/complete — plus usage, credits, realtime S2S, outbound voice dialing, phone numbers, agents, registered tools, and knowledge bases. Speko benchmarks providers per (language, region, optimizeFor) and routes each STT, LLM, and TTS call to the best available option. Failover is handled server-side. You ship one integration; providers rotate without a code change.
Install
npm install @spekoai/sdk
# or
pnpm add @spekoai/sdkRuntime: Node 18+ (uses global fetch and AbortController). Also works in Bun, Deno, and any runtime with fetch.
Quickstart
import { Speko } from '@spekoai/sdk';
import { readFile } from 'node:fs/promises';
const speko = new Speko({ apiKey: process.env.SPEKO_API_KEY! });
// Transcribe
const audio = await readFile('./call.wav');
const { text, provider, confidence } = await speko.transcribe(audio, {
language: 'es-MX',
});
// Synthesize
const speech = await speko.synthesize('Hello world', {
language: 'en',
});
// Complete
const { text: reply } = await speko.complete({
messages: [{ role: 'user', content: 'Hi!' }],
intent: { language: 'en' },
});What the router does
Every routed one-shot call takes a RoutingIntent (language, optional region and optimizeFor). Speko scores every provider for that intent against its continuously-updated benchmark set, picks the top-ranked one, and fails over to the next-best if the primary errors. Response headers (X-Speko-Provider, X-Speko-Model, X-Speko-Failover-Count, X-Speko-Scores-Run-Id) are surfaced on every result object so you can log what actually ran.
If you need to restrict the pool (for compliance, cost caps, or pinning a provider while debugging), pass constraints.allowedProviders[modality]. The router still ranks by score — it just picks the top-ranked candidate from your allow-list.
Cancellation
Every method accepts an optional AbortSignal as the last argument. The signal is composed with the client's timeout (30 s by default), so external cancellation wins whenever it fires first. Frameworks like @spekoai/adapter-livekit pass their own signals through when a session tears down mid-call.
Errors
All API failures throw SpekoApiError or one of its subclasses:
SpekoAuthError— 401, bad or missing API key.SpekoRateLimitError— 429, carriesretryAfterseconds parsed fromRetry-After.SpekoApiError— any other non-2xx response.statusandcodeare populated from the JSON body.
See Errors for details.
Reference
Speko client
Constructor, options, concurrency, auth.
transcribe
POST /v1/transcribe.
synthesize
POST /v1/synthesize.
complete
POST /v1/complete.
realtime
Speech-to-speech WebSocket sessions.
voice
Outbound phone calls.
phone numbers
Managed numbers, SIP imports, and business verification.
calls
Call detail, events, reports, recordings, and transfers.
callbacks
Scheduled follow-up calls.
usage
GET /v1/usage.
credits
Balance and ledger.
agents
Persisted voice personas and registered tools.
Types
Shared request / response types.
Errors
Exception classes.