@spekoai/sdk 0.0.3 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.1] - 2026-04-26
11
+
12
+ ### Added
13
+
14
+ - `RoutingIntent.region` — optional string forwarded to the gateway as
15
+ `intent.region`. Set when latency to a specific geography matters
16
+ (e.g. `'us-east4'`, `'eu-west1'`); STT/TTS rankings differ per
17
+ region. Omitting it preserves the previous behaviour: the server
18
+ defaults to `'global'`, which surfaces the region-agnostic (batch)
19
+ benchmark rows. Plumbed through `transcribe()`, `synthesize()`, and
20
+ `complete({ intent })`.
21
+
22
+ ## [0.2.0] - 2026-04-26
23
+
24
+ ### Removed
25
+
26
+ - **BREAKING**: `RoutingIntent.vertical` removed (and the `Vertical`
27
+ union type along with it). The router now ranks on
28
+ `(language, optimizeFor)` only. Callers passing `vertical` will fail
29
+ to type-check; the gateway also rejects the field. Old persisted
30
+ session pipeline configs containing `vertical` are tolerated server-
31
+ side.
32
+
10
33
  ## [0.0.3] - 2026-04-13
11
34
 
12
35
  ### Fixed
package/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  Official TypeScript SDK for [Speko](https://speko.ai) — one API, every voice provider.
4
4
 
5
5
  Speko is a voice AI gateway that benchmarks every STT, LLM, and TTS provider
6
- across languages and verticals, then routes each request to the best provider
7
- in real time. Failover is handled. You write one integration; Speko picks the
6
+ across languages, then routes each request to the best provider in real
7
+ time. Failover is handled. You write one integration; Speko picks the
8
8
  right provider for every call.
9
9
 
10
10
  ## Installation
@@ -25,23 +25,22 @@ import { readFile } from 'node:fs/promises';
25
25
 
26
26
  const speko = new Speko({ apiKey: process.env.SPEKO_API_KEY });
27
27
 
28
- // Transcribe — best STT provider auto-routed for your language + vertical
28
+ // Transcribe — best STT provider auto-routed for your language
29
29
  const audio = await readFile('./call.wav');
30
30
  const { text, provider, confidence } = await speko.transcribe(audio, {
31
31
  language: 'es-MX',
32
- vertical: 'healthcare',
32
+ region: 'us-east4', // optional — rank streaming providers in this region
33
33
  });
34
34
 
35
35
  // Synthesize — best TTS provider auto-routed
36
36
  const speech = await speko.synthesize('Hello world', {
37
37
  language: 'en',
38
- vertical: 'general',
39
38
  });
40
39
 
41
40
  // Complete — best LLM provider auto-routed
42
41
  const { text: reply } = await speko.complete({
43
42
  messages: [{ role: 'user', content: 'Hi!' }],
44
- intent: { language: 'en', vertical: 'general' },
43
+ intent: { language: 'en' },
45
44
  });
46
45
  ```
47
46
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { Speko } from './lib/client.js';
2
2
  export { SpekoApiError, SpekoAuthError, SpekoRateLimitError } from './lib/errors.js';
3
- export type { SpekoClientOptions, PipelineConfig, CreateSessionParams, Session, SessionDetail, UsageSummary, UsageByProvider, UsageQueryParams, Vertical, OptimizeFor, RoutingIntent, TranscribeOptions, TranscribeResult, SynthesizeOptions, SynthesizeResult, ChatMessage, CompleteParams, CompleteResult, } from './lib/types/index.js';
3
+ export type { SpekoClientOptions, KeySource, UsageSummary, UsageByProvider, UsageQueryParams, OrganizationBalance, CreditLedgerEntry, CreditLedgerKind, CreditLedgerPage, CreditLedgerQueryParams, OptimizeFor, RoutingIntent, PipelineConstraints, TranscribeOptions, TranscribeResult, SynthesizeOptions, SynthesizeResult, ChatMessage, CompleteParams, CompleteResult, RealtimeProvider, RealtimeToolSpec, RealtimeConnectParams, RealtimeFrame, RealtimeEventHandler, RealtimeSessionHandle, } from './lib/types/index.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACrF,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,OAAO,EACP,aAAa,EACb,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,cAAc,GACf,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACrF,YAAY,EACV,kBAAkB,EAClB,SAAS,EACT,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import type { CompleteParams, CompleteResult, SpekoClientOptions, SynthesizeOptions, SynthesizeResult, TranscribeOptions, TranscribeResult } from './types/index.js';
2
- import { Sessions } from './resources/sessions.js';
3
2
  import { Usage } from './resources/usage.js';
3
+ import { Credits } from './resources/credits.js';
4
+ import { Realtime } from './resources/realtime.js';
4
5
  /**
5
6
  * Speko client — one API, every voice provider.
6
7
  *
@@ -12,21 +13,20 @@ import { Usage } from './resources/usage.js';
12
13
  *
13
14
  * const { text, provider } = await speko.transcribe(audioBytes, {
14
15
  * language: 'es-MX',
15
- * vertical: 'healthcare',
16
16
  * });
17
17
  * ```
18
18
  */
19
19
  export declare class Speko {
20
- /** Real-time voice sessions over LiveKit (back-compat path). */
21
- readonly sessions: Sessions;
22
20
  readonly usage: Usage;
21
+ readonly credits: Credits;
22
+ readonly realtime: Realtime;
23
23
  private readonly transcribeResource;
24
24
  private readonly synthesizeResource;
25
25
  private readonly completeResource;
26
26
  constructor(options: SpekoClientOptions);
27
27
  /**
28
28
  * Transcribe audio. The router picks the best STT provider for your
29
- * `(language, vertical, optimizeFor)` and fails over automatically.
29
+ * `(language, optimizeFor)` and fails over automatically.
30
30
  *
31
31
  * Pass an `AbortSignal` to cancel the in-flight request — useful when a
32
32
  * calling framework (e.g. LiveKit Agents) tears down a session mid-call.
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAQ7C;;;;;;;;;;;;;;GAcG;AACH,qBAAa,KAAK;IAChB,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAEtB,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAa;IAChD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAa;IAChD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAW;gBAEhC,OAAO,EAAE,kBAAkB;IAoBvC;;;;;;OAMG;IACH,UAAU,CACR,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,iBAAiB,EAC1B,WAAW,CAAC,EA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B,EAC1B,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,gBAAgB,CAAC;IAI5B;;;OAGG;IACH,QAAQ,CACN,MAAM,EAAE,cAAc,EACtB,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,cAAc,CAAC;CAG3B"}
@@ -1,9 +1,10 @@
1
1
  import { HttpClient } from './http.js';
2
- import { Sessions } from './resources/sessions.js';
3
2
  import { Usage } from './resources/usage.js';
3
+ import { Credits } from './resources/credits.js';
4
4
  import { Transcribe } from './resources/transcribe.js';
5
5
  import { Synthesize } from './resources/synthesize.js';
6
6
  import { Complete } from './resources/complete.js';
7
+ import { Realtime } from './resources/realtime.js';
7
8
  const DEFAULT_BASE_URL = 'https://api.speko.ai';
8
9
  const DEFAULT_TIMEOUT = 30_000;
9
10
  /**
@@ -17,14 +18,13 @@ const DEFAULT_TIMEOUT = 30_000;
17
18
  *
18
19
  * const { text, provider } = await speko.transcribe(audioBytes, {
19
20
  * language: 'es-MX',
20
- * vertical: 'healthcare',
21
21
  * });
22
22
  * ```
23
23
  */
24
24
  export class Speko {
25
- /** Real-time voice sessions over LiveKit (back-compat path). */
26
- sessions;
27
25
  usage;
26
+ credits;
27
+ realtime;
28
28
  transcribeResource;
29
29
  synthesizeResource;
30
30
  completeResource;
@@ -37,15 +37,16 @@ export class Speko {
37
37
  apiKey: options.apiKey,
38
38
  timeout: options.timeout ?? DEFAULT_TIMEOUT,
39
39
  });
40
- this.sessions = new Sessions(http);
41
40
  this.usage = new Usage(http);
41
+ this.credits = new Credits(http);
42
+ this.realtime = new Realtime(http);
42
43
  this.transcribeResource = new Transcribe(http);
43
44
  this.synthesizeResource = new Synthesize(http);
44
45
  this.completeResource = new Complete(http);
45
46
  }
46
47
  /**
47
48
  * Transcribe audio. The router picks the best STT provider for your
48
- * `(language, vertical, optimizeFor)` and fails over automatically.
49
+ * `(language, optimizeFor)` and fails over automatically.
49
50
  *
50
51
  * Pass an `AbortSignal` to cancel the in-flight request — useful when a
51
52
  * calling framework (e.g. LiveKit Agents) tears down a session mid-call.
@@ -5,13 +5,13 @@ export declare class Complete {
5
5
  constructor(http: HttpClient);
6
6
  /**
7
7
  * Run an LLM completion. The Speko router picks the best provider for your
8
- * `(language, vertical, optimizeFor)` and falls over automatically.
8
+ * `(language, optimizeFor)` and falls over automatically.
9
9
  *
10
10
  * @example
11
11
  * ```ts
12
12
  * const { text, provider } = await speko.complete({
13
13
  * messages: [{ role: 'user', content: 'Hi!' }],
14
- * intent: { language: 'en', vertical: 'general' },
14
+ * intent: { language: 'en' },
15
15
  * });
16
16
  * ```
17
17
  */
@@ -5,13 +5,13 @@ export class Complete {
5
5
  }
6
6
  /**
7
7
  * Run an LLM completion. The Speko router picks the best provider for your
8
- * `(language, vertical, optimizeFor)` and falls over automatically.
8
+ * `(language, optimizeFor)` and falls over automatically.
9
9
  *
10
10
  * @example
11
11
  * ```ts
12
12
  * const { text, provider } = await speko.complete({
13
13
  * messages: [{ role: 'user', content: 'Hi!' }],
14
- * intent: { language: 'en', vertical: 'general' },
14
+ * intent: { language: 'en' },
15
15
  * });
16
16
  * ```
17
17
  */
@@ -0,0 +1,28 @@
1
+ import type { HttpClient } from '../http.js';
2
+ import type { CreditLedgerPage, CreditLedgerQueryParams, OrganizationBalance } from '../types/index.js';
3
+ /**
4
+ * Prepaid credit balance + append-only ledger. Balance is reported in
5
+ * micro-USD (`1_000_000` µ$ = $1) alongside a float USD helper.
6
+ */
7
+ export declare class Credits {
8
+ private readonly http;
9
+ constructor(http: HttpClient);
10
+ /**
11
+ * Current credit balance for the caller's organization.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const { balanceUsd } = await speko.credits.getBalance();
16
+ * if (balanceUsd < 0.5) showLowBalanceBanner();
17
+ * ```
18
+ */
19
+ getBalance(): Promise<OrganizationBalance>;
20
+ /**
21
+ * Most-recent-first page of credit movements (grants, debits, topups,
22
+ * refunds, adjustments). `nextCursor` is the `createdAt` of the last
23
+ * entry on the current page — pass it back as `cursor` to fetch the
24
+ * next page; `null` means no more pages.
25
+ */
26
+ getLedger(params?: CreditLedgerQueryParams): Promise<CreditLedgerPage>;
27
+ }
28
+ //# sourceMappingURL=credits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credits.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/credits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B;;;GAGG;AACH,qBAAa,OAAO;IACN,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;OAQG;IACH,UAAU,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAI1C;;;;;OAKG;IACH,SAAS,CAAC,MAAM,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAUvE"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Prepaid credit balance + append-only ledger. Balance is reported in
3
+ * micro-USD (`1_000_000` µ$ = $1) alongside a float USD helper.
4
+ */
5
+ export class Credits {
6
+ http;
7
+ constructor(http) {
8
+ this.http = http;
9
+ }
10
+ /**
11
+ * Current credit balance for the caller's organization.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const { balanceUsd } = await speko.credits.getBalance();
16
+ * if (balanceUsd < 0.5) showLowBalanceBanner();
17
+ * ```
18
+ */
19
+ getBalance() {
20
+ return this.http.get('/v1/credits/balance');
21
+ }
22
+ /**
23
+ * Most-recent-first page of credit movements (grants, debits, topups,
24
+ * refunds, adjustments). `nextCursor` is the `createdAt` of the last
25
+ * entry on the current page — pass it back as `cursor` to fetch the
26
+ * next page; `null` means no more pages.
27
+ */
28
+ getLedger(params) {
29
+ const query = new URLSearchParams();
30
+ if (params?.limit)
31
+ query.set('limit', String(params.limit));
32
+ if (params?.cursor)
33
+ query.set('cursor', params.cursor);
34
+ const qs = query.toString();
35
+ return this.http.get(`/v1/credits/ledger${qs ? `?${qs}` : ''}`);
36
+ }
37
+ }
@@ -0,0 +1,15 @@
1
+ import type { HttpClient } from '../http.js';
2
+ import type { RealtimeConnectParams, RealtimeSessionHandle } from '../types/index.js';
3
+ export declare class Realtime {
4
+ private readonly http;
5
+ constructor(http: HttpClient);
6
+ /**
7
+ * Open a speech-to-speech session. Posts `/v1/sessions` with `mode: 's2s'`
8
+ * to mint a short-lived WebSocket token, then opens a direct WS to the
9
+ * server's S2S proxy. The proxy bridges to the underlying provider
10
+ * (OpenAI Realtime, Gemini Live, xAI Grok Voice) so the client sees a
11
+ * single transport regardless of which backend is in use.
12
+ */
13
+ connect(params: RealtimeConnectParams): Promise<RealtimeSessionHandle>;
14
+ }
15
+ //# sourceMappingURL=realtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"realtime.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/realtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,qBAAqB,EAGrB,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAU3B,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;OAMG;IACG,OAAO,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CA2B7E"}
@@ -0,0 +1,173 @@
1
+ export class Realtime {
2
+ http;
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /**
7
+ * Open a speech-to-speech session. Posts `/v1/sessions` with `mode: 's2s'`
8
+ * to mint a short-lived WebSocket token, then opens a direct WS to the
9
+ * server's S2S proxy. The proxy bridges to the underlying provider
10
+ * (OpenAI Realtime, Gemini Live, xAI Grok Voice) so the client sees a
11
+ * single transport regardless of which backend is in use.
12
+ */
13
+ async connect(params) {
14
+ const response = await this.http.post('/v1/sessions', {
15
+ mode: 's2s',
16
+ s2s: {
17
+ provider: params.provider,
18
+ model: params.model,
19
+ voice: params.voice,
20
+ systemPrompt: params.systemPrompt,
21
+ temperature: params.temperature,
22
+ inputSampleRate: params.inputSampleRate,
23
+ outputSampleRate: params.outputSampleRate,
24
+ tools: params.tools,
25
+ },
26
+ metadata: params.metadata,
27
+ ttlSeconds: params.ttlSeconds,
28
+ });
29
+ return new BrowserRealtimeHandle(response.sessionId, response.wsUrl, response.wsToken, response.expiresAt);
30
+ }
31
+ }
32
+ class BrowserRealtimeHandle {
33
+ sessionId;
34
+ expiresAt;
35
+ ws;
36
+ handlers = new Set();
37
+ closed = false;
38
+ constructor(sessionId, wsUrl, wsToken, expiresAt) {
39
+ this.sessionId = sessionId;
40
+ this.expiresAt = expiresAt;
41
+ // Pass the token as the first subprotocol — browsers can't set headers
42
+ // on `new WebSocket()`, so subprotocol is the only auth carrier that
43
+ // doesn't leak through URL params.
44
+ this.ws = new WebSocket(wsUrl, [wsToken]);
45
+ this.ws.binaryType = 'arraybuffer';
46
+ this.ws.addEventListener('message', (evt) => {
47
+ this.dispatchIncoming(evt.data);
48
+ });
49
+ this.ws.addEventListener('close', (evt) => {
50
+ this.closed = true;
51
+ this.emit({ type: 'close', code: evt.code, reason: evt.reason });
52
+ });
53
+ this.ws.addEventListener('error', () => {
54
+ this.emit({
55
+ type: 'error',
56
+ code: 'WS_ERROR',
57
+ message: 'WebSocket transport error',
58
+ });
59
+ });
60
+ }
61
+ sendAudio(pcm) {
62
+ if (this.closed || this.ws.readyState !== 1)
63
+ return;
64
+ // Copy to ensure we send a plain ArrayBuffer, not a typed-array view that
65
+ // might alias a SharedArrayBuffer.
66
+ const copy = new Uint8Array(pcm.byteLength);
67
+ copy.set(pcm);
68
+ this.ws.send(copy.buffer);
69
+ }
70
+ commit() {
71
+ this.sendControl('commit');
72
+ }
73
+ interrupt() {
74
+ this.sendJson({ t: 'interrupt' });
75
+ }
76
+ sendToolResult(callId, output) {
77
+ this.sendJson({ t: 'tool_result', callId, output });
78
+ }
79
+ on(handler) {
80
+ this.handlers.add(handler);
81
+ return () => {
82
+ this.handlers.delete(handler);
83
+ };
84
+ }
85
+ close(code = 1000, reason = 'client_closed') {
86
+ if (this.closed)
87
+ return;
88
+ this.closed = true;
89
+ try {
90
+ this.ws.close(code, reason);
91
+ }
92
+ catch {
93
+ // ignore
94
+ }
95
+ }
96
+ sendControl(action) {
97
+ this.sendJson({ t: 'control', action });
98
+ }
99
+ sendJson(payload) {
100
+ if (this.closed || this.ws.readyState !== 1)
101
+ return;
102
+ try {
103
+ this.ws.send(JSON.stringify(payload));
104
+ }
105
+ catch {
106
+ // ignore
107
+ }
108
+ }
109
+ dispatchIncoming(data) {
110
+ if (data instanceof ArrayBuffer) {
111
+ this.emit({
112
+ type: 'audio',
113
+ pcm: new Uint8Array(data),
114
+ sampleRate: 24000,
115
+ });
116
+ return;
117
+ }
118
+ if (typeof data !== 'string')
119
+ return;
120
+ let parsed;
121
+ try {
122
+ parsed = JSON.parse(data);
123
+ }
124
+ catch {
125
+ return;
126
+ }
127
+ const t = parsed['t'];
128
+ switch (t) {
129
+ case 'transcript':
130
+ this.emit({
131
+ type: 'transcript',
132
+ role: parsed['role'],
133
+ text: String(parsed['text'] ?? ''),
134
+ final: Boolean(parsed['final']),
135
+ });
136
+ break;
137
+ case 'tool_call':
138
+ this.emit({
139
+ type: 'tool_call',
140
+ callId: String(parsed['callId'] ?? ''),
141
+ name: String(parsed['name'] ?? ''),
142
+ arguments: String(parsed['arguments'] ?? ''),
143
+ });
144
+ break;
145
+ case 'usage':
146
+ this.emit({
147
+ type: 'usage',
148
+ inputAudioTokens: Number(parsed['inputAudioTokens'] ?? 0),
149
+ outputAudioTokens: Number(parsed['outputAudioTokens'] ?? 0),
150
+ });
151
+ break;
152
+ case 'error':
153
+ this.emit({
154
+ type: 'error',
155
+ code: String(parsed['code'] ?? 'UNKNOWN'),
156
+ message: String(parsed['message'] ?? ''),
157
+ });
158
+ break;
159
+ default:
160
+ break;
161
+ }
162
+ }
163
+ emit(frame) {
164
+ for (const handler of this.handlers) {
165
+ try {
166
+ handler(frame);
167
+ }
168
+ catch {
169
+ // swallow — a misbehaving handler shouldn't break the pump
170
+ }
171
+ }
172
+ }
173
+ }
@@ -5,7 +5,7 @@ export declare class Synthesize {
5
5
  constructor(http: HttpClient);
6
6
  /**
7
7
  * Synthesize text into audio. The Speko router picks the best TTS provider
8
- * for your `(language, vertical, optimizeFor)` and falls over automatically.
8
+ * for your `(language, optimizeFor)` and falls over automatically.
9
9
  *
10
10
  * The returned audio's format depends on the chosen provider — check the
11
11
  * `contentType` field on the result. ElevenLabs returns `audio/mpeg`,
@@ -15,7 +15,6 @@ export declare class Synthesize {
15
15
  * ```ts
16
16
  * const result = await speko.synthesize('Hello world', {
17
17
  * language: 'en',
18
- * vertical: 'general',
19
18
  * });
20
19
  * await writeFile(`out.${result.contentType.includes('mpeg') ? 'mp3' : 'pcm'}`, result.audio);
21
20
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"synthesize.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/synthesize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;;;;;;;;;OAgBG;IACG,IAAI,CACR,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB,EAC1B,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,gBAAgB,CAAC;CA2B7B"}
1
+ {"version":3,"file":"synthesize.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/synthesize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;;;;;;;;OAeG;IACG,IAAI,CACR,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB,EAC1B,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,gBAAgB,CAAC;CA4B7B"}
@@ -5,7 +5,7 @@ export class Synthesize {
5
5
  }
6
6
  /**
7
7
  * Synthesize text into audio. The Speko router picks the best TTS provider
8
- * for your `(language, vertical, optimizeFor)` and falls over automatically.
8
+ * for your `(language, optimizeFor)` and falls over automatically.
9
9
  *
10
10
  * The returned audio's format depends on the chosen provider — check the
11
11
  * `contentType` field on the result. ElevenLabs returns `audio/mpeg`,
@@ -15,7 +15,6 @@ export class Synthesize {
15
15
  * ```ts
16
16
  * const result = await speko.synthesize('Hello world', {
17
17
  * language: 'en',
18
- * vertical: 'general',
19
18
  * });
20
19
  * await writeFile(`out.${result.contentType.includes('mpeg') ? 'mp3' : 'pcm'}`, result.audio);
21
20
  * ```
@@ -23,7 +22,7 @@ export class Synthesize {
23
22
  async call(text, options, abortSignal) {
24
23
  const intent = {
25
24
  language: options.language,
26
- vertical: options.vertical,
25
+ ...(options.region !== undefined && { region: options.region }),
27
26
  ...(options.optimizeFor !== undefined && { optimizeFor: options.optimizeFor }),
28
27
  };
29
28
  const body = { text, intent };
@@ -31,6 +30,8 @@ export class Synthesize {
31
30
  body['voice'] = options.voice;
32
31
  if (options.speed !== undefined)
33
32
  body['speed'] = options.speed;
33
+ if (options.constraints !== undefined)
34
+ body['constraints'] = options.constraints;
34
35
  const { bytes, headers } = await this.http.requestBinary('POST', '/v1/synthesize', body, abortSignal);
35
36
  return {
36
37
  audio: bytes,
@@ -5,14 +5,13 @@ export declare class Transcribe {
5
5
  constructor(http: HttpClient);
6
6
  /**
7
7
  * Transcribe audio. The Speko router picks the best STT provider for
8
- * your `(language, vertical, optimizeFor)` and falls over automatically.
8
+ * your `(language, optimizeFor)` and falls over automatically.
9
9
  *
10
10
  * @example
11
11
  * ```ts
12
12
  * const audio = await readFile('./call.wav');
13
13
  * const { text, provider, confidence } = await speko.transcribe(audio, {
14
14
  * language: 'es-MX',
15
- * vertical: 'healthcare',
16
15
  * });
17
16
  * ```
18
17
  */
@@ -1 +1 @@
1
- {"version":3,"file":"transcribe.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/transcribe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;;;;;OAYG;IACG,IAAI,CACR,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,iBAAiB,EAC1B,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,gBAAgB,CAAC;CAkB7B"}
1
+ {"version":3,"file":"transcribe.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/transcribe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;;;;OAWG;IACG,IAAI,CACR,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,iBAAiB,EAC1B,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,gBAAgB,CAAC;CAuB7B"}
@@ -5,26 +5,29 @@ export class Transcribe {
5
5
  }
6
6
  /**
7
7
  * Transcribe audio. The Speko router picks the best STT provider for
8
- * your `(language, vertical, optimizeFor)` and falls over automatically.
8
+ * your `(language, optimizeFor)` and falls over automatically.
9
9
  *
10
10
  * @example
11
11
  * ```ts
12
12
  * const audio = await readFile('./call.wav');
13
13
  * const { text, provider, confidence } = await speko.transcribe(audio, {
14
14
  * language: 'es-MX',
15
- * vertical: 'healthcare',
16
15
  * });
17
16
  * ```
18
17
  */
19
18
  async call(audio, options, abortSignal) {
20
19
  const intent = {
21
20
  language: options.language,
22
- vertical: options.vertical,
21
+ ...(options.region !== undefined && { region: options.region }),
23
22
  ...(options.optimizeFor !== undefined && { optimizeFor: options.optimizeFor }),
24
23
  };
25
- return this.http.requestRaw('POST', '/v1/transcribe', audio, {
24
+ const headers = {
26
25
  'Content-Type': options.contentType ?? 'audio/wav',
27
26
  'X-Speko-Intent': JSON.stringify(intent),
28
- }, abortSignal);
27
+ };
28
+ if (options.constraints) {
29
+ headers['X-Speko-Constraints'] = JSON.stringify(options.constraints);
30
+ }
31
+ return this.http.requestRaw('POST', '/v1/transcribe', audio, headers, abortSignal);
29
32
  }
30
33
  }
@@ -7,65 +7,23 @@ export interface SpekoClientOptions {
7
7
  /** Request timeout in milliseconds. Defaults to 30000. */
8
8
  timeout?: number;
9
9
  }
10
- /** Pipeline configuration for a voice session. */
11
- export interface PipelineConfig {
12
- stt: {
13
- provider: string;
14
- model?: string;
15
- language?: string;
16
- keywords?: string[];
17
- };
18
- llm: {
19
- provider: string;
20
- model: string;
21
- systemPrompt?: string;
22
- temperature?: number;
23
- maxTokens?: number;
24
- };
25
- tts: {
26
- provider: string;
27
- voice: string;
28
- model?: string;
29
- speed?: number;
30
- };
31
- }
32
- /** Parameters for creating a session. */
33
- export interface CreateSessionParams {
34
- pipeline: PipelineConfig;
35
- metadata?: Record<string, unknown>;
36
- }
37
- /** A voice session returned by the API. */
38
- export interface Session {
39
- id: string;
40
- status: 'created' | 'connecting' | 'active' | 'ended' | 'failed';
41
- roomName: string;
42
- token: string;
43
- livekitUrl: string;
44
- createdAt: string;
45
- }
46
- /** A session detail object. */
47
- export interface SessionDetail {
48
- id: string;
49
- workspaceId: string;
50
- status: 'created' | 'connecting' | 'active' | 'ended' | 'failed';
51
- roomName: string;
52
- pipelineConfig: PipelineConfig;
53
- metadata: Record<string, unknown>;
54
- createdAt: string;
55
- updatedAt: string;
56
- endedAt: string | null;
57
- }
10
+ /** BYOK = customer key, no Speko charge. MANAGED = platform key, billed. */
11
+ export type KeySource = 'BYOK' | 'MANAGED';
58
12
  /** Usage record for a workspace. */
59
13
  export interface UsageSummary {
60
14
  totalSessions: number;
61
15
  totalMinutes: number;
62
16
  totalCost: number;
63
17
  breakdown: UsageByProvider[];
18
+ /** Current organization balance in micro-USD (1_000_000 µ$ = $1), as string. */
19
+ balanceMicroUsd: string;
20
+ balanceUsd: number;
64
21
  }
65
22
  export interface UsageByProvider {
66
23
  provider: string;
67
24
  type: 'stt' | 'llm' | 'tts';
68
25
  metric: string;
26
+ keySource: KeySource;
69
27
  quantity: number;
70
28
  cost: number;
71
29
  }
@@ -76,20 +34,63 @@ export interface UsageQueryParams {
76
34
  /** End date (ISO 8601). */
77
35
  to?: string;
78
36
  }
79
- /** Vertical labels supported by the router. */
80
- export type Vertical = 'general' | 'healthcare' | 'finance' | 'legal';
37
+ /** Current prepaid credit balance. */
38
+ export interface OrganizationBalance {
39
+ balanceMicroUsd: string;
40
+ balanceUsd: number;
41
+ updatedAt: string;
42
+ }
43
+ export type CreditLedgerKind = 'grant' | 'debit' | 'topup' | 'refund' | 'adjustment';
44
+ export interface CreditLedgerEntry {
45
+ id: string;
46
+ kind: CreditLedgerKind;
47
+ /** Signed. Positive for grants/topups/refunds, negative for debits. */
48
+ amountMicroUsd: string;
49
+ metric: string | null;
50
+ provider: string | null;
51
+ sessionId: string | null;
52
+ createdAt: string;
53
+ }
54
+ export interface CreditLedgerPage {
55
+ entries: CreditLedgerEntry[];
56
+ /** Pass back as `cursor` for the next page, or null if exhausted. */
57
+ nextCursor: string | null;
58
+ }
59
+ export interface CreditLedgerQueryParams {
60
+ limit?: number;
61
+ cursor?: string;
62
+ }
81
63
  /** Optimization preset that biases the router's weighted score. */
82
64
  export type OptimizeFor = 'balanced' | 'accuracy' | 'latency' | 'cost';
83
65
  /** Routing intent passed to the proxy primitives. */
84
66
  export interface RoutingIntent {
85
67
  /** BCP-47 language tag, e.g. "en" or "es-MX". */
86
68
  language: string;
87
- vertical: Vertical;
69
+ /**
70
+ * Region to rank streaming providers in (e.g. `"us-east4"`, `"eu-west1"`).
71
+ * Defaults to `"global"` on the server, which surfaces region-agnostic
72
+ * (batch) benchmark rows. Set this when latency to a specific
73
+ * geography matters — STT/TTS rankings differ per region.
74
+ */
75
+ region?: string;
88
76
  optimizeFor?: OptimizeFor;
89
77
  }
78
+ /**
79
+ * Optional constraints layered on top of `RoutingIntent`. The router still
80
+ * ranks candidates by benchmark score — but if `allowedProviders[modality]`
81
+ * is set and non-empty, it only considers that subset.
82
+ */
83
+ export interface PipelineConstraints {
84
+ allowedProviders?: {
85
+ stt?: string[];
86
+ llm?: string[];
87
+ tts?: string[];
88
+ };
89
+ }
90
90
  export interface TranscribeOptions extends RoutingIntent {
91
91
  /** MIME type of the audio body. Defaults to "audio/wav". */
92
92
  contentType?: string;
93
+ constraints?: PipelineConstraints;
93
94
  }
94
95
  export interface TranscribeResult {
95
96
  text: string;
@@ -103,6 +104,7 @@ export interface SynthesizeOptions extends RoutingIntent {
103
104
  /** Optional voice override. Otherwise the SDK uses each provider's default. */
104
105
  voice?: string;
105
106
  speed?: number;
107
+ constraints?: PipelineConstraints;
106
108
  }
107
109
  export interface SynthesizeResult {
108
110
  /** Raw audio bytes. Format depends on the chosen provider — see `contentType`. */
@@ -124,6 +126,7 @@ export interface CompleteParams {
124
126
  systemPrompt?: string;
125
127
  temperature?: number;
126
128
  maxTokens?: number;
129
+ constraints?: PipelineConstraints;
127
130
  }
128
131
  export interface CompleteResult {
129
132
  text: string;
@@ -136,4 +139,71 @@ export interface CompleteResult {
136
139
  failoverCount: number;
137
140
  scoresRunId: string | null;
138
141
  }
142
+ export type RealtimeProvider = 'openai' | 'google' | 'xai';
143
+ export interface RealtimeToolSpec {
144
+ name: string;
145
+ description: string;
146
+ parameters: Record<string, unknown>;
147
+ }
148
+ export interface RealtimeConnectParams {
149
+ provider: RealtimeProvider;
150
+ model: string;
151
+ voice?: string;
152
+ systemPrompt?: string;
153
+ temperature?: number;
154
+ inputSampleRate?: 16000 | 24000;
155
+ outputSampleRate?: 16000 | 24000;
156
+ tools?: RealtimeToolSpec[];
157
+ metadata?: Record<string, unknown>;
158
+ /** Max session duration in seconds. Server-capped at 1800 (30 min). */
159
+ ttlSeconds?: number;
160
+ }
161
+ /**
162
+ * Event shape emitted by a `RealtimeSessionHandle`. Binary audio comes in
163
+ * as `audio` frames; text control messages come through typed variants.
164
+ */
165
+ export type RealtimeFrame = {
166
+ type: 'audio';
167
+ pcm: Uint8Array;
168
+ sampleRate: number;
169
+ } | {
170
+ type: 'transcript';
171
+ role: 'user' | 'assistant';
172
+ text: string;
173
+ final: boolean;
174
+ } | {
175
+ type: 'tool_call';
176
+ callId: string;
177
+ name: string;
178
+ arguments: string;
179
+ } | {
180
+ type: 'usage';
181
+ inputAudioTokens: number;
182
+ outputAudioTokens: number;
183
+ } | {
184
+ type: 'error';
185
+ code: string;
186
+ message: string;
187
+ } | {
188
+ type: 'close';
189
+ code: number;
190
+ reason: string;
191
+ };
192
+ export type RealtimeEventHandler = (frame: RealtimeFrame) => void;
193
+ export interface RealtimeSessionHandle {
194
+ readonly sessionId: string;
195
+ readonly expiresAt: string;
196
+ /** Send a PCM16 audio chunk up to the model. */
197
+ sendAudio(pcm: Uint8Array): void;
198
+ /** Signal user-turn boundary / commit the input buffer. */
199
+ commit(): void;
200
+ /** Interrupt the current assistant response. */
201
+ interrupt(): void;
202
+ /** Return a previously-requested tool call result. */
203
+ sendToolResult(callId: string, output: string): void;
204
+ /** Subscribe to frames. Returns an unsubscribe callback. */
205
+ on(handler: RealtimeEventHandler): () => void;
206
+ /** Close the session. Safe to call multiple times. */
207
+ close(code?: number, reason?: string): void;
208
+ }
139
209
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/types/index.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,kDAAkD;AAClD,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE;QACH,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;IACF,GAAG,EAAE;QACH,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,GAAG,EAAE;QACH,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,yCAAyC;AACzC,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,cAAc,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,2CAA2C;AAC3C,MAAM,WAAW,OAAO;IACtB,EAAE,E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.1",
4
4
  "description": "Official Speko TypeScript SDK — one API, every voice provider",
5
5
  "license": "MIT",
6
6
  "author": "Speko",
@@ -1,44 +0,0 @@
1
- import type { HttpClient } from '../http.js';
2
- import type { CreateSessionParams, Session, SessionDetail } from '../types/index.js';
3
- export declare class Sessions {
4
- private readonly http;
5
- constructor(http: HttpClient);
6
- /**
7
- * Create a new voice session.
8
- *
9
- * @example
10
- * ```ts
11
- * const session = await speko.sessions.create({
12
- * pipeline: {
13
- * stt: { provider: 'deepgram' },
14
- * llm: { provider: 'openai', model: 'gpt-4o' },
15
- * tts: { provider: 'elevenlabs', voice: 'rachel' },
16
- * },
17
- * });
18
- * console.log(session.token); // Use to connect via LiveKit
19
- * ```
20
- */
21
- create(params: CreateSessionParams): Promise<Session>;
22
- /**
23
- * Get a session by ID.
24
- *
25
- * @example
26
- * ```ts
27
- * const session = await speko.sessions.get('sess_abc123');
28
- * ```
29
- */
30
- get(sessionId: string): Promise<SessionDetail>;
31
- /**
32
- * End an active session.
33
- *
34
- * @example
35
- * ```ts
36
- * await speko.sessions.end('sess_abc123');
37
- * ```
38
- */
39
- end(sessionId: string): Promise<{
40
- id: string;
41
- status: string;
42
- }>;
43
- }
44
- //# sourceMappingURL=sessions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,mBAAmB,EACnB,OAAO,EACP,aAAa,EACd,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;;;;;;;OAcG;IACG,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAI3D;;;;;;;OAOG;IACG,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAIpD;;;;;;;OAOG;IACG,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAKtE"}
@@ -1,46 +0,0 @@
1
- export class Sessions {
2
- http;
3
- constructor(http) {
4
- this.http = http;
5
- }
6
- /**
7
- * Create a new voice session.
8
- *
9
- * @example
10
- * ```ts
11
- * const session = await speko.sessions.create({
12
- * pipeline: {
13
- * stt: { provider: 'deepgram' },
14
- * llm: { provider: 'openai', model: 'gpt-4o' },
15
- * tts: { provider: 'elevenlabs', voice: 'rachel' },
16
- * },
17
- * });
18
- * console.log(session.token); // Use to connect via LiveKit
19
- * ```
20
- */
21
- async create(params) {
22
- return this.http.post('/v1/sessions', params);
23
- }
24
- /**
25
- * Get a session by ID.
26
- *
27
- * @example
28
- * ```ts
29
- * const session = await speko.sessions.get('sess_abc123');
30
- * ```
31
- */
32
- async get(sessionId) {
33
- return this.http.get(`/v1/sessions/${sessionId}`);
34
- }
35
- /**
36
- * End an active session.
37
- *
38
- * @example
39
- * ```ts
40
- * await speko.sessions.end('sess_abc123');
41
- * ```
42
- */
43
- async end(sessionId) {
44
- return this.http.delete(`/v1/sessions/${sessionId}`);
45
- }
46
- }