@canarycoders/ai 0.3.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.
- package/LICENSE +21 -0
- package/README.md +174 -0
- package/dist/compat.cjs +17 -0
- package/dist/compat.cjs.map +1 -0
- package/dist/compat.d.cts +19 -0
- package/dist/compat.d.ts +19 -0
- package/dist/compat.js +14 -0
- package/dist/compat.js.map +1 -0
- package/dist/index.cjs +1658 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1070 -0
- package/dist/index.d.ts +1068 -0
- package/dist/index.js +1638 -0
- package/dist/index.js.map +1 -0
- package/dist/realtime-BWDkXcj9.d.cts +61 -0
- package/dist/realtime-BWDkXcj9.d.ts +61 -0
- package/dist/realtime-client/index.cjs +82 -0
- package/dist/realtime-client/index.cjs.map +1 -0
- package/dist/realtime-client/index.d.cts +30 -0
- package/dist/realtime-client/index.d.ts +30 -0
- package/dist/realtime-client/index.js +80 -0
- package/dist/realtime-client/index.js.map +1 -0
- package/package.json +81 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1070 @@
|
|
|
1
|
+
import { CompatTarget } from './compat.cjs';
|
|
2
|
+
export { anthropicTarget, openaiTarget } from './compat.cjs';
|
|
3
|
+
import { C as CreateRealtimeSessionParams, R as RealtimeSession, a as RealtimeSessionRecord, F as FinalizeRealtimeParams, B as BrokeredCredential } from './realtime-BWDkXcj9.cjs';
|
|
4
|
+
export { b as RealtimeKind, c as RealtimeTool } from './realtime-BWDkXcj9.cjs';
|
|
5
|
+
|
|
6
|
+
type FetchLike = typeof globalThis.fetch;
|
|
7
|
+
|
|
8
|
+
/** Every provider the gateway can route to. */
|
|
9
|
+
type ProviderType = "gemini" | "vertex" | "openai" | "anthropic" | "xai" | "lmstudio" | "ollama" | "perplexity" | "elevenlabs" | "mlxaudio" | "vision" | "gcvision";
|
|
10
|
+
/** Providers that serve text chat / completion. */
|
|
11
|
+
type ChatProvider = "gemini" | "vertex" | "openai" | "anthropic" | "xai" | "lmstudio" | "ollama" | "perplexity";
|
|
12
|
+
type ModelCapability = "chat" | "vision" | "image-generation" | "video-generation" | "text-to-speech" | "speech-to-text" | "image-recognition" | "face-detection" | "web-detection" | "conversation" | "sound-effect" | "music-generation" | "dialogue" | "realtime-voice" | "realtime-translate" | "realtime-transcribe" | "embeddings" | "reasoning";
|
|
13
|
+
interface TokenUsage {
|
|
14
|
+
inputTokens: number;
|
|
15
|
+
outputTokens: number;
|
|
16
|
+
totalTokens: number;
|
|
17
|
+
cachedTokens?: number;
|
|
18
|
+
reasoningTokens?: number;
|
|
19
|
+
}
|
|
20
|
+
interface ModelInfo {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
contextWindow: number;
|
|
24
|
+
maxOutputTokens: number;
|
|
25
|
+
provider: string;
|
|
26
|
+
capabilities: ModelCapability[];
|
|
27
|
+
inputCostPer1k?: number;
|
|
28
|
+
outputCostPer1k?: number;
|
|
29
|
+
costPerImage?: number;
|
|
30
|
+
costPerSecond?: number;
|
|
31
|
+
costPerCharacter?: number;
|
|
32
|
+
costPerHour?: number;
|
|
33
|
+
costPerAnalysis?: number;
|
|
34
|
+
costPerMinute?: number;
|
|
35
|
+
higherContextThreshold?: number;
|
|
36
|
+
higherContextInputCostPer1k?: number;
|
|
37
|
+
higherContextOutputCostPer1k?: number;
|
|
38
|
+
deprecated?: boolean;
|
|
39
|
+
shutdownDate?: string;
|
|
40
|
+
replacedBy?: string;
|
|
41
|
+
}
|
|
42
|
+
interface VoiceInfo {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
gender?: string;
|
|
46
|
+
accent?: string;
|
|
47
|
+
age?: string;
|
|
48
|
+
language?: string;
|
|
49
|
+
description?: string;
|
|
50
|
+
preview_url?: string;
|
|
51
|
+
labels?: Record<string, string>;
|
|
52
|
+
}
|
|
53
|
+
interface Citation {
|
|
54
|
+
url?: string;
|
|
55
|
+
title?: string;
|
|
56
|
+
text?: string;
|
|
57
|
+
startIndex?: number;
|
|
58
|
+
endIndex?: number;
|
|
59
|
+
}
|
|
60
|
+
/** The standard CanaryLLM success envelope: `{ success: true, data: T }`. */
|
|
61
|
+
interface ApiEnvelope<T> {
|
|
62
|
+
success: boolean;
|
|
63
|
+
data: T;
|
|
64
|
+
message?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
type ConversationTemplateType = "interview" | "conversation";
|
|
68
|
+
interface ConversationQuestion {
|
|
69
|
+
question: string;
|
|
70
|
+
context?: string;
|
|
71
|
+
isRequired?: boolean;
|
|
72
|
+
}
|
|
73
|
+
interface ConversationVoiceSettings {
|
|
74
|
+
stability?: number;
|
|
75
|
+
speed?: number;
|
|
76
|
+
similarityBoost?: number;
|
|
77
|
+
}
|
|
78
|
+
interface ConversationTool {
|
|
79
|
+
name: string;
|
|
80
|
+
description?: string;
|
|
81
|
+
}
|
|
82
|
+
interface ConversationTemplateParams {
|
|
83
|
+
name: string;
|
|
84
|
+
type: ConversationTemplateType;
|
|
85
|
+
systemPrompt: string;
|
|
86
|
+
description?: string;
|
|
87
|
+
firstMessage?: string;
|
|
88
|
+
voiceId?: string;
|
|
89
|
+
voiceModel?: string;
|
|
90
|
+
voiceSettings?: ConversationVoiceSettings;
|
|
91
|
+
language?: string;
|
|
92
|
+
languagePresets?: Record<string, {
|
|
93
|
+
firstMessage?: string;
|
|
94
|
+
}>;
|
|
95
|
+
llmProvider?: ChatProvider;
|
|
96
|
+
llmModel?: string;
|
|
97
|
+
clientWebhookUrl?: string;
|
|
98
|
+
webhookSecret?: string;
|
|
99
|
+
maxDurationSeconds?: number;
|
|
100
|
+
tag?: string;
|
|
101
|
+
questions?: ConversationQuestion[];
|
|
102
|
+
tools?: ConversationTool[];
|
|
103
|
+
}
|
|
104
|
+
type ConversationTemplateUpdate = Partial<ConversationTemplateParams>;
|
|
105
|
+
interface ConversationTemplate extends ConversationTemplateParams {
|
|
106
|
+
id: number;
|
|
107
|
+
agentId?: string;
|
|
108
|
+
createdAt?: string;
|
|
109
|
+
updatedAt?: string;
|
|
110
|
+
}
|
|
111
|
+
interface ConversationSessionRecord {
|
|
112
|
+
id: number;
|
|
113
|
+
templateId: number;
|
|
114
|
+
status: string;
|
|
115
|
+
metadata?: Record<string, unknown>;
|
|
116
|
+
createdAt?: string;
|
|
117
|
+
completedAt?: string;
|
|
118
|
+
}
|
|
119
|
+
interface CreateConversationSessionParams {
|
|
120
|
+
templateId: number;
|
|
121
|
+
metadata?: Record<string, unknown>;
|
|
122
|
+
textOnly?: boolean;
|
|
123
|
+
}
|
|
124
|
+
interface ConversationSession {
|
|
125
|
+
session: ConversationSessionRecord;
|
|
126
|
+
signedUrl: string;
|
|
127
|
+
/** seconds until the signed URL expires (≈900) */
|
|
128
|
+
expiresIn: number;
|
|
129
|
+
textOnly: boolean;
|
|
130
|
+
}
|
|
131
|
+
interface SignedUrlParams {
|
|
132
|
+
agentId: string;
|
|
133
|
+
sessionId?: number;
|
|
134
|
+
}
|
|
135
|
+
interface SignedUrlResult {
|
|
136
|
+
signedUrl: string;
|
|
137
|
+
expiresIn: number;
|
|
138
|
+
sessionId?: number;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
142
|
+
type RetryMode = "idempotent" | "submit" | "none";
|
|
143
|
+
interface TransportConfig {
|
|
144
|
+
apiKey?: string;
|
|
145
|
+
baseURL: string;
|
|
146
|
+
authStyle: "bearer" | "x-api-key";
|
|
147
|
+
timeoutMs: number;
|
|
148
|
+
maxRetries: number;
|
|
149
|
+
fetch?: FetchLike;
|
|
150
|
+
defaultHeaders?: Record<string, string>;
|
|
151
|
+
defaultTag?: string;
|
|
152
|
+
userAgent?: string;
|
|
153
|
+
}
|
|
154
|
+
interface RequestOptions {
|
|
155
|
+
body?: unknown;
|
|
156
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
157
|
+
headers?: Record<string, string>;
|
|
158
|
+
signal?: AbortSignal;
|
|
159
|
+
/** total timeout for this call; 0 disables (used for streams) */
|
|
160
|
+
timeoutMs?: number;
|
|
161
|
+
/** unwrap `{ success, data }` envelopes and return `data` (default true) */
|
|
162
|
+
unwrap?: boolean;
|
|
163
|
+
retry?: RetryMode;
|
|
164
|
+
}
|
|
165
|
+
declare class Transport {
|
|
166
|
+
readonly baseURL: string;
|
|
167
|
+
readonly timeoutMs: number;
|
|
168
|
+
readonly maxRetries: number;
|
|
169
|
+
private readonly apiKey?;
|
|
170
|
+
private readonly authStyle;
|
|
171
|
+
private readonly fetchImpl;
|
|
172
|
+
private readonly defaultHeaders;
|
|
173
|
+
private readonly defaultTag?;
|
|
174
|
+
private readonly userAgent;
|
|
175
|
+
private readonly retryPolicy;
|
|
176
|
+
constructor(config: TransportConfig);
|
|
177
|
+
json<T>(method: HttpMethod, path: string, opts?: RequestOptions): Promise<T>;
|
|
178
|
+
/** Perform the request and return the Response without throwing on non-2xx. */
|
|
179
|
+
raw(method: HttpMethod, path: string, opts?: RequestOptions): Promise<Response>;
|
|
180
|
+
/** Perform the request and return the raw text body (CSV, YAML, …). */
|
|
181
|
+
text(method: HttpMethod, path: string, opts?: RequestOptions): Promise<string>;
|
|
182
|
+
/** Open a streaming response. Throws if the initial response is an error. */
|
|
183
|
+
stream(method: HttpMethod, path: string, opts?: RequestOptions): Promise<Response>;
|
|
184
|
+
private maybeUnwrap;
|
|
185
|
+
private send;
|
|
186
|
+
private withDefaultTag;
|
|
187
|
+
private withRetry;
|
|
188
|
+
private execute;
|
|
189
|
+
private buildHeaders;
|
|
190
|
+
private buildUrl;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
type MessageRole = "system" | "user" | "assistant" | "tool";
|
|
194
|
+
interface TextContent {
|
|
195
|
+
type: "text";
|
|
196
|
+
text: string;
|
|
197
|
+
}
|
|
198
|
+
interface ImageContent {
|
|
199
|
+
type: "image";
|
|
200
|
+
/** base64-encoded image bytes */
|
|
201
|
+
data: string;
|
|
202
|
+
mimeType?: string;
|
|
203
|
+
}
|
|
204
|
+
interface DocumentContent {
|
|
205
|
+
type: "document";
|
|
206
|
+
/** base64-encoded PDF bytes */
|
|
207
|
+
data: string;
|
|
208
|
+
mimeType: "application/pdf";
|
|
209
|
+
}
|
|
210
|
+
interface VideoContent {
|
|
211
|
+
type: "video";
|
|
212
|
+
/** base64-encoded video bytes */
|
|
213
|
+
data?: string;
|
|
214
|
+
/** id returned by `video.upload()` */
|
|
215
|
+
fileId?: string;
|
|
216
|
+
mimeType?: string;
|
|
217
|
+
}
|
|
218
|
+
type ContentPart = TextContent | ImageContent | DocumentContent | VideoContent;
|
|
219
|
+
type MessageContent = string | ContentPart[];
|
|
220
|
+
interface ToolCall {
|
|
221
|
+
id: string;
|
|
222
|
+
type: "function";
|
|
223
|
+
function: {
|
|
224
|
+
name: string;
|
|
225
|
+
arguments: string;
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
interface ToolCallDelta {
|
|
229
|
+
index: number;
|
|
230
|
+
id?: string;
|
|
231
|
+
type?: "function";
|
|
232
|
+
function?: {
|
|
233
|
+
name?: string;
|
|
234
|
+
arguments?: string;
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
interface Message {
|
|
238
|
+
role: MessageRole;
|
|
239
|
+
content: MessageContent;
|
|
240
|
+
name?: string;
|
|
241
|
+
toolCalls?: ToolCall[];
|
|
242
|
+
toolCallId?: string;
|
|
243
|
+
}
|
|
244
|
+
interface ToolDefinition {
|
|
245
|
+
type: "function";
|
|
246
|
+
function: {
|
|
247
|
+
name: string;
|
|
248
|
+
description?: string;
|
|
249
|
+
parameters?: Record<string, unknown>;
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
type ToolChoice = "auto" | "none" | "required" | {
|
|
253
|
+
type: "function";
|
|
254
|
+
function: {
|
|
255
|
+
name: string;
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
interface ThinkingMode {
|
|
259
|
+
enabled: boolean;
|
|
260
|
+
budget?: number;
|
|
261
|
+
}
|
|
262
|
+
interface WebSearchOptions {
|
|
263
|
+
enabled: boolean;
|
|
264
|
+
maxUses?: number;
|
|
265
|
+
allowedDomains?: string[];
|
|
266
|
+
blockedDomains?: string[];
|
|
267
|
+
recencyFilter?: "day" | "week" | "month" | "year";
|
|
268
|
+
userLocation?: {
|
|
269
|
+
country?: string;
|
|
270
|
+
region?: string;
|
|
271
|
+
city?: string;
|
|
272
|
+
timezone?: string;
|
|
273
|
+
};
|
|
274
|
+
xSearch?: boolean;
|
|
275
|
+
}
|
|
276
|
+
type ResponseFormat = "text" | "json" | "json_schema";
|
|
277
|
+
interface CompleteParams {
|
|
278
|
+
provider: ChatProvider;
|
|
279
|
+
messages: Message[];
|
|
280
|
+
model?: string;
|
|
281
|
+
temperature?: number;
|
|
282
|
+
maxTokens?: number;
|
|
283
|
+
topP?: number;
|
|
284
|
+
frequencyPenalty?: number;
|
|
285
|
+
presencePenalty?: number;
|
|
286
|
+
stop?: string[];
|
|
287
|
+
responseFormat?: ResponseFormat;
|
|
288
|
+
jsonSchema?: Record<string, unknown>;
|
|
289
|
+
tools?: ToolDefinition[];
|
|
290
|
+
toolChoice?: ToolChoice;
|
|
291
|
+
thinkingMode?: ThinkingMode;
|
|
292
|
+
webSearch?: WebSearchOptions;
|
|
293
|
+
cache?: {
|
|
294
|
+
enabled?: boolean;
|
|
295
|
+
ttl?: number;
|
|
296
|
+
};
|
|
297
|
+
tag?: string;
|
|
298
|
+
service?: string;
|
|
299
|
+
/** server-side per-request timeout in ms (1000–300000) */
|
|
300
|
+
timeout?: number;
|
|
301
|
+
}
|
|
302
|
+
interface CompletionResult {
|
|
303
|
+
content: string;
|
|
304
|
+
usage: TokenUsage;
|
|
305
|
+
model: string;
|
|
306
|
+
provider: string;
|
|
307
|
+
requestId?: string;
|
|
308
|
+
cached?: boolean;
|
|
309
|
+
finishReason?: string;
|
|
310
|
+
toolCalls?: ToolCall[];
|
|
311
|
+
citations?: Citation[];
|
|
312
|
+
metadata?: Record<string, unknown>;
|
|
313
|
+
}
|
|
314
|
+
/** Raw chunk shape emitted by the native `/queue/stream` endpoint. */
|
|
315
|
+
interface StreamChunk {
|
|
316
|
+
delta: string;
|
|
317
|
+
usage?: TokenUsage;
|
|
318
|
+
finishReason?: string;
|
|
319
|
+
toolCallDeltas?: ToolCallDelta[];
|
|
320
|
+
metadata?: Record<string, unknown>;
|
|
321
|
+
}
|
|
322
|
+
/** Normalized streaming event, identical across every wire protocol. */
|
|
323
|
+
type ChatStreamEvent = {
|
|
324
|
+
type: "start";
|
|
325
|
+
raw?: unknown;
|
|
326
|
+
} | {
|
|
327
|
+
type: "text";
|
|
328
|
+
delta: string;
|
|
329
|
+
raw?: unknown;
|
|
330
|
+
} | {
|
|
331
|
+
type: "thinking";
|
|
332
|
+
delta: string;
|
|
333
|
+
raw?: unknown;
|
|
334
|
+
} | {
|
|
335
|
+
type: "tool_call";
|
|
336
|
+
index: number;
|
|
337
|
+
id?: string;
|
|
338
|
+
name?: string;
|
|
339
|
+
argsDelta?: string;
|
|
340
|
+
raw?: unknown;
|
|
341
|
+
} | {
|
|
342
|
+
type: "usage";
|
|
343
|
+
usage: TokenUsage;
|
|
344
|
+
raw?: unknown;
|
|
345
|
+
} | {
|
|
346
|
+
type: "done";
|
|
347
|
+
finishReason?: string;
|
|
348
|
+
usage?: TokenUsage;
|
|
349
|
+
raw?: unknown;
|
|
350
|
+
} | {
|
|
351
|
+
type: "raw";
|
|
352
|
+
event?: string;
|
|
353
|
+
data: unknown;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
type JobStatus = "queued" | "processing" | "thinking" | "streaming" | "completed" | "failed" | "cancelled" | "not_found" | "error";
|
|
357
|
+
interface JobSnapshot {
|
|
358
|
+
id: string;
|
|
359
|
+
status: JobStatus;
|
|
360
|
+
/** queue position, present only while `queued` */
|
|
361
|
+
position?: number;
|
|
362
|
+
createdAt?: string;
|
|
363
|
+
startedAt?: string;
|
|
364
|
+
completedAt?: string;
|
|
365
|
+
provider?: string;
|
|
366
|
+
model?: string;
|
|
367
|
+
error?: {
|
|
368
|
+
message: string;
|
|
369
|
+
code?: string;
|
|
370
|
+
statusCode?: number;
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
/** Drives per-domain default poll timeouts. */
|
|
374
|
+
type TaskKind = "completion" | "image" | "video" | "tts" | "stt" | "sound-effect" | "music" | "dialogue" | "vision" | "embedding";
|
|
375
|
+
interface PollOptions {
|
|
376
|
+
/** first poll delay after submit (default 500ms) */
|
|
377
|
+
initialIntervalMs?: number;
|
|
378
|
+
/** interval growth factor (default 1.5) */
|
|
379
|
+
backoffFactor?: number;
|
|
380
|
+
/** cap on the per-poll interval (default 5000ms) */
|
|
381
|
+
maxIntervalMs?: number;
|
|
382
|
+
/** jitter fraction applied to each interval, 0–1 (default 0.2) */
|
|
383
|
+
jitter?: number;
|
|
384
|
+
/** total wall-clock budget; defaults per task kind */
|
|
385
|
+
maxWaitMs?: number;
|
|
386
|
+
/** fired on every poll while the job is still running */
|
|
387
|
+
onPoll?: (info: {
|
|
388
|
+
status: JobStatus;
|
|
389
|
+
position?: number;
|
|
390
|
+
elapsedMs: number;
|
|
391
|
+
}) => void;
|
|
392
|
+
signal?: AbortSignal;
|
|
393
|
+
/** also fire `POST /queue/cancel` when the signal aborts (default true) */
|
|
394
|
+
cancelServerOnAbort?: boolean;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
interface JobStreamOptions {
|
|
398
|
+
signal?: AbortSignal;
|
|
399
|
+
includeRaw?: boolean;
|
|
400
|
+
/** abort the stream if no bytes arrive within this window (default 60s) */
|
|
401
|
+
idleMs?: number;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* A handle to a queued task. Returned by the `*Job` / `.submit()` methods so
|
|
405
|
+
* callers can hold the `id`, poll, stream, or cancel out of band.
|
|
406
|
+
*/
|
|
407
|
+
declare class Job<T> {
|
|
408
|
+
readonly id: string;
|
|
409
|
+
private readonly transport;
|
|
410
|
+
private readonly taskKind;
|
|
411
|
+
private readonly defaultPoll?;
|
|
412
|
+
private cachedValue?;
|
|
413
|
+
constructor(id: string, transport: Transport, taskKind: TaskKind, defaultPoll?: PollOptions);
|
|
414
|
+
/** One-shot status probe. Throws `NotFoundError` unless `allowMissing`. */
|
|
415
|
+
status(opts?: {
|
|
416
|
+
signal?: AbortSignal;
|
|
417
|
+
allowMissing?: boolean;
|
|
418
|
+
}): Promise<JobSnapshot>;
|
|
419
|
+
/** Poll to completion and resolve the typed result (cached after success). */
|
|
420
|
+
result(opts?: PollOptions): Promise<T>;
|
|
421
|
+
/** Stream the task's chunks via `/queue/stream` (for `stream: true` tasks). */
|
|
422
|
+
stream(opts?: JobStreamOptions): AsyncGenerator<ChatStreamEvent>;
|
|
423
|
+
/** Best-effort server cancel. Safe to call more than once. */
|
|
424
|
+
cancel(opts?: {
|
|
425
|
+
signal?: AbortSignal;
|
|
426
|
+
}): Promise<void>;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
declare class BaseResource {
|
|
430
|
+
protected readonly transport: Transport;
|
|
431
|
+
protected readonly defaultPoll?: PollOptions;
|
|
432
|
+
constructor(transport: Transport, defaultPoll?: PollOptions);
|
|
433
|
+
protected submitQueued<T>(path: string, body: unknown, kind: TaskKind, signal?: AbortSignal): Promise<Job<T>>;
|
|
434
|
+
protected runQueued<T>(path: string, body: unknown, kind: TaskKind, poll?: PollOptions): Promise<T>;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
declare class AgentsResource extends BaseResource {
|
|
438
|
+
/** Mint a short-lived signed URL for an ElevenLabs agent. */
|
|
439
|
+
signedUrl(params: SignedUrlParams, signal?: AbortSignal): Promise<SignedUrlResult>;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
interface ImageGenerateParams {
|
|
443
|
+
provider: "openai" | "gemini" | "vertex" | "xai" | "ollama";
|
|
444
|
+
prompt: string;
|
|
445
|
+
model?: string;
|
|
446
|
+
n?: number;
|
|
447
|
+
size?: string;
|
|
448
|
+
aspectRatio?: string;
|
|
449
|
+
quality?: "standard" | "hd" | "ultra";
|
|
450
|
+
tag?: string;
|
|
451
|
+
service?: string;
|
|
452
|
+
}
|
|
453
|
+
interface GeneratedImage {
|
|
454
|
+
/** base64-encoded image bytes (when returned inline) */
|
|
455
|
+
data?: string;
|
|
456
|
+
url?: string;
|
|
457
|
+
mimeType?: string;
|
|
458
|
+
revisedPrompt?: string;
|
|
459
|
+
}
|
|
460
|
+
interface ImageGenerationResult {
|
|
461
|
+
images: GeneratedImage[];
|
|
462
|
+
model: string;
|
|
463
|
+
provider: string;
|
|
464
|
+
}
|
|
465
|
+
interface VideoGenerateParams {
|
|
466
|
+
provider: "gemini" | "vertex" | "xai";
|
|
467
|
+
prompt: string;
|
|
468
|
+
model?: string;
|
|
469
|
+
aspectRatio?: string;
|
|
470
|
+
resolution?: string;
|
|
471
|
+
durationSeconds?: number;
|
|
472
|
+
numberOfVideos?: number;
|
|
473
|
+
/** public URL of a seed image */
|
|
474
|
+
imageUrl?: string;
|
|
475
|
+
/** id from `video.upload()` for image-to-video */
|
|
476
|
+
fileId?: string;
|
|
477
|
+
tag?: string;
|
|
478
|
+
service?: string;
|
|
479
|
+
}
|
|
480
|
+
interface GeneratedVideo {
|
|
481
|
+
data?: string;
|
|
482
|
+
url?: string;
|
|
483
|
+
mimeType?: string;
|
|
484
|
+
}
|
|
485
|
+
interface VideoGenerationResult {
|
|
486
|
+
videos: GeneratedVideo[];
|
|
487
|
+
model: string;
|
|
488
|
+
provider: string;
|
|
489
|
+
}
|
|
490
|
+
interface VideoUploadResult {
|
|
491
|
+
fileId: string;
|
|
492
|
+
mimeType: string;
|
|
493
|
+
}
|
|
494
|
+
type AudioOutputFormat = "mp3_44100_128" | "mp3_44100_192" | "pcm_16000" | "pcm_22050" | "pcm_24000" | "pcm_44100";
|
|
495
|
+
interface VoiceSettings {
|
|
496
|
+
stability?: number;
|
|
497
|
+
similarityBoost?: number;
|
|
498
|
+
style?: number;
|
|
499
|
+
useSpeakerBoost?: boolean;
|
|
500
|
+
speed?: number;
|
|
501
|
+
}
|
|
502
|
+
interface SpeechParams {
|
|
503
|
+
provider: "elevenlabs" | "mlxaudio";
|
|
504
|
+
text: string;
|
|
505
|
+
model?: string;
|
|
506
|
+
voiceId?: string;
|
|
507
|
+
outputFormat?: AudioOutputFormat;
|
|
508
|
+
voiceSettings?: VoiceSettings;
|
|
509
|
+
languageCode?: string;
|
|
510
|
+
previousText?: string;
|
|
511
|
+
nextText?: string;
|
|
512
|
+
applyTextNormalization?: "auto" | "on" | "off";
|
|
513
|
+
previousRequestIds?: string[];
|
|
514
|
+
tag?: string;
|
|
515
|
+
service?: string;
|
|
516
|
+
}
|
|
517
|
+
interface TTSResult {
|
|
518
|
+
/** base64-encoded audio bytes */
|
|
519
|
+
audio: string;
|
|
520
|
+
mimeType: string;
|
|
521
|
+
model: string;
|
|
522
|
+
provider: string;
|
|
523
|
+
characterCount?: number;
|
|
524
|
+
}
|
|
525
|
+
interface TranscribeParams {
|
|
526
|
+
provider: "elevenlabs" | "mlxaudio";
|
|
527
|
+
/** base64-encoded audio bytes or a public URL */
|
|
528
|
+
audio: string;
|
|
529
|
+
mimeType: string;
|
|
530
|
+
model?: string;
|
|
531
|
+
language?: string;
|
|
532
|
+
diarize?: boolean;
|
|
533
|
+
numSpeakers?: number;
|
|
534
|
+
timestampsGranularity?: "word" | "character";
|
|
535
|
+
tagAudioEvents?: boolean;
|
|
536
|
+
tag?: string;
|
|
537
|
+
service?: string;
|
|
538
|
+
}
|
|
539
|
+
interface TranscriptWord {
|
|
540
|
+
text: string;
|
|
541
|
+
start?: number;
|
|
542
|
+
end?: number;
|
|
543
|
+
speaker?: string;
|
|
544
|
+
type?: string;
|
|
545
|
+
}
|
|
546
|
+
interface STTResult {
|
|
547
|
+
text: string;
|
|
548
|
+
language?: string;
|
|
549
|
+
words?: TranscriptWord[];
|
|
550
|
+
model: string;
|
|
551
|
+
provider: string;
|
|
552
|
+
}
|
|
553
|
+
interface SoundEffectParams {
|
|
554
|
+
text: string;
|
|
555
|
+
model?: string;
|
|
556
|
+
durationSeconds?: number;
|
|
557
|
+
promptInfluence?: number;
|
|
558
|
+
loop?: boolean;
|
|
559
|
+
tag?: string;
|
|
560
|
+
service?: string;
|
|
561
|
+
}
|
|
562
|
+
interface SoundEffectResult {
|
|
563
|
+
audio: string;
|
|
564
|
+
mimeType: string;
|
|
565
|
+
model: string;
|
|
566
|
+
provider: string;
|
|
567
|
+
}
|
|
568
|
+
interface MusicParams {
|
|
569
|
+
prompt: string;
|
|
570
|
+
model?: string;
|
|
571
|
+
durationMs?: number;
|
|
572
|
+
forceInstrumental?: boolean;
|
|
573
|
+
tag?: string;
|
|
574
|
+
service?: string;
|
|
575
|
+
}
|
|
576
|
+
interface MusicResult {
|
|
577
|
+
audio: string;
|
|
578
|
+
mimeType: string;
|
|
579
|
+
model: string;
|
|
580
|
+
provider: string;
|
|
581
|
+
}
|
|
582
|
+
interface DialogueInput {
|
|
583
|
+
text: string;
|
|
584
|
+
voiceId: string;
|
|
585
|
+
}
|
|
586
|
+
interface DialogueParams {
|
|
587
|
+
inputs: DialogueInput[];
|
|
588
|
+
model?: string;
|
|
589
|
+
outputFormat?: AudioOutputFormat;
|
|
590
|
+
voiceSettings?: VoiceSettings;
|
|
591
|
+
languageCode?: string;
|
|
592
|
+
seed?: number;
|
|
593
|
+
applyTextNormalization?: "auto" | "on" | "off";
|
|
594
|
+
tag?: string;
|
|
595
|
+
service?: string;
|
|
596
|
+
}
|
|
597
|
+
interface DialogueResult {
|
|
598
|
+
audio: string;
|
|
599
|
+
mimeType: string;
|
|
600
|
+
model: string;
|
|
601
|
+
provider: string;
|
|
602
|
+
}
|
|
603
|
+
interface EmbeddingParams {
|
|
604
|
+
provider: "lmstudio";
|
|
605
|
+
/** A single string or an array of strings (max 2048) to embed. */
|
|
606
|
+
input: string | string[];
|
|
607
|
+
/** Embedding model id, e.g. `nomic-embed-text-v1.5`. */
|
|
608
|
+
model?: string;
|
|
609
|
+
/** Output dimensionality for models that support truncation (Matryoshka). */
|
|
610
|
+
dimensions?: number;
|
|
611
|
+
encodingFormat?: "float" | "base64";
|
|
612
|
+
tag?: string;
|
|
613
|
+
service?: string;
|
|
614
|
+
}
|
|
615
|
+
interface EmbeddingResult {
|
|
616
|
+
/** One vector per input, in input order. */
|
|
617
|
+
embeddings: number[][];
|
|
618
|
+
model: string;
|
|
619
|
+
provider: string;
|
|
620
|
+
dimensions: number;
|
|
621
|
+
usage: {
|
|
622
|
+
inputTokens: number;
|
|
623
|
+
totalTokens: number;
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
declare class AudioResource extends BaseResource {
|
|
628
|
+
/** Text-to-speech. */
|
|
629
|
+
speech(params: SpeechParams, poll?: PollOptions): Promise<TTSResult>;
|
|
630
|
+
speechJob(params: SpeechParams, signal?: AbortSignal): Promise<Job<TTSResult>>;
|
|
631
|
+
/** Speech-to-text. */
|
|
632
|
+
transcribe(params: TranscribeParams, poll?: PollOptions): Promise<STTResult>;
|
|
633
|
+
transcribeJob(params: TranscribeParams, signal?: AbortSignal): Promise<Job<STTResult>>;
|
|
634
|
+
soundEffect(params: SoundEffectParams, poll?: PollOptions): Promise<SoundEffectResult>;
|
|
635
|
+
soundEffectJob(params: SoundEffectParams, signal?: AbortSignal): Promise<Job<SoundEffectResult>>;
|
|
636
|
+
music(params: MusicParams, poll?: PollOptions): Promise<MusicResult>;
|
|
637
|
+
musicJob(params: MusicParams, signal?: AbortSignal): Promise<Job<MusicResult>>;
|
|
638
|
+
dialogue(params: DialogueParams, poll?: PollOptions): Promise<DialogueResult>;
|
|
639
|
+
dialogueJob(params: DialogueParams, signal?: AbortSignal): Promise<Job<DialogueResult>>;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
interface ChatStreamOptions {
|
|
643
|
+
signal?: AbortSignal;
|
|
644
|
+
includeRaw?: boolean;
|
|
645
|
+
}
|
|
646
|
+
declare class ChatResource extends BaseResource {
|
|
647
|
+
/** Submit a completion and poll until the final result is ready. */
|
|
648
|
+
complete(params: CompleteParams, poll?: PollOptions): Promise<CompletionResult>;
|
|
649
|
+
/** Submit a completion and return the `Job` handle without waiting. */
|
|
650
|
+
submit(params: CompleteParams, signal?: AbortSignal): Promise<Job<CompletionResult>>;
|
|
651
|
+
/** Stream a completion as normalized chat events. */
|
|
652
|
+
stream(params: CompleteParams, opts?: ChatStreamOptions): AsyncGenerator<ChatStreamEvent>;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
declare class TemplatesAPI extends BaseResource {
|
|
656
|
+
create(params: ConversationTemplateParams, signal?: AbortSignal): Promise<ConversationTemplate>;
|
|
657
|
+
list(signal?: AbortSignal): Promise<ConversationTemplate[]>;
|
|
658
|
+
get(id: number, signal?: AbortSignal): Promise<ConversationTemplate>;
|
|
659
|
+
update(id: number, params: ConversationTemplateUpdate, signal?: AbortSignal): Promise<ConversationTemplate>;
|
|
660
|
+
delete(id: number, signal?: AbortSignal): Promise<void>;
|
|
661
|
+
}
|
|
662
|
+
declare class SessionsAPI extends BaseResource {
|
|
663
|
+
create(params: CreateConversationSessionParams, signal?: AbortSignal): Promise<ConversationSession>;
|
|
664
|
+
list(opts?: {
|
|
665
|
+
templateId?: number;
|
|
666
|
+
}, signal?: AbortSignal): Promise<ConversationSessionRecord[]>;
|
|
667
|
+
get(id: number, signal?: AbortSignal): Promise<ConversationSessionRecord>;
|
|
668
|
+
}
|
|
669
|
+
declare class ConversationsResource extends BaseResource {
|
|
670
|
+
readonly templates: TemplatesAPI;
|
|
671
|
+
readonly sessions: SessionsAPI;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
declare class DiscoveryResource extends BaseResource {
|
|
675
|
+
providers(signal?: AbortSignal): Promise<string[]>;
|
|
676
|
+
models(provider: string, signal?: AbortSignal): Promise<ModelInfo[]>;
|
|
677
|
+
voices(provider: string, signal?: AbortSignal): Promise<VoiceInfo[]>;
|
|
678
|
+
capabilities(signal?: AbortSignal): Promise<Record<string, any>>;
|
|
679
|
+
concurrency(signal?: AbortSignal): Promise<Record<string, any>>;
|
|
680
|
+
concurrencyFor(provider: string, signal?: AbortSignal): Promise<Record<string, any>>;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
declare class EmbeddingsResource extends BaseResource {
|
|
684
|
+
/**
|
|
685
|
+
* Embed one or more text inputs into vectors via a local embedding model
|
|
686
|
+
* (LM Studio). Submits to the queue and resolves with the vectors. Content is
|
|
687
|
+
* processed transiently by the gateway and never stored — intended for
|
|
688
|
+
* customer-side RAG ingestion and retrieval.
|
|
689
|
+
*/
|
|
690
|
+
create(params: EmbeddingParams, poll?: PollOptions): Promise<EmbeddingResult>;
|
|
691
|
+
/** Handle form: returns a {@link Job} you can poll or cancel yourself. */
|
|
692
|
+
createJob(params: EmbeddingParams, signal?: AbortSignal): Promise<Job<EmbeddingResult>>;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
declare class ImagesResource extends BaseResource {
|
|
696
|
+
/** Generate one or more images and wait for the result. */
|
|
697
|
+
generate(params: ImageGenerateParams, poll?: PollOptions): Promise<ImageGenerationResult>;
|
|
698
|
+
/** Submit an image generation and return the `Job` handle. */
|
|
699
|
+
generateJob(params: ImageGenerateParams, signal?: AbortSignal): Promise<Job<ImageGenerationResult>>;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
interface KeyInfo {
|
|
703
|
+
keyPrefix: string;
|
|
704
|
+
name?: string;
|
|
705
|
+
permissions: {
|
|
706
|
+
read: boolean;
|
|
707
|
+
write: boolean;
|
|
708
|
+
admin?: boolean;
|
|
709
|
+
};
|
|
710
|
+
rateLimits: {
|
|
711
|
+
perMinute: number;
|
|
712
|
+
perDay: number;
|
|
713
|
+
};
|
|
714
|
+
expiresAt?: string;
|
|
715
|
+
lastUsedAt?: string;
|
|
716
|
+
createdAt?: string;
|
|
717
|
+
}
|
|
718
|
+
interface KeyValidation {
|
|
719
|
+
success: boolean;
|
|
720
|
+
valid: boolean;
|
|
721
|
+
message?: string;
|
|
722
|
+
data?: unknown;
|
|
723
|
+
}
|
|
724
|
+
declare class KeysResource extends BaseResource {
|
|
725
|
+
/** Info about the key the client is authenticated with. */
|
|
726
|
+
info(signal?: AbortSignal): Promise<KeyInfo>;
|
|
727
|
+
/** Validate an API key. Returns `{ valid: false }` rather than throwing. */
|
|
728
|
+
validate(apiKey: string, signal?: AbortSignal): Promise<KeyValidation>;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
interface PortalPeriod {
|
|
732
|
+
year?: number;
|
|
733
|
+
month?: number;
|
|
734
|
+
}
|
|
735
|
+
declare class PortalResource extends BaseResource {
|
|
736
|
+
info(signal?: AbortSignal): Promise<Record<string, unknown>>;
|
|
737
|
+
overview(period?: PortalPeriod, signal?: AbortSignal): Promise<Record<string, unknown>>;
|
|
738
|
+
usageDaily(period?: PortalPeriod, signal?: AbortSignal): Promise<unknown[]>;
|
|
739
|
+
usageByModel(period?: PortalPeriod, signal?: AbortSignal): Promise<unknown[]>;
|
|
740
|
+
/** Export a month of usage as CSV text. */
|
|
741
|
+
exportUsage(params: {
|
|
742
|
+
month: number;
|
|
743
|
+
year: number;
|
|
744
|
+
}, signal?: AbortSignal): Promise<string>;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
/** Unauthenticated endpoints. These work even without an API key. */
|
|
748
|
+
declare class PublicResource extends BaseResource {
|
|
749
|
+
/** All providers with their models and public pricing. */
|
|
750
|
+
models(signal?: AbortSignal): Promise<Record<string, any>>;
|
|
751
|
+
/** Available voices per provider. */
|
|
752
|
+
voices(signal?: AbortSignal): Promise<Record<string, any>>;
|
|
753
|
+
/** A short spoken preview of a voice (base64 audio). */
|
|
754
|
+
voicePreview(params: {
|
|
755
|
+
provider: string;
|
|
756
|
+
voiceId: string;
|
|
757
|
+
}, signal?: AbortSignal): Promise<{
|
|
758
|
+
audio: string;
|
|
759
|
+
mimeType: string;
|
|
760
|
+
voiceId: string;
|
|
761
|
+
}>;
|
|
762
|
+
/** The raw OpenAPI specification (YAML). */
|
|
763
|
+
openapi(signal?: AbortSignal): Promise<string>;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/** Low-level access to the queue by `queueId`, for tasks tracked out of band. */
|
|
767
|
+
declare class QueueResource extends BaseResource {
|
|
768
|
+
/** Reconstruct a `Job` handle from a known queue id. */
|
|
769
|
+
job<T = unknown>(queueId: string, taskKind?: TaskKind): Job<T>;
|
|
770
|
+
status(queueId: string, opts?: {
|
|
771
|
+
signal?: AbortSignal;
|
|
772
|
+
allowMissing?: boolean;
|
|
773
|
+
}): Promise<JobSnapshot>;
|
|
774
|
+
result<T = unknown>(queueId: string, opts?: PollOptions): Promise<T>;
|
|
775
|
+
stream(queueId: string, opts?: {
|
|
776
|
+
signal?: AbortSignal;
|
|
777
|
+
includeRaw?: boolean;
|
|
778
|
+
idleMs?: number;
|
|
779
|
+
}): AsyncGenerator<ChatStreamEvent>;
|
|
780
|
+
cancel(queueId: string, opts?: {
|
|
781
|
+
signal?: AbortSignal;
|
|
782
|
+
}): Promise<void>;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
declare class RealtimeSessionsAPI extends BaseResource {
|
|
786
|
+
/** Mint an ephemeral realtime credential. The response is NOT enveloped. */
|
|
787
|
+
create(params: CreateRealtimeSessionParams, signal?: AbortSignal): Promise<RealtimeSession>;
|
|
788
|
+
get(id: number, signal?: AbortSignal): Promise<RealtimeSessionRecord>;
|
|
789
|
+
end(id: number, params?: FinalizeRealtimeParams, signal?: AbortSignal): Promise<RealtimeSessionRecord>;
|
|
790
|
+
}
|
|
791
|
+
declare class RealtimeResource extends BaseResource {
|
|
792
|
+
readonly sessions: RealtimeSessionsAPI;
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* Normalize a realtime or conversational session into a single credential
|
|
796
|
+
* shape safe to hand to a frontend (only the short-lived secret, never the
|
|
797
|
+
* API key).
|
|
798
|
+
*/
|
|
799
|
+
declare function toBrokeredCredential(session: RealtimeSession | ConversationSession): BrokeredCredential;
|
|
800
|
+
|
|
801
|
+
interface UsageSummary {
|
|
802
|
+
totalRequests: number;
|
|
803
|
+
totalTokens: number;
|
|
804
|
+
totalPrice?: number;
|
|
805
|
+
[k: string]: unknown;
|
|
806
|
+
}
|
|
807
|
+
declare class UsageResource extends BaseResource {
|
|
808
|
+
/** Current-month usage summary. */
|
|
809
|
+
current(signal?: AbortSignal): Promise<UsageSummary>;
|
|
810
|
+
/** Monthly usage broken down by model/provider. */
|
|
811
|
+
monthly(signal?: AbortSignal): Promise<unknown>;
|
|
812
|
+
/** Daily usage breakdown. */
|
|
813
|
+
daily(signal?: AbortSignal): Promise<unknown>;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
interface VideoUploadOptions {
|
|
817
|
+
filename?: string;
|
|
818
|
+
mimeType?: string;
|
|
819
|
+
signal?: AbortSignal;
|
|
820
|
+
}
|
|
821
|
+
declare class VideoResource extends BaseResource {
|
|
822
|
+
generate(params: VideoGenerateParams, poll?: PollOptions): Promise<VideoGenerationResult>;
|
|
823
|
+
generateJob(params: VideoGenerateParams, signal?: AbortSignal): Promise<Job<VideoGenerationResult>>;
|
|
824
|
+
/** Upload a seed video for image/video-to-video; returns a `fileId`. */
|
|
825
|
+
upload(file: Blob | Uint8Array | ArrayBuffer, opts?: VideoUploadOptions): Promise<VideoUploadResult>;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
interface BoundingBox {
|
|
829
|
+
x: number;
|
|
830
|
+
y: number;
|
|
831
|
+
width: number;
|
|
832
|
+
height: number;
|
|
833
|
+
}
|
|
834
|
+
interface Detection {
|
|
835
|
+
label: string;
|
|
836
|
+
confidence: number;
|
|
837
|
+
box: BoundingBox;
|
|
838
|
+
classId?: number;
|
|
839
|
+
}
|
|
840
|
+
interface DetectParams {
|
|
841
|
+
/** base64-encoded image bytes (max ~50MB) */
|
|
842
|
+
image: string;
|
|
843
|
+
model?: string;
|
|
844
|
+
confidence?: number;
|
|
845
|
+
/** restrict to these YOLO class ids */
|
|
846
|
+
classes?: number[];
|
|
847
|
+
tag?: string;
|
|
848
|
+
service?: string;
|
|
849
|
+
}
|
|
850
|
+
interface ZeroShotDetectParams {
|
|
851
|
+
image: string;
|
|
852
|
+
prompt: string;
|
|
853
|
+
confidence?: number;
|
|
854
|
+
tag?: string;
|
|
855
|
+
service?: string;
|
|
856
|
+
}
|
|
857
|
+
interface FaceDetectParams {
|
|
858
|
+
image: string;
|
|
859
|
+
model?: "haarcascade" | "mediapipe" | "yolo-face";
|
|
860
|
+
blur?: boolean;
|
|
861
|
+
blurStrength?: number;
|
|
862
|
+
confidence?: number;
|
|
863
|
+
minSize?: number;
|
|
864
|
+
scaleFactor?: number;
|
|
865
|
+
minNeighbors?: number;
|
|
866
|
+
tag?: string;
|
|
867
|
+
service?: string;
|
|
868
|
+
}
|
|
869
|
+
interface WebDetectParams {
|
|
870
|
+
image: string;
|
|
871
|
+
maxResults?: number;
|
|
872
|
+
tag?: string;
|
|
873
|
+
}
|
|
874
|
+
interface ImageRecognitionResult {
|
|
875
|
+
detections: Detection[];
|
|
876
|
+
model: string;
|
|
877
|
+
width?: number;
|
|
878
|
+
height?: number;
|
|
879
|
+
}
|
|
880
|
+
interface FaceDetectionResult {
|
|
881
|
+
faces: Detection[];
|
|
882
|
+
/** base64-encoded image with faces blurred (when `blur: true`) */
|
|
883
|
+
blurredImage?: string;
|
|
884
|
+
model: string;
|
|
885
|
+
}
|
|
886
|
+
interface WebEntity {
|
|
887
|
+
description?: string;
|
|
888
|
+
score?: number;
|
|
889
|
+
}
|
|
890
|
+
interface WebDetectionResult {
|
|
891
|
+
entities: WebEntity[];
|
|
892
|
+
pages?: unknown[];
|
|
893
|
+
matchingImages?: unknown[];
|
|
894
|
+
}
|
|
895
|
+
interface AutoLabelParams {
|
|
896
|
+
images: string[];
|
|
897
|
+
classes: string[];
|
|
898
|
+
confidence?: number;
|
|
899
|
+
outputFormat?: string;
|
|
900
|
+
valSplit?: number;
|
|
901
|
+
tag?: string;
|
|
902
|
+
}
|
|
903
|
+
interface AutoLabelResult {
|
|
904
|
+
labeled: number;
|
|
905
|
+
datasetId?: string;
|
|
906
|
+
[k: string]: unknown;
|
|
907
|
+
}
|
|
908
|
+
interface AutoTrainParams {
|
|
909
|
+
images: string[];
|
|
910
|
+
classes: string[];
|
|
911
|
+
baseModel?: string;
|
|
912
|
+
confidence?: number;
|
|
913
|
+
imageSize?: number;
|
|
914
|
+
epochs?: number;
|
|
915
|
+
tag?: string;
|
|
916
|
+
}
|
|
917
|
+
/** Dataset-based fine-tuning. Field shape depends on the server build. */
|
|
918
|
+
type TrainParams = Record<string, unknown>;
|
|
919
|
+
interface TrainingJob {
|
|
920
|
+
jobId: string;
|
|
921
|
+
status: string;
|
|
922
|
+
progress?: number;
|
|
923
|
+
modelId?: string;
|
|
924
|
+
createdAt?: string;
|
|
925
|
+
completedAt?: string;
|
|
926
|
+
error?: string;
|
|
927
|
+
}
|
|
928
|
+
interface VisionModel {
|
|
929
|
+
modelId: string;
|
|
930
|
+
name?: string;
|
|
931
|
+
classes?: string[];
|
|
932
|
+
createdAt?: string;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
declare class VisionResource extends BaseResource {
|
|
936
|
+
detect(params: DetectParams, poll?: PollOptions): Promise<ImageRecognitionResult>;
|
|
937
|
+
detectJob(params: DetectParams, signal?: AbortSignal): Promise<Job<ImageRecognitionResult>>;
|
|
938
|
+
zeroShot(params: ZeroShotDetectParams, poll?: PollOptions): Promise<ImageRecognitionResult>;
|
|
939
|
+
zeroShotJob(params: ZeroShotDetectParams, signal?: AbortSignal): Promise<Job<ImageRecognitionResult>>;
|
|
940
|
+
faces(params: FaceDetectParams, poll?: PollOptions): Promise<FaceDetectionResult>;
|
|
941
|
+
facesJob(params: FaceDetectParams, signal?: AbortSignal): Promise<Job<FaceDetectionResult>>;
|
|
942
|
+
web(params: WebDetectParams, poll?: PollOptions): Promise<WebDetectionResult>;
|
|
943
|
+
webJob(params: WebDetectParams, signal?: AbortSignal): Promise<Job<WebDetectionResult>>;
|
|
944
|
+
autoLabel(params: AutoLabelParams, poll?: PollOptions): Promise<AutoLabelResult>;
|
|
945
|
+
autoLabelJob(params: AutoLabelParams, signal?: AbortSignal): Promise<Job<AutoLabelResult>>;
|
|
946
|
+
autoTrain(params: AutoTrainParams, poll?: PollOptions): Promise<TrainingJob>;
|
|
947
|
+
autoTrainJob(params: AutoTrainParams, signal?: AbortSignal): Promise<Job<TrainingJob>>;
|
|
948
|
+
/** Start a dataset training run (synchronous; returns a job record). */
|
|
949
|
+
train(params: TrainParams, signal?: AbortSignal): Promise<TrainingJob>;
|
|
950
|
+
getTraining(jobId: string, signal?: AbortSignal): Promise<TrainingJob>;
|
|
951
|
+
listTraining(signal?: AbortSignal): Promise<TrainingJob[]>;
|
|
952
|
+
models(signal?: AbortSignal): Promise<VisionModel[]>;
|
|
953
|
+
deleteModel(modelId: string, signal?: AbortSignal): Promise<{
|
|
954
|
+
deleted: boolean;
|
|
955
|
+
modelId: string;
|
|
956
|
+
}>;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
interface CanaryLLMOptions {
|
|
960
|
+
/** API key. Defaults to `process.env.CANARY_AI_API_KEY` (legacy `CANARYLLM_API_KEY` still read). */
|
|
961
|
+
apiKey?: string;
|
|
962
|
+
/** Base URL. Defaults to `https://api.ai.canarycoders.es`. */
|
|
963
|
+
baseURL?: string;
|
|
964
|
+
/** Send the key as `Authorization: Bearer` (default) or `X-API-Key`. */
|
|
965
|
+
authStyle?: "bearer" | "x-api-key";
|
|
966
|
+
/** Per-request total timeout in ms (default 60000). */
|
|
967
|
+
timeoutMs?: number;
|
|
968
|
+
/** Automatic retries for transient failures (default 2). */
|
|
969
|
+
maxRetries?: number;
|
|
970
|
+
/** Override the fetch implementation (tests, proxies, custom agents). */
|
|
971
|
+
fetch?: FetchLike;
|
|
972
|
+
defaultHeaders?: Record<string, string>;
|
|
973
|
+
/** Default `tag` attached to requests for usage attribution. */
|
|
974
|
+
defaultTag?: string;
|
|
975
|
+
/** Default polling behavior for queued operations. */
|
|
976
|
+
poll?: PollOptions;
|
|
977
|
+
}
|
|
978
|
+
declare class CanaryLLM {
|
|
979
|
+
readonly chat: ChatResource;
|
|
980
|
+
readonly queue: QueueResource;
|
|
981
|
+
readonly images: ImagesResource;
|
|
982
|
+
readonly video: VideoResource;
|
|
983
|
+
readonly audio: AudioResource;
|
|
984
|
+
readonly embeddings: EmbeddingsResource;
|
|
985
|
+
readonly vision: VisionResource;
|
|
986
|
+
readonly conversations: ConversationsResource;
|
|
987
|
+
readonly agents: AgentsResource;
|
|
988
|
+
readonly realtime: RealtimeResource;
|
|
989
|
+
readonly discovery: DiscoveryResource;
|
|
990
|
+
readonly usage: UsageResource;
|
|
991
|
+
readonly portal: PortalResource;
|
|
992
|
+
readonly keys: KeysResource;
|
|
993
|
+
readonly public: PublicResource;
|
|
994
|
+
private readonly transport;
|
|
995
|
+
private readonly baseURL;
|
|
996
|
+
private readonly apiKey?;
|
|
997
|
+
constructor(options?: CanaryLLMOptions);
|
|
998
|
+
/** Targets to plug into the official `openai` / `@anthropic-ai/sdk` clients. */
|
|
999
|
+
get compat(): {
|
|
1000
|
+
openai: () => CompatTarget;
|
|
1001
|
+
anthropic: () => CompatTarget;
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
interface APIErrorInit {
|
|
1006
|
+
status?: number;
|
|
1007
|
+
code?: string | number;
|
|
1008
|
+
requestId?: string;
|
|
1009
|
+
headers?: Headers;
|
|
1010
|
+
details?: unknown;
|
|
1011
|
+
raw?: unknown;
|
|
1012
|
+
}
|
|
1013
|
+
/** Base class for every error the SDK throws from an API interaction. */
|
|
1014
|
+
declare class APIError extends Error {
|
|
1015
|
+
readonly status?: number;
|
|
1016
|
+
readonly code?: string | number;
|
|
1017
|
+
readonly requestId?: string;
|
|
1018
|
+
readonly headers?: Headers;
|
|
1019
|
+
readonly details?: unknown;
|
|
1020
|
+
readonly raw?: unknown;
|
|
1021
|
+
constructor(message: string, init?: APIErrorInit);
|
|
1022
|
+
}
|
|
1023
|
+
declare class BadRequestError extends APIError {
|
|
1024
|
+
/** parsed Zod issues from the server, when present */
|
|
1025
|
+
readonly validationIssues?: unknown;
|
|
1026
|
+
constructor(message: string, init?: APIErrorInit);
|
|
1027
|
+
}
|
|
1028
|
+
declare class AuthenticationError extends APIError {
|
|
1029
|
+
}
|
|
1030
|
+
declare class PermissionError extends APIError {
|
|
1031
|
+
}
|
|
1032
|
+
declare class NotFoundError extends APIError {
|
|
1033
|
+
}
|
|
1034
|
+
declare class ConflictError extends APIError {
|
|
1035
|
+
}
|
|
1036
|
+
declare class UnprocessableEntityError extends APIError {
|
|
1037
|
+
}
|
|
1038
|
+
declare class RateLimitError extends APIError {
|
|
1039
|
+
/** remaining request budget; only sent by the server in development */
|
|
1040
|
+
readonly remaining?: {
|
|
1041
|
+
minute: number;
|
|
1042
|
+
day: number;
|
|
1043
|
+
};
|
|
1044
|
+
readonly retryAfterMs?: number;
|
|
1045
|
+
constructor(message: string, init?: APIErrorInit);
|
|
1046
|
+
}
|
|
1047
|
+
declare class InternalServerError extends APIError {
|
|
1048
|
+
}
|
|
1049
|
+
/** Network-level failure (DNS, connection refused, TLS, reset). No HTTP status. */
|
|
1050
|
+
declare class APIConnectionError extends APIError {
|
|
1051
|
+
}
|
|
1052
|
+
declare class APIConnectionTimeoutError extends APIConnectionError {
|
|
1053
|
+
phase?: "connect" | "read" | "total";
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
interface SSEOptions {
|
|
1057
|
+
signal?: AbortSignal;
|
|
1058
|
+
/** abort the stream if no bytes arrive within this window */
|
|
1059
|
+
idleMs?: number;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
type StreamProtocol = "native" | "openai" | "anthropic" | "responses";
|
|
1063
|
+
interface StreamAdapterOptions extends SSEOptions {
|
|
1064
|
+
/** attach the source payload as `raw` on each event (off by default) */
|
|
1065
|
+
includeRaw?: boolean;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
// @ts-ignore
|
|
1069
|
+
export = CanaryLLM;
|
|
1070
|
+
export { APIConnectionError, APIConnectionTimeoutError, APIError, type ApiEnvelope, type AudioOutputFormat, AuthenticationError, type AutoLabelParams, type AutoLabelResult, type AutoTrainParams, BadRequestError, type BoundingBox, BrokeredCredential, CanaryLLM, type CanaryLLMOptions, type ChatProvider, type ChatStreamEvent, type ChatStreamOptions, type Citation, CompatTarget, type CompleteParams, type CompletionResult, ConflictError, type ContentPart, type ConversationQuestion, type ConversationSession, type ConversationSessionRecord, type ConversationTemplate, type ConversationTemplateParams, type ConversationTemplateType, type ConversationTemplateUpdate, type ConversationTool, type ConversationVoiceSettings, type CreateConversationSessionParams, CreateRealtimeSessionParams, type DetectParams, type Detection, type DialogueInput, type DialogueParams, type DialogueResult, type DocumentContent, type EmbeddingParams, type EmbeddingResult, type FaceDetectParams, type FaceDetectionResult, FinalizeRealtimeParams, type GeneratedImage, type GeneratedVideo, type ImageContent, type ImageGenerateParams, type ImageGenerationResult, type ImageRecognitionResult, InternalServerError, Job, type JobSnapshot, type JobStatus, type JobStreamOptions, type KeyInfo, type KeyValidation, type Message, type MessageContent, type MessageRole, type ModelCapability, type ModelInfo, type MusicParams, type MusicResult, NotFoundError, PermissionError, type PollOptions, type PortalPeriod, type ProviderType, RateLimitError, RealtimeSession, RealtimeSessionRecord, type ResponseFormat, type STTResult, type SignedUrlParams, type SignedUrlResult, type SoundEffectParams, type SoundEffectResult, type SpeechParams, type StreamAdapterOptions, type StreamChunk, type StreamProtocol, type TTSResult, type TaskKind, type TextContent, type ThinkingMode, type TokenUsage, type ToolCall, type ToolCallDelta, type ToolChoice, type ToolDefinition, type TrainParams, type TrainingJob, type TranscribeParams, type TranscriptWord, UnprocessableEntityError, type UsageSummary, type VideoContent, type VideoGenerateParams, type VideoGenerationResult, type VideoUploadOptions, type VideoUploadResult, type VisionModel, type VoiceInfo, type VoiceSettings, type WebDetectParams, type WebDetectionResult, type WebEntity, type WebSearchOptions, type ZeroShotDetectParams, toBrokeredCredential };
|