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.
new Speko(options)
SpekoClientOptions
| Field | Type | Default | Description |
|---|---|---|---|
apiKey | string | — (required) | API key. Get one at dashboard.speko.ai/api-keys. Throws if missing. |
baseUrl | string? | https://api.speko.ai | Override the proxy base URL — useful for staging, self-hosted deploys, or local development. |
timeout | number? | 30000 | Per-request timeout in milliseconds. Applied via an internal AbortController composed with external ones. |
baseUrl is stripped automatically.
Instance properties
speko.usage— aUsageresource for billing queries.speko.credits— aCreditsresource for balance and ledger queries.speko.realtime— aRealtimeresource 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.
AbortSignal and compose it with the client’s timeout.
Authentication
Requests sendAuthorization: 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 internalfetch calls are fully independent; each builds its own AbortController.