Speko Docs

Speko client

Construct the SDK client and configure transport options.

The Speko class is the single entry point. Construct it once per process and reuse it — HTTP keep-alive, auth headers, and timeout state are all bound to the instance.

import { Speko } from '@spekoai/sdk';

const speko = new Speko({
  apiKey: process.env.SPEKO_API_KEY!,
  baseUrl: 'https://api.speko.dev', // optional
  timeout: 30_000, // optional, ms
});

new Speko(options)

SpekoClientOptions

FieldTypeDefaultDescription
apiKeystring— (required)API key. Get one at platform.speko.dev/api-keys. Throws if missing.
baseUrlstring?https://api.speko.devOverride the proxy base URL — useful for self-hosted deploys or local development.
timeoutnumber?30000Per-request timeout in milliseconds. Applied via an internal AbortController composed with external ones.

A trailing slash on baseUrl is stripped automatically.

Instance properties

  • speko.usage — a Usage resource for billing queries.
  • speko.credits — a Credits resource for balance and ledger queries.
  • speko.realtime — a Realtime resource for opening speech-to-speech sessions.
  • speko.voice — outbound phone-call helpers backed by /v1/sessions/phone.
  • speko.phoneNumbers — provision, list, update, release, and verify organization phone numbers.
  • speko.agents — manage persisted voice personas and their registered tools.
  • speko.calls — inspect calls, events, reports, recordings, and transfers.
  • speko.callbacks — list, cancel, and dispatch scheduled callbacks.
  • speko.knowledgeBases — manage per-agent knowledge bases and document uploads.

Instance methods

  • speko.transcribe(audio, options, abortSignal?) — see transcribe.
  • speko.transcribeStream(audio, options, abortSignal?) — transcript SSE events.
  • speko.synthesize(text, options, abortSignal?) — see synthesize.
  • speko.synthesizeStream(text, options, abortSignal?) — chunked audio bytes.
  • speko.complete(params, abortSignal?) — see complete.
  • speko.completeStream(params, abortSignal?) — completion SSE events.

All proxy methods accept a trailing AbortSignal and compose it with the client's timeout.

Authentication

Requests send Authorization: Bearer <apiKey>. The SDK sets a package User-Agent on every request. Non-2xx responses are parsed as { error, code } JSON when possible and re-thrown as SpekoApiError (or its SpekoAuthError / SpekoRateLimitError subclass).

Concurrency

The client is safe to share across concurrent requests — it holds no per-call mutable state. The internal fetch calls are fully independent; each builds its own AbortController.

On this page