spekoai is the Python counterpart to @spekoai/sdk. The surface mirrors the TypeScript client one-to-one: transcribe, synthesize, complete, usage, credits, plus an async-only connect_realtime for speech-to-speech sessions.
Speko benchmarks every STT, LLM, and TTS provider per (language, vertical, optimize_for) and routes each call to the best one in real time. Failover is server-side — you ship one integration; providers rotate without a code change.
Install
httpx, pydantic, and websockets.
Quickstart
What the router does
Every proxy call takes aRoutingIntent (language, vertical, optional optimize_for). 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. The returned result carries provider, model, failover_count, and scores_run_id so you can log what actually ran.
To restrict the pool — for compliance, cost caps, or pinning a provider while debugging — pass constraints=PipelineConstraints(allowed_providers=AllowedProviders(stt=[...], llm=[...], tts=[...])). The router still ranks by score but only considers candidates on the allow-list.
Pydantic models, camelCase wire
All request/response models use camelCase aliases over the wire and snake_case attributes in Python. You can pass plaindicts wherever a model is accepted — the SDK validates them.
Reference
transcribe
POST /v1/transcribe — speech to text.synthesize
POST /v1/synthesize — text to speech.complete
POST /v1/complete — LLM completion.connect_realtime
Speech-to-speech WebSocket sessions (async only).
usage
GET /v1/usage — billing summary.credits
Prepaid balance and append-only ledger.
errors
SpekoApiError, SpekoAuthError, SpekoRateLimitError.Client options
| Option | Default | Description |
|---|---|---|
api_key | — (required) | Your API key. Mint one at dashboard.speko.ai/api-keys. |
base_url | https://api.speko.ai | Override for staging or self-hosted. Trailing slash is stripped. |
timeout | 30.0 | Per-request timeout in seconds. |
Speko is a sync context manager (__enter__ / __exit__ / close()); AsyncSpeko is an async context manager (__aenter__ / __aexit__ / await close()).