addisai 0.1.0

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.
@@ -0,0 +1,718 @@
1
+ type FetchLike = typeof fetch;
2
+ interface TransportConfig {
3
+ apiKey: string;
4
+ baseURL: string;
5
+ timeout: number;
6
+ maxRetries: number;
7
+ defaultHeaders: Record<string, string>;
8
+ defaultQuery: Record<string, string>;
9
+ fetch: FetchLike;
10
+ logLevel: LogLevel;
11
+ }
12
+ type LogLevel = "off" | "error" | "warn" | "info" | "debug";
13
+ /** Per-request options accepted by every resource method. */
14
+ interface RequestOptions {
15
+ timeout?: number;
16
+ maxRetries?: number;
17
+ signal?: AbortSignal;
18
+ idempotencyKey?: string;
19
+ headers?: Record<string, string>;
20
+ query?: Record<string, unknown>;
21
+ }
22
+ interface InternalRequest {
23
+ method: "GET" | "POST" | "DELETE" | "PUT" | "PATCH" | "HEAD";
24
+ path: string;
25
+ query?: Record<string, unknown>;
26
+ /** JSON body (mutually exclusive with `form`). */
27
+ body?: unknown;
28
+ /** multipart/form-data body (mutually exclusive with `body`). */
29
+ form?: FormData;
30
+ /** Return the raw Response (for streaming or binary) instead of parsed JSON. */
31
+ raw?: boolean;
32
+ /** Minimum effective timeout in ms (e.g. paid synthesis budget). */
33
+ timeoutFloor?: number;
34
+ }
35
+ declare class Transport {
36
+ private readonly config;
37
+ constructor(config: TransportConfig);
38
+ /** The configured fetch implementation, for direct asset downloads. */
39
+ get fetch(): FetchLike;
40
+ private log;
41
+ private buildURL;
42
+ private buildHeaders;
43
+ private isRetryable;
44
+ private retryDelayMs;
45
+ request<T>(req: InternalRequest, opts?: RequestOptions): Promise<T>;
46
+ /**
47
+ * Open a streaming request: a single fetch (streams are not retried once
48
+ * started), with the timeout guarding only the initial response. The returned
49
+ * controller stays live so the caller can cancel the body mid-stream.
50
+ */
51
+ openStream(req: InternalRequest, opts?: RequestOptions): Promise<{
52
+ response: Response;
53
+ controller: AbortController;
54
+ }>;
55
+ private parseJSON;
56
+ private toError;
57
+ }
58
+
59
+ /**
60
+ * An OpenAI-style streaming chat response. It is async-iterable (`for await`),
61
+ * and provides convenience accumulators and cancellation.
62
+ */
63
+ declare class ChatStream implements AsyncIterable<ChatCompletionChunk> {
64
+ private readonly response;
65
+ private readonly controller?;
66
+ /** Transcription, if the request included audio input. */
67
+ transcription?: {
68
+ raw?: string;
69
+ clean?: string;
70
+ };
71
+ private readonly id;
72
+ private readonly created;
73
+ private consumed;
74
+ private finalUsage;
75
+ constructor(response: Response, controller?: AbortController | undefined);
76
+ /** Cancel the stream and underlying request. */
77
+ abort(): void;
78
+ [Symbol.asyncIterator](): AsyncIterator<ChatCompletionChunk>;
79
+ /** Consume the stream and return the concatenated assistant text. */
80
+ finalText(): Promise<string>;
81
+ /** Consume the stream and return an assembled non-streaming completion. */
82
+ finalCompletion(): Promise<ChatCompletion>;
83
+ /** Re-encode the stream as a byte ReadableStream of SSE chunks (for piping). */
84
+ toReadableStream(): ReadableStream<Uint8Array>;
85
+ }
86
+
87
+ type Uploadable = Blob | ArrayBuffer | ArrayBufferView | FileInput;
88
+ interface FileInput {
89
+ /** Raw bytes or a Blob. */
90
+ data: Blob | ArrayBuffer | ArrayBufferView;
91
+ /** Filename sent to the API; helps the server infer format. */
92
+ filename?: string;
93
+ /** MIME type, e.g. "audio/wav". Strongly recommended. */
94
+ contentType?: string;
95
+ }
96
+ /**
97
+ * Read a file from disk into a FileInput (Node/Bun/Deno only). Convenience for
98
+ * `audio: await fileFromPath("./call.wav")`.
99
+ */
100
+ declare function fileFromPath(path: string, contentType?: string): Promise<FileInput>;
101
+
102
+ /** Languages supported for generation/chat. */
103
+ type Language = "am" | "om";
104
+ /** Languages supported for speech-to-text. */
105
+ type SttLanguage = "am" | "om" | "en" | "ha" | "sw";
106
+ /** Languages supported for translation. */
107
+ type TranslateLanguage = "am" | "om" | "en";
108
+ /** TTS output formats. `pcm_16000` is delivered as a WAV container. */
109
+ type OutputFormat = "mp3_44100" | "wav_44100" | "pcm_16000";
110
+
111
+ /** Public model identifier surfaced to developers. Never the underlying model. */
112
+ declare const ADDIS_CHAT_MODEL = "addis-1-alef";
113
+ type ChatRole = "system" | "developer" | "user" | "assistant" | "tool";
114
+ interface ToolCall {
115
+ id: string;
116
+ type: "function";
117
+ function: {
118
+ name: string;
119
+ arguments: string;
120
+ };
121
+ /** Opaque provider state. Managed by the SDK; echo it back unchanged. */
122
+ addis_tool_state?: string;
123
+ }
124
+ interface ChatCompletionMessage {
125
+ role: ChatRole;
126
+ content?: string | null;
127
+ name?: string;
128
+ tool_calls?: ToolCall[];
129
+ tool_call_id?: string;
130
+ }
131
+ interface FunctionTool {
132
+ type: "function";
133
+ function: {
134
+ name: string;
135
+ description?: string;
136
+ parameters?: Record<string, unknown>;
137
+ };
138
+ }
139
+ /** A tool whose implementation the SDK will execute during `chat.runTools`. */
140
+ interface RunnableTool {
141
+ type: "function";
142
+ function: {
143
+ name: string;
144
+ description?: string;
145
+ parameters?: Record<string, unknown>;
146
+ /** Local implementation invoked with the parsed arguments. */
147
+ function: (args: any) => unknown | Promise<unknown>;
148
+ };
149
+ }
150
+ type ToolChoice = "auto" | "none" | "required" | {
151
+ type: "function";
152
+ function: {
153
+ name: string;
154
+ };
155
+ };
156
+ interface ChatAttachment {
157
+ /** A field name used for the multipart upload (defaults to "attachment_N"). */
158
+ name?: string;
159
+ file: Uploadable;
160
+ }
161
+ interface ChatCompletionCreateParams {
162
+ /** Accepted for OpenAI compatibility. Addis selects the model internally. */
163
+ model?: string;
164
+ messages: ChatCompletionMessage[];
165
+ /** Target language. "am" (Amharic) or "om" (Afan Oromo). Default "am". */
166
+ language?: Language;
167
+ /** Extra behaviour instructions (tone/format). Does not change identity. */
168
+ system?: string;
169
+ /** Replaces the assistant identity for branded apps. */
170
+ persona?: string;
171
+ temperature?: number;
172
+ max_tokens?: number;
173
+ tools?: FunctionTool[];
174
+ tool_choice?: ToolChoice;
175
+ /** Beta: stream tokens. Not available with tools. */
176
+ stream?: boolean;
177
+ /** Files/images/documents to attach to the final user message. */
178
+ attachments?: ChatAttachment[];
179
+ /** Audio voice-command input; transcribed server-side. */
180
+ audio?: Uploadable;
181
+ }
182
+ interface ChatUsage {
183
+ prompt_tokens: number;
184
+ completion_tokens: number;
185
+ total_tokens: number;
186
+ }
187
+ interface ChatCompletionChoice {
188
+ index: number;
189
+ message: ChatCompletionMessage;
190
+ finish_reason: string | null;
191
+ }
192
+ interface ChatCompletion {
193
+ id: string;
194
+ object: "chat.completion";
195
+ created: number;
196
+ model: string;
197
+ choices: ChatCompletionChoice[];
198
+ usage?: ChatUsage;
199
+ /** Present when audio input was transcribed. */
200
+ transcription?: {
201
+ raw?: string;
202
+ clean?: string;
203
+ };
204
+ /** Uploaded attachment URIs to reuse in later turns. */
205
+ uploaded_attachments?: {
206
+ fileUri: string;
207
+ mimeType: string;
208
+ }[];
209
+ }
210
+ interface ChatCompletionChunk {
211
+ id: string;
212
+ object: "chat.completion.chunk";
213
+ created: number;
214
+ model: string;
215
+ choices: Array<{
216
+ index: number;
217
+ delta: {
218
+ role?: "assistant";
219
+ content?: string;
220
+ };
221
+ finish_reason: string | null;
222
+ }>;
223
+ }
224
+ declare class Chat {
225
+ private readonly transport;
226
+ readonly completions: Completions;
227
+ constructor(transport: Transport);
228
+ /**
229
+ * Run an automatic tool-calling loop: the model requests tools, the SDK
230
+ * executes your local implementations, feeds results back, and repeats until
231
+ * the model produces a final answer.
232
+ */
233
+ runTools(params: Omit<ChatCompletionCreateParams, "tools" | "stream"> & {
234
+ tools: RunnableTool[];
235
+ maxToolRoundtrips?: number;
236
+ }, opts?: RequestOptions): Promise<ChatCompletion>;
237
+ }
238
+ declare class Completions {
239
+ private readonly transport;
240
+ constructor(transport: Transport);
241
+ create(params: ChatCompletionCreateParams & {
242
+ stream: true;
243
+ }, opts?: RequestOptions): Promise<ChatStream>;
244
+ create(params: ChatCompletionCreateParams & {
245
+ stream?: false;
246
+ }, opts?: RequestOptions): Promise<ChatCompletion>;
247
+ private createStream;
248
+ private createMultipart;
249
+ }
250
+
251
+ interface Page<T> {
252
+ data: T[];
253
+ nextCursor: string | null;
254
+ limit: number | null;
255
+ }
256
+ declare class CursorPage<T> implements AsyncIterable<T> {
257
+ private readonly firstPage;
258
+ private readonly fetchPage;
259
+ constructor(firstPage: Page<T>, fetchPage: (cursor: string) => Promise<Page<T>>);
260
+ /** Items on the first page only. */
261
+ get data(): T[];
262
+ get nextCursor(): string | null;
263
+ [Symbol.asyncIterator](): AsyncIterator<T>;
264
+ }
265
+ /**
266
+ * A pending page that is BOTH awaitable (`await list()` → CursorPage) and
267
+ * async-iterable (`for await (const item of list())` → items across all pages).
268
+ * Lets `list()` be used either way without the caller needing to await first.
269
+ */
270
+ declare class CursorPagePromise<T> implements PromiseLike<CursorPage<T>>, AsyncIterable<T> {
271
+ private readonly load;
272
+ private promise?;
273
+ constructor(load: () => Promise<CursorPage<T>>);
274
+ private get inner();
275
+ then<TResult1 = CursorPage<T>, TResult2 = never>(onfulfilled?: ((value: CursorPage<T>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
276
+ catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<CursorPage<T> | TResult>;
277
+ finally(onfinally?: (() => void) | null): Promise<CursorPage<T>>;
278
+ [Symbol.asyncIterator](): AsyncIterator<T>;
279
+ }
280
+
281
+ interface ClipUsage {
282
+ pricingUnit: "character";
283
+ pricePer1000Characters: number;
284
+ creditsUsed: number | null;
285
+ creditsRemaining: number | null;
286
+ currency: string;
287
+ }
288
+ interface ClipMeta {
289
+ /** Voice settings the request sent that the engine did not apply. */
290
+ ignoredVoiceSettings: string[];
291
+ /** True when this result was replayed from a prior identical request (no new billing). */
292
+ idempotentReplay: boolean;
293
+ }
294
+ interface ClipData {
295
+ id: string;
296
+ text: string;
297
+ textPreview: string;
298
+ voiceId: string;
299
+ voiceName: string;
300
+ voiceDescriptor: string;
301
+ language: Language;
302
+ outputFormat: OutputFormat;
303
+ audioUrl: string;
304
+ mimeType: string;
305
+ durationSeconds: number | null;
306
+ characterCount: number;
307
+ billableCharacters: number;
308
+ downloadName: string;
309
+ createdAt: string;
310
+ usage?: ClipUsage;
311
+ meta?: ClipMeta;
312
+ /** The idempotency key used for this generation. */
313
+ clientRequestId?: string;
314
+ }
315
+ /**
316
+ * A generated audio clip. Exposes the signed playback URL plus convenience
317
+ * helpers to fetch the bytes or write them to disk.
318
+ */
319
+ declare class AddisClip implements ClipData {
320
+ private readonly fetchImpl;
321
+ readonly id: string;
322
+ readonly text: string;
323
+ readonly textPreview: string;
324
+ readonly voiceId: string;
325
+ readonly voiceName: string;
326
+ readonly voiceDescriptor: string;
327
+ readonly language: Language;
328
+ readonly outputFormat: OutputFormat;
329
+ readonly audioUrl: string;
330
+ readonly mimeType: string;
331
+ readonly durationSeconds: number | null;
332
+ readonly characterCount: number;
333
+ readonly billableCharacters: number;
334
+ readonly downloadName: string;
335
+ readonly createdAt: string;
336
+ readonly usage?: ClipUsage;
337
+ readonly meta?: ClipMeta;
338
+ readonly clientRequestId?: string;
339
+ constructor(data: ClipData, fetchImpl: FetchLike);
340
+ /** Fetch the audio bytes from the signed playback URL. */
341
+ arrayBuffer(): Promise<ArrayBuffer>;
342
+ /** Write the audio to a file on disk (Node/Bun/Deno). */
343
+ toFile(path: string): Promise<void>;
344
+ }
345
+
346
+ /**
347
+ * A stream of audio byte chunks. Async-iterable (`for await` yields
348
+ * `Uint8Array`), with helpers to collect or save the audio. Normalizes the two
349
+ * legacy stream encodings (newline-delimited base64 JSON chunks, or a raw audio
350
+ * byte stream) into a single byte stream.
351
+ */
352
+ declare class AudioStream implements AsyncIterable<Uint8Array> {
353
+ private readonly response;
354
+ private readonly mode;
355
+ private readonly controller?;
356
+ private consumed;
357
+ constructor(response: Response, mode: "ndjson" | "raw", controller?: AbortController | undefined);
358
+ static fromResponse(response: Response, controller?: AbortController): AudioStream;
359
+ /** Cancel the stream and underlying request. */
360
+ abort(): void;
361
+ [Symbol.asyncIterator](): AsyncIterator<Uint8Array>;
362
+ /** Collect every chunk into a single ArrayBuffer. */
363
+ arrayBuffer(): Promise<ArrayBuffer>;
364
+ /** Stream the audio to a file on disk (Node/Bun/Deno). */
365
+ toFile(path: string): Promise<void>;
366
+ }
367
+
368
+ /** ElevenLabs-style voice controls, expressed on a 0–100 scale. */
369
+ interface VoiceSettings {
370
+ speed?: number;
371
+ stability?: number;
372
+ similarity?: number;
373
+ style?: number;
374
+ }
375
+ interface VoiceGenerateParams {
376
+ voiceId: string;
377
+ text: string;
378
+ language: Language;
379
+ /** Default "mp3_44100". */
380
+ outputFormat?: OutputFormat;
381
+ voiceSettings?: VoiceSettings;
382
+ /**
383
+ * Idempotency key. Auto-generated if omitted and reused across retries so a
384
+ * retried request is never billed twice. Reusing a key with changed inputs
385
+ * raises IdempotencyConflictError.
386
+ */
387
+ clientRequestId?: string;
388
+ }
389
+ interface VoiceEstimateParams {
390
+ voiceId: string;
391
+ text: string;
392
+ language: Language;
393
+ outputFormat?: OutputFormat;
394
+ }
395
+ interface VoiceEstimate {
396
+ characterCount: number;
397
+ billableCharacters: number;
398
+ pricingUnit: "character";
399
+ pricePer1000Characters: number;
400
+ estimatedCost: number;
401
+ currency: string;
402
+ currentBalance: number;
403
+ estimatedBalanceAfter: number;
404
+ canGenerate: boolean;
405
+ }
406
+ interface VoiceUsage {
407
+ walletId: string;
408
+ balance: number;
409
+ formattedBalance: string;
410
+ currency: string;
411
+ lastDeductionAt: string | null;
412
+ totalSpend: number;
413
+ formattedTotalSpend: string;
414
+ maxTtsCharacters: number;
415
+ pricing: {
416
+ unit: string;
417
+ pricePer1000Characters: number;
418
+ minimumCharge: number;
419
+ currency: string;
420
+ };
421
+ budget: unknown | null;
422
+ }
423
+ interface ClipListParams {
424
+ limit?: number;
425
+ cursor?: string;
426
+ language?: Language;
427
+ voiceId?: string;
428
+ }
429
+ declare class Voice {
430
+ private readonly transport;
431
+ readonly clips: Clips;
432
+ constructor(transport: Transport);
433
+ /** Synthesize speech and return the generated clip. */
434
+ generate(params: VoiceGenerateParams, opts?: RequestOptions): Promise<AddisClip>;
435
+ /**
436
+ * Streaming synthesis. The surface is stable for when the API enables it;
437
+ * until then it raises NotSupportedError. Use {@link Voice.generate} today.
438
+ */
439
+ stream(_params: VoiceGenerateParams, _opts?: RequestOptions): Promise<AudioStream>;
440
+ /** Pre-flight cost estimate (and whether the wallet can cover it). */
441
+ estimate(params: VoiceEstimateParams, opts?: RequestOptions): Promise<VoiceEstimate>;
442
+ /** Wallet balance and pricing for voice generation. */
443
+ usage(opts?: RequestOptions): Promise<VoiceUsage>;
444
+ }
445
+ declare class Clips {
446
+ private readonly transport;
447
+ constructor(transport: Transport);
448
+ /**
449
+ * List generated clips. The returned value is both awaitable
450
+ * (`const page = await clips.list()`) and async-iterable
451
+ * (`for await (const clip of clips.list())` walks every page).
452
+ */
453
+ list(params?: ClipListParams, opts?: RequestOptions): CursorPagePromise<AddisClip>;
454
+ /** Fetch one clip by ID. */
455
+ get(clipId: string, opts?: RequestOptions): Promise<AddisClip>;
456
+ /** Download the audio bytes for a clip. */
457
+ download(clipId: string, opts?: RequestOptions): Promise<ArrayBuffer>;
458
+ /** Delete a clip. */
459
+ delete(clipId: string, opts?: RequestOptions): Promise<void>;
460
+ }
461
+
462
+ interface VoiceCatalogEntry {
463
+ id: string;
464
+ name: string;
465
+ descriptor: string;
466
+ language: Language;
467
+ gender: string;
468
+ style: string;
469
+ scriptChip: string;
470
+ tags: string[];
471
+ previewAudioUrl: string | null;
472
+ previewMimeType: string | null;
473
+ previewDurationSeconds: number | null;
474
+ isDefault: boolean;
475
+ isAvailable: boolean;
476
+ sortOrder: number;
477
+ }
478
+ interface VoiceListParams {
479
+ language?: Language;
480
+ gender?: "female" | "male";
481
+ search?: string;
482
+ includeUnavailable?: boolean;
483
+ }
484
+ interface VoicePreview {
485
+ voiceId: string;
486
+ audioUrl: string | null;
487
+ audio: string | null;
488
+ mimeType: string | null;
489
+ durationSeconds: number | null;
490
+ downloadName: string;
491
+ }
492
+ declare class Voices {
493
+ private readonly transport;
494
+ constructor(transport: Transport);
495
+ /** List the voice catalog. */
496
+ list(params?: VoiceListParams, opts?: RequestOptions): Promise<VoiceCatalogEntry[]>;
497
+ /** Fetch a single voice's preview clip metadata. */
498
+ preview(voiceId: string, opts?: RequestOptions): Promise<VoicePreview>;
499
+ }
500
+
501
+ interface TranscribeParams {
502
+ /** Audio input. Buffer/Blob/Uint8Array, or a FileInput descriptor. Max 25 MB / 120 s. */
503
+ audio: Uploadable;
504
+ /** Language of the audio: "am" | "om" | "en" | "ha" | "sw". */
505
+ language: SttLanguage;
506
+ }
507
+ interface Transcription {
508
+ text: string;
509
+ confidence: number | null;
510
+ usage: unknown;
511
+ }
512
+ declare class Speech {
513
+ private readonly transport;
514
+ constructor(transport: Transport);
515
+ /** Transcribe speech to text. */
516
+ transcribe(params: TranscribeParams, opts?: RequestOptions): Promise<Transcription>;
517
+ }
518
+
519
+ interface TranslateParams {
520
+ text: string;
521
+ /** Target language: "am" | "om" | "en". */
522
+ to: TranslateLanguage;
523
+ /** Source language. Must differ from `to`. */
524
+ from: TranslateLanguage;
525
+ }
526
+ interface Translation {
527
+ text: string;
528
+ sourceLanguage: TranslateLanguage;
529
+ targetLanguage: TranslateLanguage;
530
+ quality: "high" | "medium" | "low" | null;
531
+ usage: unknown;
532
+ }
533
+ declare class Translate {
534
+ private readonly transport;
535
+ constructor(transport: Transport);
536
+ /** Translate text between Amharic, Afan Oromo, and English. */
537
+ create(params: TranslateParams, opts?: RequestOptions): Promise<Translation>;
538
+ }
539
+
540
+ /**
541
+ * ElevenLabs-style alias over `voice.*`, for developers migrating from
542
+ * ElevenLabs. `client.textToSpeech.convert(voiceId, { text, language })`.
543
+ */
544
+ interface ConvertParams {
545
+ text: string;
546
+ language: Language;
547
+ outputFormat?: OutputFormat;
548
+ voiceSettings?: VoiceSettings;
549
+ clientRequestId?: string;
550
+ }
551
+ declare class TextToSpeech {
552
+ private readonly voice;
553
+ constructor(voice: Voice);
554
+ /** Synthesize speech for a voice. Mirrors ElevenLabs `textToSpeech.convert`. */
555
+ convert(voiceId: string, params: ConvertParams, opts?: RequestOptions): Promise<AddisClip>;
556
+ }
557
+
558
+ interface LegacyAudioParams {
559
+ text: string;
560
+ /** "am" | "om". */
561
+ language: Language;
562
+ }
563
+ /** Result of a legacy non-streaming synthesis. */
564
+ declare class LegacyAudio {
565
+ /** Base64-encoded audio (WAV or MP3, provider-dependent). */
566
+ readonly audio: string;
567
+ constructor(
568
+ /** Base64-encoded audio (WAV or MP3, provider-dependent). */
569
+ audio: string);
570
+ /** Decode the base64 audio into bytes. */
571
+ arrayBuffer(): ArrayBuffer;
572
+ /** Write the decoded audio to disk (Node/Bun/Deno). */
573
+ toFile(path: string): Promise<void>;
574
+ }
575
+ /**
576
+ * @deprecated The legacy `/audio` text-to-speech endpoint. Use
577
+ * {@link Voice.generate} (`addis.voice.generate`) instead — it uses the current
578
+ * voice model and returns durable, signed clips with idempotent billing.
579
+ *
580
+ * Provided only as a migration bridge for existing integrations. Limited to
581
+ * 1500 characters for non-streaming synthesis.
582
+ */
583
+ declare class LegacyAudioResource {
584
+ private readonly transport;
585
+ constructor(transport: Transport);
586
+ /**
587
+ * @deprecated Use `addis.voice.generate(...)`.
588
+ * Synthesize speech via the legacy endpoint (non-streaming).
589
+ */
590
+ generate(params: LegacyAudioParams, opts?: RequestOptions): Promise<LegacyAudio>;
591
+ /**
592
+ * @deprecated Use `addis.voice.generate(...)`.
593
+ * Stream synthesis via the legacy endpoint. Returns an {@link AudioStream} of
594
+ * audio byte chunks. The SDK normalizes the two legacy encodings (Amharic
595
+ * newline-delimited base64 JSON, Afan Oromo raw `audio/wav`) into one byte
596
+ * stream. New code should not depend on this.
597
+ */
598
+ stream(params: LegacyAudioParams, opts?: RequestOptions): Promise<AudioStream>;
599
+ }
600
+ /** @deprecated Namespace for legacy endpoints retained for backward compatibility. */
601
+ declare class Legacy {
602
+ /** @deprecated Use `addis.voice` instead. */
603
+ readonly audio: LegacyAudioResource;
604
+ constructor(transport: Transport);
605
+ }
606
+
607
+ interface ClientOptions {
608
+ /** Addis AI API key. Defaults to `process.env.ADDIS_API_KEY`. */
609
+ apiKey?: string;
610
+ /** Override the API base URL. Defaults to the Addis AI Cloudflare endpoint. */
611
+ baseURL?: string;
612
+ /** Request timeout in milliseconds. Default 60000. */
613
+ timeout?: number;
614
+ /** Maximum automatic retries for transient failures. Default 2. */
615
+ maxRetries?: number;
616
+ /** Headers merged into every request. */
617
+ defaultHeaders?: Record<string, string>;
618
+ /** Query params merged into every request. */
619
+ defaultQuery?: Record<string, string>;
620
+ /** Inject a custom fetch implementation. Defaults to the global fetch. */
621
+ fetch?: FetchLike;
622
+ /** Allow running in a browser. API keys are secrets — keep this false. */
623
+ dangerouslyAllowBrowser?: boolean;
624
+ /** Logging verbosity. Secrets are never logged at any level. Default "warn". */
625
+ logLevel?: LogLevel;
626
+ }
627
+ declare class AddisAI {
628
+ readonly chat: Chat;
629
+ readonly voice: Voice;
630
+ readonly voices: Voices;
631
+ readonly speech: Speech;
632
+ readonly translate: Translate;
633
+ /** ElevenLabs-style alias over `voice.*` for developers migrating. */
634
+ readonly textToSpeech: TextToSpeech;
635
+ /** @deprecated Legacy endpoints retained for backward compatibility. Use `voice`. */
636
+ readonly legacy: Legacy;
637
+ /** @internal */
638
+ readonly _transport: Transport;
639
+ private readonly _apiKey;
640
+ constructor(options?: ClientOptions);
641
+ /** Redacted representation; never exposes the API key. */
642
+ toString(): string;
643
+ }
644
+
645
+ interface ErrorDetail {
646
+ field?: string;
647
+ code?: string;
648
+ message?: string;
649
+ }
650
+ declare class AddisAIError extends Error {
651
+ constructor(message: string);
652
+ }
653
+ /** Thrown when a capability exists in the SDK surface but is not yet enabled. */
654
+ declare class NotSupportedError extends AddisAIError {
655
+ }
656
+ /** Network-level failure (DNS, TLS, socket, fetch rejection). */
657
+ declare class APIConnectionError extends AddisAIError {
658
+ readonly cause?: unknown;
659
+ constructor(message?: string, cause?: unknown);
660
+ }
661
+ /** Request exceeded the configured timeout / was aborted by timeout. */
662
+ declare class APIConnectionTimeoutError extends APIConnectionError {
663
+ constructor(message?: string);
664
+ }
665
+ /** Any non-2xx HTTP response. */
666
+ declare class APIError extends AddisAIError {
667
+ readonly status: number;
668
+ readonly code: string | null;
669
+ readonly details: ErrorDetail[];
670
+ readonly requestId: string | null;
671
+ readonly headers: Record<string, string>;
672
+ constructor(status: number, message: string, opts?: {
673
+ code?: string | null;
674
+ details?: ErrorDetail[];
675
+ requestId?: string | null;
676
+ headers?: Record<string, string>;
677
+ });
678
+ }
679
+ declare class BadRequestError extends APIError {
680
+ }
681
+ declare class AuthenticationError extends APIError {
682
+ }
683
+ declare class InsufficientCreditsError extends APIError {
684
+ get availableBalance(): number | null;
685
+ }
686
+ declare class PermissionDeniedError extends APIError {
687
+ }
688
+ declare class NotFoundError extends APIError {
689
+ }
690
+ declare class ConflictError extends APIError {
691
+ }
692
+ declare class IdempotencyConflictError extends ConflictError {
693
+ }
694
+ declare class GenerationInProgressError extends ConflictError {
695
+ get retryAfter(): number | null;
696
+ }
697
+ declare class UnprocessableEntityError extends APIError {
698
+ }
699
+ declare class RateLimitError extends APIError {
700
+ get retryAfter(): number | null;
701
+ get limit(): number | null;
702
+ get remaining(): number | null;
703
+ get reset(): number | null;
704
+ }
705
+ declare class InternalServerError extends APIError {
706
+ }
707
+
708
+ /**
709
+ * Play audio through the system audio device (Node only). Lazily spawns
710
+ * `ffplay` (from ffmpeg); falls back to `mpv`. Intended for local scripts and
711
+ * demos, not production servers.
712
+ */
713
+ declare function play(audio: AddisClip | ArrayBuffer | Uint8Array): Promise<void>;
714
+
715
+ /** Generate a new ULID, e.g. "01JZ900QK3GZTY2VJ9ZQ5A96M5". */
716
+ declare function ulid(): string;
717
+
718
+ export { ADDIS_CHAT_MODEL, APIConnectionError, APIConnectionTimeoutError, APIError, AddisAI, AddisAIError, AddisClip, AudioStream, AuthenticationError, BadRequestError, type ChatAttachment, type ChatCompletion, type ChatCompletionChoice, type ChatCompletionChunk, type ChatCompletionCreateParams, type ChatCompletionMessage, type ChatRole, ChatStream, type ChatUsage, type ClientOptions, type ClipData, type ClipListParams, type ClipMeta, type ClipUsage, ConflictError, type ConvertParams, CursorPage, CursorPagePromise, type ErrorDetail, type FileInput, type FunctionTool, GenerationInProgressError, IdempotencyConflictError, InsufficientCreditsError, InternalServerError, type Language, LegacyAudio, type LegacyAudioParams, type LogLevel, NotFoundError, NotSupportedError, type OutputFormat, PermissionDeniedError, RateLimitError, type RequestOptions, type SttLanguage, type ToolCall, type ToolChoice, type TranscribeParams, type Transcription, type TranslateLanguage, type TranslateParams, type Translation, UnprocessableEntityError, type Uploadable, type VoiceCatalogEntry, type VoiceEstimate, type VoiceEstimateParams, type VoiceGenerateParams, type VoiceListParams, type VoicePreview, type VoiceSettings, type VoiceUsage, AddisAI as default, fileFromPath, play, ulid };