Intent
Routing hint type and construction-time validator.
Intent is the routing hint every adapter class takes. It's a re-export of RoutingIntent from @spekoai/sdk, so anything you already have typed as a RoutingIntent passes through without conversion.
import type { Intent, OptimizeFor } from '@spekoai/adapter-livekit';Type
type Intent = {
language: string; // BCP-47
region?: string; // e.g. "global", "us-east4", "europe-west3"
optimizeFor?: 'balanced' | 'accuracy' | 'latency' | 'cost';
};validateIntent(intent)
Throws a descriptive Error when the intent is malformed. Called by every adapter class constructor, so a bad intent fails at construction time rather than deep inside the first STT / LLM / TTS call.
import { validateIntent } from '@spekoai/adapter-livekit';
validateIntent({ language: 'en-US' });
// ok
validateIntent({ language: '' });
// throws: SpekoAdapter: intent.language is required (BCP-47 tag)
validateIntent({ language: 'en', optimizeFor: 'speed' as any });
// throws: SpekoAdapter: unknown optimizeFor "speed". Expected one of: balanced, accuracy, latency, cost.Validation rules:
languagemust be a non-empty string.region, if set, is forwarded to Speko for region-aware latency ranking.optimizeFor, if set, must be one ofbalanced,accuracy,latency,cost.
No BCP-47 syntactic validation beyond "is a non-empty string" — the router accepts short codes (en) and region-tagged codes (es-MX) and normalises downstream.
Sharing one intent
The adapter pattern is "one intent per agent session, shared across modalities":
const intent: Intent = { language: 'en-US', region: 'global', optimizeFor: 'latency' };
const { stt, llm, tts } = createSpekoComponents({ speko, vad, intent });If you need per-modality divergence (e.g. latency-optimised STT with cost-optimised TTS), construct the classes directly:
const sttAdapter = new SpekoSTT({ speko, intent: { ...intent, optimizeFor: 'latency' } });
const ttsAdapter = new SpekoTTS({ speko, intent: { ...intent, optimizeFor: 'cost' } });