Skip to main content
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.ai', // optional
  timeout: 30_000,                  // optional, ms
});

new Speko(options)

SpekoClientOptions

FieldTypeDefaultDescription
apiKeystring— (required)API key. Get one at dashboard.speko.ai/api-keys. Throws if missing.
baseUrlstring?https://api.speko.aiOverride the proxy base URL — useful for staging, 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.

Instance methods

  • speko.transcribe(audio, options, abortSignal?) — see transcribe.
  • speko.synthesize(text, options, abortSignal?) — see synthesize.
  • speko.complete(params, abortSignal?) — see complete.
All three accept a trailing AbortSignal and compose it with the client’s timeout.

Authentication

Requests send Authorization: Bearer <apiKey>. The SDK sets a User-Agent of @spekoai/sdk/<version> 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.