@kreuzberg/liter-llm-node 1.6.1 → 1.6.2
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/README.md +8 -7
- package/index.d.ts +414 -381
- package/index.js +45 -16
- package/liter-llm-node.darwin-arm64.node +0 -0
- package/liter-llm-node.linux-arm64-gnu.node +0 -0
- package/liter-llm-node.linux-x64-gnu.node +0 -0
- package/liter-llm-node.win32-x64-msvc.node +0 -0
- package/package.json +27 -17
package/index.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
// This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
-
// alef:hash:
|
|
2
|
+
// alef:hash:797e09398ae0b95dd0e3de94d7374eedafcd20d08532c7cf378cbcd09e3083a7
|
|
3
3
|
// To regenerate: alef generate
|
|
4
4
|
// To verify freshness: alef verify --exit-code
|
|
5
5
|
/* eslint-disable */
|
|
6
6
|
|
|
7
|
-
export type JsonValue =
|
|
7
|
+
export type JsonValue =
|
|
8
|
+
| string
|
|
9
|
+
| number
|
|
10
|
+
| boolean
|
|
11
|
+
| null
|
|
12
|
+
| JsonValue[]
|
|
13
|
+
| { [key: string]: JsonValue };
|
|
8
14
|
|
|
9
15
|
/**
|
|
10
16
|
* Return all provider configs from the registry.
|
|
@@ -35,7 +41,12 @@ export declare function capabilities(providerName: string): ProviderCapabilities
|
|
|
35
41
|
* stay below `limit`. Returns `Err(LiterLlmError::Streaming)` on overflow
|
|
36
42
|
* and emits a `tracing::warn!` with context.
|
|
37
43
|
*/
|
|
38
|
-
export declare function checkBound(
|
|
44
|
+
export declare function checkBound(
|
|
45
|
+
context: string,
|
|
46
|
+
currentLen: number,
|
|
47
|
+
incoming: number,
|
|
48
|
+
limit: number,
|
|
49
|
+
): void;
|
|
39
50
|
|
|
40
51
|
/**
|
|
41
52
|
* Remove all guardrails from the global registry.
|
|
@@ -55,7 +66,11 @@ export declare function clear(): void;
|
|
|
55
66
|
* are tried by stripping from the last `-` or `.` separator. For example,
|
|
56
67
|
* `gpt-4-0613` will match `gpt-4` if no `gpt-4-0613` entry exists.
|
|
57
68
|
*/
|
|
58
|
-
export declare function completionCost(
|
|
69
|
+
export declare function completionCost(
|
|
70
|
+
model: string,
|
|
71
|
+
promptTokens: number,
|
|
72
|
+
completionTokens: number,
|
|
73
|
+
): number | null;
|
|
59
74
|
|
|
60
75
|
/**
|
|
61
76
|
* Calculate the estimated cost of a completion, accounting for cached
|
|
@@ -71,7 +86,12 @@ export declare function completionCost(model: string, promptTokens: number, comp
|
|
|
71
86
|
* Returns `None` if the model is not present in the embedded pricing
|
|
72
87
|
* registry, mirroring [`completion_cost`].
|
|
73
88
|
*/
|
|
74
|
-
export declare function completionCostWithCache(
|
|
89
|
+
export declare function completionCostWithCache(
|
|
90
|
+
model: string,
|
|
91
|
+
promptTokens: number,
|
|
92
|
+
cachedTokens: number,
|
|
93
|
+
completionTokens: number,
|
|
94
|
+
): number | null;
|
|
75
95
|
|
|
76
96
|
/**
|
|
77
97
|
* Return the set of complex provider names.
|
|
@@ -93,7 +113,10 @@ export declare function complexProviderNames(): Array<string>;
|
|
|
93
113
|
* @throws Returns [`LiterLlmError::BadRequest`] if the tokenizer cannot be loaded or
|
|
94
114
|
* if tokenization fails for any message.
|
|
95
115
|
*/
|
|
96
|
-
export declare function countRequestTokens(
|
|
116
|
+
export declare function countRequestTokens(
|
|
117
|
+
model: string,
|
|
118
|
+
req?: ChatCompletionRequest | undefined | null,
|
|
119
|
+
): number;
|
|
97
120
|
|
|
98
121
|
/**
|
|
99
122
|
* Count tokens in a text string using the tokenizer for the given model.
|
|
@@ -115,7 +138,13 @@ export declare function countTokens(model: string, text: string): number;
|
|
|
115
138
|
* @throws Returns [`LiterLlmError`] if the underlying HTTP client cannot be
|
|
116
139
|
* constructed, or if the resolved provider configuration is invalid.
|
|
117
140
|
*/
|
|
118
|
-
export declare function createClient(
|
|
141
|
+
export declare function createClient(
|
|
142
|
+
apiKey: string,
|
|
143
|
+
baseUrl?: string | undefined | null,
|
|
144
|
+
timeoutSecs?: number | undefined | null,
|
|
145
|
+
maxRetries?: number | undefined | null,
|
|
146
|
+
modelHint?: string | undefined | null,
|
|
147
|
+
): DefaultClient;
|
|
119
148
|
|
|
120
149
|
/**
|
|
121
150
|
* Create a new LLM client from a JSON string.
|
|
@@ -149,34 +178,34 @@ export declare function ensureCryptoProvider(): void;
|
|
|
149
178
|
/** Assistant's response to a user message. */
|
|
150
179
|
export interface AssistantMessage {
|
|
151
180
|
/** The assistant's text response. Absent if tool calls are returned instead. */
|
|
152
|
-
readonly content?: string
|
|
181
|
+
readonly content?: string;
|
|
153
182
|
/** Optional name for the assistant. */
|
|
154
|
-
readonly name?: string
|
|
183
|
+
readonly name?: string;
|
|
155
184
|
/** Tool calls the model wants to execute, if any. */
|
|
156
|
-
readonly toolCalls?: Array<ToolCall
|
|
185
|
+
readonly toolCalls?: Array<ToolCall>;
|
|
157
186
|
/** Refusal reason, if the model declined to respond per safety policies. */
|
|
158
|
-
readonly refusal?: string
|
|
187
|
+
readonly refusal?: string;
|
|
159
188
|
/** Deprecated legacy function_call field; retained for API compatibility. */
|
|
160
|
-
readonly functionCall?: FunctionCall
|
|
189
|
+
readonly functionCall?: FunctionCall;
|
|
161
190
|
}
|
|
162
191
|
|
|
163
192
|
/** Audio content part for speech-capable models. */
|
|
164
193
|
export interface AudioContent {
|
|
165
194
|
/** Base64-encoded audio data. */
|
|
166
|
-
readonly data?: string
|
|
195
|
+
readonly data?: string;
|
|
167
196
|
/** Audio format (e.g., "wav", "mp3", "ogg"). */
|
|
168
|
-
readonly format?: string
|
|
197
|
+
readonly format?: string;
|
|
169
198
|
}
|
|
170
199
|
|
|
171
200
|
/** Auth configuration block. */
|
|
172
201
|
export interface AuthConfig {
|
|
173
202
|
/** Auth scheme classification. */
|
|
174
|
-
readonly authType: AuthType
|
|
203
|
+
readonly authType: AuthType;
|
|
175
204
|
/**
|
|
176
205
|
* Name of the environment variable that holds the API key (e.g. `"OPENAI_API_KEY"`).
|
|
177
206
|
* Holds the variable name, never the secret value.
|
|
178
207
|
*/
|
|
179
|
-
readonly envVar?: string
|
|
208
|
+
readonly envVar?: string;
|
|
180
209
|
}
|
|
181
210
|
|
|
182
211
|
/** How the API key is sent in the HTTP request. */
|
|
@@ -204,65 +233,65 @@ export declare enum AuthType {
|
|
|
204
233
|
/** Query parameters for listing batches. */
|
|
205
234
|
export interface BatchListQuery {
|
|
206
235
|
/** Maximum number of results to return. Defaults to 20. */
|
|
207
|
-
readonly limit?: number
|
|
236
|
+
readonly limit?: number;
|
|
208
237
|
/** Pagination cursor: return results after this batch ID. */
|
|
209
|
-
readonly after?: string
|
|
238
|
+
readonly after?: string;
|
|
210
239
|
}
|
|
211
240
|
|
|
212
241
|
/** Response from listing batches. */
|
|
213
242
|
export interface BatchListResponse {
|
|
214
243
|
/** Object type (always `"list"`). */
|
|
215
|
-
readonly object?: string
|
|
244
|
+
readonly object?: string;
|
|
216
245
|
/** List of batch objects. */
|
|
217
|
-
readonly data?: Array<BatchObject
|
|
246
|
+
readonly data?: Array<BatchObject>;
|
|
218
247
|
/** Whether more results are available. */
|
|
219
|
-
readonly hasMore?: boolean
|
|
248
|
+
readonly hasMore?: boolean;
|
|
220
249
|
/** First batch ID in the result set (for pagination). */
|
|
221
|
-
readonly firstId?: string
|
|
250
|
+
readonly firstId?: string;
|
|
222
251
|
/** Last batch ID in the result set (for pagination). */
|
|
223
|
-
readonly lastId?: string
|
|
252
|
+
readonly lastId?: string;
|
|
224
253
|
}
|
|
225
254
|
|
|
226
255
|
/** A batch job object. */
|
|
227
256
|
export interface BatchObject {
|
|
228
257
|
/** Unique batch ID. */
|
|
229
|
-
readonly id?: string
|
|
258
|
+
readonly id?: string;
|
|
230
259
|
/** Object type (always `"batch"`). */
|
|
231
|
-
readonly object?: string
|
|
260
|
+
readonly object?: string;
|
|
232
261
|
/** API endpoint (e.g., `"/v1/chat/completions"`). */
|
|
233
|
-
readonly endpoint?: string
|
|
262
|
+
readonly endpoint?: string;
|
|
234
263
|
/** ID of the input file. */
|
|
235
|
-
readonly inputFileId?: string
|
|
264
|
+
readonly inputFileId?: string;
|
|
236
265
|
/** Completion window (e.g., `"24h"`). */
|
|
237
|
-
readonly completionWindow?: string
|
|
266
|
+
readonly completionWindow?: string;
|
|
238
267
|
/** Current job status. */
|
|
239
|
-
readonly status?: BatchStatus
|
|
268
|
+
readonly status?: BatchStatus;
|
|
240
269
|
/** ID of the output file (present when completed). */
|
|
241
|
-
readonly outputFileId?: string
|
|
270
|
+
readonly outputFileId?: string;
|
|
242
271
|
/** ID of the error file (present if some requests failed). */
|
|
243
|
-
readonly errorFileId?: string
|
|
272
|
+
readonly errorFileId?: string;
|
|
244
273
|
/** Unix timestamp of batch creation. */
|
|
245
|
-
readonly createdAt?: number
|
|
274
|
+
readonly createdAt?: number;
|
|
246
275
|
/** Unix timestamp of completion (if completed). */
|
|
247
|
-
readonly completedAt?: number
|
|
276
|
+
readonly completedAt?: number;
|
|
248
277
|
/** Unix timestamp of failure (if failed). */
|
|
249
|
-
readonly failedAt?: number
|
|
278
|
+
readonly failedAt?: number;
|
|
250
279
|
/** Unix timestamp of expiration (if expired). */
|
|
251
|
-
readonly expiredAt?: number
|
|
280
|
+
readonly expiredAt?: number;
|
|
252
281
|
/** Request processing counts. */
|
|
253
|
-
readonly requestCounts?: BatchRequestCounts
|
|
282
|
+
readonly requestCounts?: BatchRequestCounts;
|
|
254
283
|
/** Metadata attached to the batch. */
|
|
255
|
-
readonly metadata?: JsonValue
|
|
284
|
+
readonly metadata?: JsonValue;
|
|
256
285
|
}
|
|
257
286
|
|
|
258
287
|
/** Request processing counts for a batch. */
|
|
259
288
|
export interface BatchRequestCounts {
|
|
260
289
|
/** Total requests in the batch. */
|
|
261
|
-
readonly total?: number
|
|
290
|
+
readonly total?: number;
|
|
262
291
|
/** Completed requests. */
|
|
263
|
-
readonly completed?: number
|
|
292
|
+
readonly completed?: number;
|
|
264
293
|
/** Failed requests. */
|
|
265
|
-
readonly failed?: number
|
|
294
|
+
readonly failed?: number;
|
|
266
295
|
}
|
|
267
296
|
|
|
268
297
|
/** Status of a batch job. */
|
|
@@ -288,147 +317,147 @@ export declare enum BatchStatus {
|
|
|
288
317
|
/** Configuration for budget enforcement. */
|
|
289
318
|
export interface BudgetConfig {
|
|
290
319
|
/** Maximum total spend across all models, in USD. `None` means unlimited. */
|
|
291
|
-
readonly globalLimit?: number
|
|
320
|
+
readonly globalLimit?: number;
|
|
292
321
|
/**
|
|
293
322
|
* Per-model spending limits in USD. Models not listed here are only
|
|
294
323
|
* constrained by `global_limit`.
|
|
295
324
|
*/
|
|
296
|
-
readonly modelLimits?: Record<string, number
|
|
325
|
+
readonly modelLimits?: Record<string, number>;
|
|
297
326
|
/** Whether to reject requests or merely warn when a limit is exceeded. */
|
|
298
|
-
readonly enforcement?: Enforcement
|
|
327
|
+
readonly enforcement?: Enforcement;
|
|
299
328
|
}
|
|
300
329
|
|
|
301
330
|
/** Storage backend for the response cache. */
|
|
302
331
|
export type CacheBackend =
|
|
303
|
-
| { type:
|
|
304
|
-
| { type:
|
|
332
|
+
| { type: "memory" }
|
|
333
|
+
| { type: "open_dal"; scheme: string; config: Record<string, string> };
|
|
305
334
|
|
|
306
335
|
/** Configuration for the response cache. */
|
|
307
336
|
export interface CacheConfig {
|
|
308
337
|
/** Maximum number of cached entries. */
|
|
309
|
-
readonly maxEntries?: number
|
|
338
|
+
readonly maxEntries?: number;
|
|
310
339
|
/** Time-to-live for each cached entry. */
|
|
311
|
-
readonly ttl?: number
|
|
340
|
+
readonly ttl?: number;
|
|
312
341
|
/** Storage backend to use. */
|
|
313
|
-
readonly backend?: CacheBackend
|
|
342
|
+
readonly backend?: CacheBackend;
|
|
314
343
|
}
|
|
315
344
|
|
|
316
345
|
/** A streamed chunk of a chat completion response. */
|
|
317
346
|
export interface ChatCompletionChunk {
|
|
318
347
|
/** Unique identifier for this stream. */
|
|
319
|
-
readonly id?: string
|
|
348
|
+
readonly id?: string;
|
|
320
349
|
/**
|
|
321
350
|
* Always `"chat.completion.chunk"` from OpenAI-compatible APIs. Stored
|
|
322
351
|
* as a plain `String` so non-standard provider values do not fail parsing.
|
|
323
352
|
*/
|
|
324
|
-
readonly object?: string
|
|
353
|
+
readonly object?: string;
|
|
325
354
|
/** Unix timestamp of chunk creation. */
|
|
326
|
-
readonly created?: number
|
|
355
|
+
readonly created?: number;
|
|
327
356
|
/** Model used to generate the chunk. */
|
|
328
|
-
readonly model?: string
|
|
357
|
+
readonly model?: string;
|
|
329
358
|
/** Streaming choices (delta updates). */
|
|
330
|
-
readonly choices?: Array<StreamChoice
|
|
359
|
+
readonly choices?: Array<StreamChoice>;
|
|
331
360
|
/** Token usage (typically only in the final chunk). */
|
|
332
|
-
readonly usage?: Usage
|
|
361
|
+
readonly usage?: Usage;
|
|
333
362
|
/** Fingerprint of the system configuration (OpenAI-specific). */
|
|
334
|
-
readonly systemFingerprint?: string
|
|
363
|
+
readonly systemFingerprint?: string;
|
|
335
364
|
/** Service tier used (OpenAI-specific). */
|
|
336
|
-
readonly serviceTier?: string
|
|
365
|
+
readonly serviceTier?: string;
|
|
337
366
|
}
|
|
338
367
|
|
|
339
368
|
/** Chat completion request (compatible with OpenAI and similar APIs). */
|
|
340
369
|
export interface ChatCompletionRequest {
|
|
341
370
|
/** Model ID (e.g., `"gpt-4o-mini"`, `"claude-3-5-sonnet"`). */
|
|
342
|
-
readonly model?: string
|
|
371
|
+
readonly model?: string;
|
|
343
372
|
/** Conversation history from oldest to newest. */
|
|
344
|
-
readonly messages?: Array<Message
|
|
373
|
+
readonly messages?: Array<Message>;
|
|
345
374
|
/** Sampling temperature in `[0.0, 2.0]`. Higher increases randomness. Defaults to 1.0. */
|
|
346
|
-
readonly temperature?: number
|
|
375
|
+
readonly temperature?: number;
|
|
347
376
|
/** Nucleus sampling parameter in `[0.0, 1.0]`. Lower is more focused. */
|
|
348
|
-
readonly topP?: number
|
|
377
|
+
readonly topP?: number;
|
|
349
378
|
/** Number of chat completions to generate. Defaults to 1. */
|
|
350
|
-
readonly n?: number
|
|
379
|
+
readonly n?: number;
|
|
351
380
|
/**
|
|
352
381
|
* Whether to stream the response.
|
|
353
382
|
*
|
|
354
383
|
* Managed by the client layer — do not set directly.
|
|
355
384
|
*/
|
|
356
|
-
readonly stream?: boolean
|
|
385
|
+
readonly stream?: boolean;
|
|
357
386
|
/** Stop sequence(s) that halt token generation. */
|
|
358
|
-
readonly stop?: StopSequence
|
|
387
|
+
readonly stop?: StopSequence;
|
|
359
388
|
/** Max output tokens. Different from max_completion_tokens in some providers. */
|
|
360
|
-
readonly maxTokens?: number
|
|
389
|
+
readonly maxTokens?: number;
|
|
361
390
|
/** Presence penalty in `[-2.0, 2.0]`. Positive discourages repeated topics. */
|
|
362
|
-
readonly presencePenalty?: number
|
|
391
|
+
readonly presencePenalty?: number;
|
|
363
392
|
/** Frequency penalty in `[-2.0, 2.0]`. Positive discourages repeated tokens. */
|
|
364
|
-
readonly frequencyPenalty?: number
|
|
393
|
+
readonly frequencyPenalty?: number;
|
|
365
394
|
/**
|
|
366
395
|
* Token bias map. Uses `BTreeMap` (sorted keys) for deterministic
|
|
367
396
|
* serialization order — important when hashing or signing requests.
|
|
368
397
|
*/
|
|
369
|
-
readonly logitBias?: Record<string, number
|
|
398
|
+
readonly logitBias?: Record<string, number>;
|
|
370
399
|
/** User identifier for request tracking and abuse detection. */
|
|
371
|
-
readonly user?: string
|
|
400
|
+
readonly user?: string;
|
|
372
401
|
/** Tools the model can invoke. */
|
|
373
|
-
readonly tools?: Array<ChatCompletionTool
|
|
402
|
+
readonly tools?: Array<ChatCompletionTool>;
|
|
374
403
|
/** Tool usage mode (auto, required, none, or specific tool). */
|
|
375
|
-
readonly toolChoice?: ToolChoice
|
|
404
|
+
readonly toolChoice?: ToolChoice;
|
|
376
405
|
/** Whether the model can call multiple tools in parallel. Defaults to true. */
|
|
377
|
-
readonly parallelToolCalls?: boolean
|
|
406
|
+
readonly parallelToolCalls?: boolean;
|
|
378
407
|
/** Output format constraint (text, JSON, JSON schema). */
|
|
379
|
-
readonly responseFormat?: ResponseFormat
|
|
408
|
+
readonly responseFormat?: ResponseFormat;
|
|
380
409
|
/** Streaming options (e.g., include_usage). */
|
|
381
|
-
readonly streamOptions?: StreamOptions
|
|
410
|
+
readonly streamOptions?: StreamOptions;
|
|
382
411
|
/** Random seed for reproducible outputs. Provider support varies. */
|
|
383
|
-
readonly seed?: number
|
|
412
|
+
readonly seed?: number;
|
|
384
413
|
/** Reasoning effort level (low, medium, high) for extended-thinking models. */
|
|
385
|
-
readonly reasoningEffort?: ReasoningEffort
|
|
414
|
+
readonly reasoningEffort?: ReasoningEffort;
|
|
386
415
|
/**
|
|
387
416
|
* Provider-specific extra parameters merged into the request body.
|
|
388
417
|
* Use for guardrails, safety settings, grounding config, etc.
|
|
389
418
|
*/
|
|
390
|
-
readonly extraBody?: JsonValue
|
|
419
|
+
readonly extraBody?: JsonValue;
|
|
391
420
|
}
|
|
392
421
|
|
|
393
422
|
/** Chat completion response from the API. */
|
|
394
423
|
export interface ChatCompletionResponse {
|
|
395
424
|
/** Unique identifier for this response. */
|
|
396
|
-
readonly id?: string
|
|
425
|
+
readonly id?: string;
|
|
397
426
|
/**
|
|
398
427
|
* Always `"chat.completion"` from OpenAI-compatible APIs. Stored as a
|
|
399
428
|
* plain `String` so non-standard provider values do not break deserialization.
|
|
400
429
|
*/
|
|
401
|
-
readonly object?: string
|
|
430
|
+
readonly object?: string;
|
|
402
431
|
/** Unix timestamp of response creation. */
|
|
403
|
-
readonly created?: number
|
|
432
|
+
readonly created?: number;
|
|
404
433
|
/** Model used to generate the response. */
|
|
405
|
-
readonly model?: string
|
|
434
|
+
readonly model?: string;
|
|
406
435
|
/** List of completion choices. */
|
|
407
|
-
readonly choices?: Array<Choice
|
|
436
|
+
readonly choices?: Array<Choice>;
|
|
408
437
|
/** Token usage statistics. */
|
|
409
|
-
readonly usage?: Usage
|
|
438
|
+
readonly usage?: Usage;
|
|
410
439
|
/** Fingerprint of the system configuration (OpenAI-specific). */
|
|
411
|
-
readonly systemFingerprint?: string
|
|
440
|
+
readonly systemFingerprint?: string;
|
|
412
441
|
/** Service tier used (OpenAI-specific). */
|
|
413
|
-
readonly serviceTier?: string
|
|
442
|
+
readonly serviceTier?: string;
|
|
414
443
|
}
|
|
415
444
|
|
|
416
445
|
/** A tool the model can invoke (currently, all tools are functions). */
|
|
417
446
|
export interface ChatCompletionTool {
|
|
418
447
|
/** Tool type (always "function" in OpenAI spec). */
|
|
419
|
-
readonly toolType: ToolType
|
|
448
|
+
readonly toolType: ToolType;
|
|
420
449
|
/** Function definition with name, description, and JSON schema parameters. */
|
|
421
|
-
readonly function: FunctionDefinition
|
|
450
|
+
readonly function: FunctionDefinition;
|
|
422
451
|
}
|
|
423
452
|
|
|
424
453
|
/** A single completion choice. */
|
|
425
454
|
export interface Choice {
|
|
426
455
|
/** Index of this choice in the choices array. */
|
|
427
|
-
readonly index?: number
|
|
456
|
+
readonly index?: number;
|
|
428
457
|
/** The assistant's message response. */
|
|
429
|
-
readonly message?: AssistantMessage
|
|
458
|
+
readonly message?: AssistantMessage;
|
|
430
459
|
/** Why the model stopped generating (stop, length, tool_calls, content_filter, etc.). */
|
|
431
|
-
readonly finishReason?: FinishReason
|
|
460
|
+
readonly finishReason?: FinishReason;
|
|
432
461
|
}
|
|
433
462
|
|
|
434
463
|
/**
|
|
@@ -449,7 +478,7 @@ export interface ChunkMiddleware {
|
|
|
449
478
|
* - `Ok(None)` — drop this chunk silently.
|
|
450
479
|
* - `Err(e)` — propagate as a stream error.
|
|
451
480
|
*/
|
|
452
|
-
process(chunk?: ChatCompletionChunk | undefined | null): string
|
|
481
|
+
process(chunk?: ChatCompletionChunk | undefined | null): string;
|
|
453
482
|
}
|
|
454
483
|
|
|
455
484
|
/** Observable state of a circuit breaker. */
|
|
@@ -464,111 +493,111 @@ export declare enum CircuitState {
|
|
|
464
493
|
|
|
465
494
|
/** A single content part in a user message — text, image, document, or audio. */
|
|
466
495
|
export type ContentPart =
|
|
467
|
-
| { type:
|
|
468
|
-
| { type:
|
|
469
|
-
| { type:
|
|
470
|
-
| { type:
|
|
496
|
+
| { type: "text"; text: string }
|
|
497
|
+
| { type: "image_url"; imageUrl: ImageUrl }
|
|
498
|
+
| { type: "document"; document: DocumentContent }
|
|
499
|
+
| { type: "input_audio"; inputAudio: AudioContent };
|
|
471
500
|
|
|
472
501
|
/** Request to create a batch job. */
|
|
473
502
|
export interface CreateBatchRequest {
|
|
474
503
|
/** ID of the uploaded input file (JSONL format). */
|
|
475
|
-
readonly inputFileId?: string
|
|
504
|
+
readonly inputFileId?: string;
|
|
476
505
|
/** API endpoint (e.g., `"/v1/chat/completions"`). */
|
|
477
|
-
readonly endpoint?: string
|
|
506
|
+
readonly endpoint?: string;
|
|
478
507
|
/** Completion window (e.g., `"24h"`). */
|
|
479
|
-
readonly completionWindow?: string
|
|
508
|
+
readonly completionWindow?: string;
|
|
480
509
|
/** Optional metadata to attach to the batch. */
|
|
481
|
-
readonly metadata?: JsonValue
|
|
510
|
+
readonly metadata?: JsonValue;
|
|
482
511
|
}
|
|
483
512
|
|
|
484
513
|
/** Request to upload a file. */
|
|
485
514
|
export interface CreateFileRequest {
|
|
486
515
|
/** Base64-encoded file data. */
|
|
487
|
-
readonly file?: string
|
|
516
|
+
readonly file?: string;
|
|
488
517
|
/** Purpose for the file. */
|
|
489
|
-
readonly purpose?: FilePurpose
|
|
518
|
+
readonly purpose?: FilePurpose;
|
|
490
519
|
/** Optional filename to associate with the upload. */
|
|
491
|
-
readonly filename?: string
|
|
520
|
+
readonly filename?: string;
|
|
492
521
|
}
|
|
493
522
|
|
|
494
523
|
/** Request to create images from a text prompt. */
|
|
495
524
|
export interface CreateImageRequest {
|
|
496
525
|
/** Text description of the image to generate. */
|
|
497
|
-
readonly prompt?: string
|
|
526
|
+
readonly prompt?: string;
|
|
498
527
|
/** Model ID (e.g., `"dall-e-3"`). Optional; API may use default if unset. */
|
|
499
|
-
readonly model?: string
|
|
528
|
+
readonly model?: string;
|
|
500
529
|
/** Number of images to generate. Defaults to 1. */
|
|
501
|
-
readonly n?: number
|
|
530
|
+
readonly n?: number;
|
|
502
531
|
/** Image size (e.g., `"1024x1024"`, `"1792x1024"`). */
|
|
503
|
-
readonly size?: string
|
|
532
|
+
readonly size?: string;
|
|
504
533
|
/** Image quality: `"standard"` or `"hd"`. */
|
|
505
|
-
readonly quality?: string
|
|
534
|
+
readonly quality?: string;
|
|
506
535
|
/** Style: `"natural"` or `"vivid"` (DALL-E 3 only). */
|
|
507
|
-
readonly style?: string
|
|
536
|
+
readonly style?: string;
|
|
508
537
|
/** Response format: `"url"` or `"b64_json"`. */
|
|
509
|
-
readonly responseFormat?: string
|
|
538
|
+
readonly responseFormat?: string;
|
|
510
539
|
/** User identifier for request tracking. */
|
|
511
|
-
readonly user?: string
|
|
540
|
+
readonly user?: string;
|
|
512
541
|
}
|
|
513
542
|
|
|
514
543
|
/** Request to create a structured response. */
|
|
515
544
|
export interface CreateResponseRequest {
|
|
516
545
|
/** Model ID. */
|
|
517
|
-
readonly model?: string
|
|
546
|
+
readonly model?: string;
|
|
518
547
|
/** Input data to process (e.g., a document to extract from). */
|
|
519
|
-
readonly input?: JsonValue
|
|
548
|
+
readonly input?: JsonValue;
|
|
520
549
|
/** Instructions for processing the input. */
|
|
521
|
-
readonly instructions?: string
|
|
550
|
+
readonly instructions?: string;
|
|
522
551
|
/** Available tools the model can use. */
|
|
523
|
-
readonly tools?: Array<ResponseTool
|
|
552
|
+
readonly tools?: Array<ResponseTool>;
|
|
524
553
|
/** Sampling temperature in `[0.0, 2.0]`. Defaults to 1.0. */
|
|
525
|
-
readonly temperature?: number
|
|
554
|
+
readonly temperature?: number;
|
|
526
555
|
/** Maximum output tokens. */
|
|
527
|
-
readonly maxOutputTokens?: number
|
|
556
|
+
readonly maxOutputTokens?: number;
|
|
528
557
|
/** Optional metadata. */
|
|
529
|
-
readonly metadata?: JsonValue
|
|
558
|
+
readonly metadata?: JsonValue;
|
|
530
559
|
}
|
|
531
560
|
|
|
532
561
|
/** Request to generate speech audio from text. */
|
|
533
562
|
export interface CreateSpeechRequest {
|
|
534
563
|
/** Model ID (e.g., `"tts-1"`, `"tts-1-hd"`). */
|
|
535
|
-
readonly model?: string
|
|
564
|
+
readonly model?: string;
|
|
536
565
|
/** Text to synthesize into speech. */
|
|
537
|
-
readonly input?: string
|
|
566
|
+
readonly input?: string;
|
|
538
567
|
/** Voice name (e.g., `"alloy"`, `"echo"`, `"fable"`, `"onyx"`, `"nova"`, `"shimmer"`). */
|
|
539
|
-
readonly voice?: string
|
|
568
|
+
readonly voice?: string;
|
|
540
569
|
/** Audio format (e.g., `"mp3"`, `"opus"`, `"aac"`, `"flac"`, `"wav"`, `"pcm"`). */
|
|
541
|
-
readonly responseFormat?: string
|
|
570
|
+
readonly responseFormat?: string;
|
|
542
571
|
/** Playback speed in `[0.25, 4.0]`. Defaults to 1.0. */
|
|
543
|
-
readonly speed?: number
|
|
572
|
+
readonly speed?: number;
|
|
544
573
|
}
|
|
545
574
|
|
|
546
575
|
/** Request to transcribe audio into text. */
|
|
547
576
|
export interface CreateTranscriptionRequest {
|
|
548
577
|
/** Model ID (e.g., `"whisper-1"`). */
|
|
549
|
-
readonly model?: string
|
|
578
|
+
readonly model?: string;
|
|
550
579
|
/** Base64-encoded audio file data. */
|
|
551
|
-
readonly file?: string
|
|
580
|
+
readonly file?: string;
|
|
552
581
|
/** Language ISO-639-1 code (e.g., `"en"`, `"fr"`, `"de"`). Optional; model auto-detects. */
|
|
553
|
-
readonly language?: string
|
|
582
|
+
readonly language?: string;
|
|
554
583
|
/** Optional text to guide the model (improves accuracy for domain-specific terms). */
|
|
555
|
-
readonly prompt?: string
|
|
584
|
+
readonly prompt?: string;
|
|
556
585
|
/** Output format (e.g., `"json"`, `"text"`, `"vtt"`, `"srt"`, `"verbose_json"`). */
|
|
557
|
-
readonly responseFormat?: string
|
|
586
|
+
readonly responseFormat?: string;
|
|
558
587
|
/** Sampling temperature in `[0.0, 1.0]`. Higher increases variability. Defaults to 0. */
|
|
559
|
-
readonly temperature?: number
|
|
588
|
+
readonly temperature?: number;
|
|
560
589
|
}
|
|
561
590
|
|
|
562
591
|
/** Configuration for registering a custom LLM provider at runtime. */
|
|
563
592
|
export interface CustomProviderConfig {
|
|
564
593
|
/** Unique name for this provider (e.g., "my-provider"). */
|
|
565
|
-
readonly name: string
|
|
594
|
+
readonly name: string;
|
|
566
595
|
/** Base URL for the provider's API (e.g., "https://api.my-provider.com/v1"). */
|
|
567
|
-
readonly baseUrl: string
|
|
596
|
+
readonly baseUrl: string;
|
|
568
597
|
/** Authentication header format. */
|
|
569
|
-
readonly authHeader: AuthHeaderFormat
|
|
598
|
+
readonly authHeader: AuthHeaderFormat;
|
|
570
599
|
/** Model name prefixes that route to this provider (e.g., `["my-"]`). */
|
|
571
|
-
readonly modelPrefixes: Array<string
|
|
600
|
+
readonly modelPrefixes: Array<string>;
|
|
572
601
|
}
|
|
573
602
|
|
|
574
603
|
/**
|
|
@@ -589,27 +618,29 @@ export interface CustomProviderConfig {
|
|
|
589
618
|
* headers are cached at construction to avoid redundant encoding on every request.
|
|
590
619
|
*/
|
|
591
620
|
export declare class DefaultClient {
|
|
592
|
-
chat(req?: ChatCompletionRequest | undefined | null): Promise<ChatCompletionResponse
|
|
593
|
-
chatStream(
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
621
|
+
chat(req?: ChatCompletionRequest | undefined | null): Promise<ChatCompletionResponse>;
|
|
622
|
+
chatStream(
|
|
623
|
+
req?: ChatCompletionRequest | undefined | null,
|
|
624
|
+
): Promise<AsyncGenerator<ChatCompletionChunk, void, undefined>>;
|
|
625
|
+
embed(req?: EmbeddingRequest | undefined | null): Promise<EmbeddingResponse>;
|
|
626
|
+
listModels(): Promise<ModelsListResponse>;
|
|
627
|
+
imageGenerate(req?: CreateImageRequest | undefined | null): Promise<ImagesResponse>;
|
|
628
|
+
speech(req?: CreateSpeechRequest | undefined | null): Promise<Uint8Array>;
|
|
629
|
+
transcribe(req?: CreateTranscriptionRequest | undefined | null): Promise<TranscriptionResponse>;
|
|
630
|
+
moderate(req?: ModerationRequest | undefined | null): Promise<ModerationResponse>;
|
|
631
|
+
rerank(req?: RerankRequest | undefined | null): Promise<RerankResponse>;
|
|
632
|
+
search(req?: SearchRequest | undefined | null): Promise<SearchResponse>;
|
|
633
|
+
ocr(req?: OcrRequest | undefined | null): Promise<OcrResponse>;
|
|
634
|
+
createFile(req?: CreateFileRequest | undefined | null): Promise<FileObject>;
|
|
635
|
+
retrieveFile(fileId: string): Promise<FileObject>;
|
|
636
|
+
deleteFile(fileId: string): Promise<DeleteResponse>;
|
|
637
|
+
listFiles(query?: FileListQuery | undefined | null): Promise<FileListResponse>;
|
|
638
|
+
fileContent(fileId: string): Promise<Uint8Array>;
|
|
639
|
+
createBatch(req?: CreateBatchRequest | undefined | null): Promise<BatchObject>;
|
|
640
|
+
retrieveBatch(batchId: string): Promise<BatchObject>;
|
|
641
|
+
listBatches(query?: BatchListQuery | undefined | null): Promise<BatchListResponse>;
|
|
642
|
+
cancelBatch(batchId: string): Promise<BatchObject>;
|
|
643
|
+
fetchBatchForPolling(batchId: string): Promise<BatchObject>;
|
|
613
644
|
/**
|
|
614
645
|
* Poll a batch until it reaches a terminal status (Completed, Failed, Expired, Cancelled).
|
|
615
646
|
*
|
|
@@ -619,36 +650,39 @@ export declare class DefaultClient {
|
|
|
619
650
|
* Returns `BatchWaitError::Timeout` if the configured timeout is exceeded.
|
|
620
651
|
* Returns `BatchWaitError::Client` for underlying client errors.
|
|
621
652
|
*/
|
|
622
|
-
waitForBatch(
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
653
|
+
waitForBatch(
|
|
654
|
+
batchId: string,
|
|
655
|
+
config?: WaitForBatchConfig | undefined | null,
|
|
656
|
+
): Promise<BatchObject>;
|
|
657
|
+
createResponse(req?: CreateResponseRequest | undefined | null): Promise<ResponseObject>;
|
|
658
|
+
retrieveResponse(responseId: string): Promise<ResponseObject>;
|
|
659
|
+
cancelResponse(responseId: string): Promise<ResponseObject>;
|
|
626
660
|
}
|
|
627
661
|
|
|
628
662
|
/** Response from a delete operation. */
|
|
629
663
|
export interface DeleteResponse {
|
|
630
664
|
/** ID of the deleted resource. */
|
|
631
|
-
readonly id?: string
|
|
665
|
+
readonly id?: string;
|
|
632
666
|
/** Object type. */
|
|
633
|
-
readonly object?: string
|
|
667
|
+
readonly object?: string;
|
|
634
668
|
/** Confirmation that the resource was deleted. */
|
|
635
|
-
readonly deleted?: boolean
|
|
669
|
+
readonly deleted?: boolean;
|
|
636
670
|
}
|
|
637
671
|
|
|
638
672
|
/** Developer message (system-like message for Claude models). */
|
|
639
673
|
export interface DeveloperMessage {
|
|
640
674
|
/** Developer-specific instructions or context. */
|
|
641
|
-
readonly content?: string
|
|
675
|
+
readonly content?: string;
|
|
642
676
|
/** Optional name for the developer message source. */
|
|
643
|
-
readonly name?: string
|
|
677
|
+
readonly name?: string;
|
|
644
678
|
}
|
|
645
679
|
|
|
646
680
|
/** PDF/document content part for vision-capable models. */
|
|
647
681
|
export interface DocumentContent {
|
|
648
682
|
/** Base64-encoded document data or URL. */
|
|
649
|
-
readonly data?: string
|
|
683
|
+
readonly data?: string;
|
|
650
684
|
/** MIME type (e.g., "application/pdf", "text/csv"). */
|
|
651
|
-
readonly mediaType?: string
|
|
685
|
+
readonly mediaType?: string;
|
|
652
686
|
}
|
|
653
687
|
|
|
654
688
|
/** The format in which the embedding vectors are returned. */
|
|
@@ -673,25 +707,25 @@ export interface EmbeddingObject {
|
|
|
673
707
|
* Always `"embedding"` from OpenAI-compatible APIs. Stored as a plain
|
|
674
708
|
* `String` so non-standard provider values do not break deserialization.
|
|
675
709
|
*/
|
|
676
|
-
readonly object: string
|
|
710
|
+
readonly object: string;
|
|
677
711
|
/** The embedding vector. */
|
|
678
|
-
readonly embedding: Array<number
|
|
712
|
+
readonly embedding: Array<number>;
|
|
679
713
|
/** Index in the batch (corresponds to input order). */
|
|
680
|
-
readonly index: number
|
|
714
|
+
readonly index: number;
|
|
681
715
|
}
|
|
682
716
|
|
|
683
717
|
/** Embedding request. */
|
|
684
718
|
export interface EmbeddingRequest {
|
|
685
719
|
/** Model ID (e.g., `"text-embedding-3-small"`). */
|
|
686
|
-
readonly model?: string
|
|
720
|
+
readonly model?: string;
|
|
687
721
|
/** Text or texts to embed. */
|
|
688
|
-
readonly input?: EmbeddingInput
|
|
722
|
+
readonly input?: EmbeddingInput;
|
|
689
723
|
/** Output format: float (native) or base64. */
|
|
690
|
-
readonly encodingFormat?: EmbeddingFormat
|
|
724
|
+
readonly encodingFormat?: EmbeddingFormat;
|
|
691
725
|
/** Requested embedding dimensions (if supported by the model). */
|
|
692
|
-
readonly dimensions?: number
|
|
726
|
+
readonly dimensions?: number;
|
|
693
727
|
/** User identifier for request tracking. */
|
|
694
|
-
readonly user?: string
|
|
728
|
+
readonly user?: string;
|
|
695
729
|
}
|
|
696
730
|
|
|
697
731
|
/** Embedding response. */
|
|
@@ -700,13 +734,13 @@ export interface EmbeddingResponse {
|
|
|
700
734
|
* Always `"list"` from OpenAI-compatible APIs. Stored as a plain
|
|
701
735
|
* `String` so non-standard provider values do not break deserialization.
|
|
702
736
|
*/
|
|
703
|
-
readonly object: string
|
|
737
|
+
readonly object: string;
|
|
704
738
|
/** List of embeddings. */
|
|
705
|
-
readonly data: Array<EmbeddingObject
|
|
739
|
+
readonly data: Array<EmbeddingObject>;
|
|
706
740
|
/** Model used to generate embeddings. */
|
|
707
|
-
readonly model: string
|
|
741
|
+
readonly model: string;
|
|
708
742
|
/** Token usage (input tokens only; embeddings have zero output tokens). */
|
|
709
|
-
readonly usage?: Usage
|
|
743
|
+
readonly usage?: Usage;
|
|
710
744
|
}
|
|
711
745
|
|
|
712
746
|
/** How budget limits are enforced. */
|
|
@@ -726,39 +760,39 @@ export declare enum Enforcement {
|
|
|
726
760
|
/** Query parameters for listing files. */
|
|
727
761
|
export interface FileListQuery {
|
|
728
762
|
/** Filter by file purpose (e.g., `"batch"`, `"fine-tune"`). */
|
|
729
|
-
readonly purpose?: string
|
|
763
|
+
readonly purpose?: string;
|
|
730
764
|
/** Maximum number of results to return. Defaults to 20. */
|
|
731
|
-
readonly limit?: number
|
|
765
|
+
readonly limit?: number;
|
|
732
766
|
/** Pagination cursor: return results after this file ID. */
|
|
733
|
-
readonly after?: string
|
|
767
|
+
readonly after?: string;
|
|
734
768
|
}
|
|
735
769
|
|
|
736
770
|
/** Response from listing files. */
|
|
737
771
|
export interface FileListResponse {
|
|
738
772
|
/** Object type (always `"list"`). */
|
|
739
|
-
readonly object?: string
|
|
773
|
+
readonly object?: string;
|
|
740
774
|
/** List of file objects. */
|
|
741
|
-
readonly data?: Array<FileObject
|
|
775
|
+
readonly data?: Array<FileObject>;
|
|
742
776
|
/** Whether more results are available. */
|
|
743
|
-
readonly hasMore?: boolean
|
|
777
|
+
readonly hasMore?: boolean;
|
|
744
778
|
}
|
|
745
779
|
|
|
746
780
|
/** An uploaded file object. */
|
|
747
781
|
export interface FileObject {
|
|
748
782
|
/** Unique file ID. */
|
|
749
|
-
readonly id?: string
|
|
783
|
+
readonly id?: string;
|
|
750
784
|
/** Object type (always `"file"`). */
|
|
751
|
-
readonly object?: string
|
|
785
|
+
readonly object?: string;
|
|
752
786
|
/** File size in bytes. */
|
|
753
|
-
readonly bytes?: number
|
|
787
|
+
readonly bytes?: number;
|
|
754
788
|
/** Unix timestamp of file creation. */
|
|
755
|
-
readonly createdAt?: number
|
|
789
|
+
readonly createdAt?: number;
|
|
756
790
|
/** Filename. */
|
|
757
|
-
readonly filename?: string
|
|
791
|
+
readonly filename?: string;
|
|
758
792
|
/** File purpose. */
|
|
759
|
-
readonly purpose?: string
|
|
793
|
+
readonly purpose?: string;
|
|
760
794
|
/** Processing status (e.g., `"uploaded"`, `"processed"`). */
|
|
761
|
-
readonly status?: string
|
|
795
|
+
readonly status?: string;
|
|
762
796
|
}
|
|
763
797
|
|
|
764
798
|
/** Purpose of an uploaded file. */
|
|
@@ -796,27 +830,27 @@ export declare enum FinishReason {
|
|
|
796
830
|
/** Function call details. */
|
|
797
831
|
export interface FunctionCall {
|
|
798
832
|
/** Function name. */
|
|
799
|
-
readonly name: string
|
|
833
|
+
readonly name: string;
|
|
800
834
|
/** Arguments as a JSON string (parse with serde_json::from_str). */
|
|
801
|
-
readonly arguments: string
|
|
835
|
+
readonly arguments: string;
|
|
802
836
|
}
|
|
803
837
|
|
|
804
838
|
/** Function definition exposed to the model. */
|
|
805
839
|
export interface FunctionDefinition {
|
|
806
840
|
/** Name of the function. Required and must be alphanumeric + underscores. */
|
|
807
|
-
readonly name: string
|
|
841
|
+
readonly name: string;
|
|
808
842
|
/** Human-readable description explaining what the function does. */
|
|
809
|
-
readonly description?: string
|
|
843
|
+
readonly description?: string;
|
|
810
844
|
/** JSON Schema defining the function's parameters. */
|
|
811
|
-
readonly parameters?: JsonValue
|
|
845
|
+
readonly parameters?: JsonValue;
|
|
812
846
|
/** If true, enforce strict JSON schema validation for arguments. */
|
|
813
|
-
readonly strict?: boolean
|
|
847
|
+
readonly strict?: boolean;
|
|
814
848
|
}
|
|
815
849
|
|
|
816
850
|
/** Deprecated legacy function-role message body. */
|
|
817
851
|
export interface FunctionMessage {
|
|
818
|
-
readonly content?: string
|
|
819
|
-
readonly name?: string
|
|
852
|
+
readonly content?: string;
|
|
853
|
+
readonly name?: string;
|
|
820
854
|
}
|
|
821
855
|
|
|
822
856
|
/**
|
|
@@ -833,7 +867,7 @@ export interface HealthChecker {
|
|
|
833
867
|
* move it into the returned future without a clone, making the
|
|
834
868
|
* `'static + Send` bound on the future trivially satisfiable.
|
|
835
869
|
*/
|
|
836
|
-
check(upstream: string): Promise<string
|
|
870
|
+
check(upstream: string): Promise<string>;
|
|
837
871
|
}
|
|
838
872
|
|
|
839
873
|
/** The result of a single health probe. */
|
|
@@ -847,11 +881,11 @@ export declare enum HealthStatus {
|
|
|
847
881
|
/** A single generated image, returned as either a URL or base64 data. */
|
|
848
882
|
export interface Image {
|
|
849
883
|
/** Image URL (if response_format was "url"). */
|
|
850
|
-
readonly url?: string
|
|
884
|
+
readonly url?: string;
|
|
851
885
|
/** Base64-encoded image data (if response_format was "b64_json"). */
|
|
852
|
-
readonly b64Json?: string
|
|
886
|
+
readonly b64Json?: string;
|
|
853
887
|
/** The final prompt used to generate the image (DALL-E 3). */
|
|
854
|
-
readonly revisedPrompt?: string
|
|
888
|
+
readonly revisedPrompt?: string;
|
|
855
889
|
}
|
|
856
890
|
|
|
857
891
|
/** Image detail level controlling token cost and processing. */
|
|
@@ -867,63 +901,63 @@ export declare enum ImageDetail {
|
|
|
867
901
|
/** Response containing generated images. */
|
|
868
902
|
export interface ImagesResponse {
|
|
869
903
|
/** Unix timestamp of image creation. */
|
|
870
|
-
readonly created?: number
|
|
904
|
+
readonly created?: number;
|
|
871
905
|
/** List of generated images. */
|
|
872
|
-
readonly data?: Array<Image
|
|
906
|
+
readonly data?: Array<Image>;
|
|
873
907
|
}
|
|
874
908
|
|
|
875
909
|
/** An image URL reference with optional detail level for processing. */
|
|
876
910
|
export interface ImageUrl {
|
|
877
911
|
/** URL of the image (data URI or HTTP/HTTPS URL). */
|
|
878
|
-
readonly url?: string
|
|
912
|
+
readonly url?: string;
|
|
879
913
|
/** Detail level: low (512x512), high (2x2 tiles), or auto (model-selected). */
|
|
880
|
-
readonly detail?: ImageDetail
|
|
914
|
+
readonly detail?: ImageDetail;
|
|
881
915
|
}
|
|
882
916
|
|
|
883
917
|
/** An intent prototype: `(intent_name, prototype_embedding, target_model_id)`. */
|
|
884
918
|
export interface IntentPrototype {
|
|
885
919
|
/** Human-readable name for the intent (used in logs/metrics). */
|
|
886
|
-
readonly name: string
|
|
920
|
+
readonly name: string;
|
|
887
921
|
/** Pre-computed embedding vector for this intent. */
|
|
888
|
-
readonly embedding: Array<number
|
|
922
|
+
readonly embedding: Array<number>;
|
|
889
923
|
/** Model to route to when this intent is detected. */
|
|
890
|
-
readonly model: string
|
|
924
|
+
readonly model: string;
|
|
891
925
|
}
|
|
892
926
|
|
|
893
927
|
/** JSON Schema specification for constrained output. */
|
|
894
928
|
export interface JsonSchemaFormat {
|
|
895
929
|
/** Name of the schema (must be unique in the request). */
|
|
896
|
-
readonly name?: string
|
|
930
|
+
readonly name?: string;
|
|
897
931
|
/** Description of what the schema represents. */
|
|
898
|
-
readonly description?: string
|
|
932
|
+
readonly description?: string;
|
|
899
933
|
/** JSON Schema object defining the output structure. */
|
|
900
|
-
readonly schema?: JsonValue
|
|
934
|
+
readonly schema?: JsonValue;
|
|
901
935
|
/** If true, enforce strict schema validation. */
|
|
902
|
-
readonly strict?: boolean
|
|
936
|
+
readonly strict?: boolean;
|
|
903
937
|
}
|
|
904
938
|
|
|
905
939
|
/** A chat message in a conversation. */
|
|
906
940
|
export type Message =
|
|
907
|
-
| { role:
|
|
908
|
-
| { role:
|
|
909
|
-
| { role:
|
|
910
|
-
| { role:
|
|
911
|
-
| { role:
|
|
912
|
-
| { role:
|
|
941
|
+
| { role: "system"; 0: SystemMessage }
|
|
942
|
+
| { role: "user"; 0: UserMessage }
|
|
943
|
+
| { role: "assistant"; 0: AssistantMessage }
|
|
944
|
+
| { role: "tool"; 0: ToolMessage }
|
|
945
|
+
| { role: "developer"; 0: DeveloperMessage }
|
|
946
|
+
| { role: "function"; 0: FunctionMessage };
|
|
913
947
|
|
|
914
948
|
/** A model available from the API. */
|
|
915
949
|
export interface ModelObject {
|
|
916
950
|
/** Model ID (e.g., `"gpt-4o"`, `"claude-3-5-sonnet"`). */
|
|
917
|
-
readonly id?: string
|
|
951
|
+
readonly id?: string;
|
|
918
952
|
/**
|
|
919
953
|
* Always `"model"` from OpenAI-compatible APIs. Stored as a plain
|
|
920
954
|
* `String` so non-standard provider values do not break deserialization.
|
|
921
955
|
*/
|
|
922
|
-
readonly object?: string
|
|
956
|
+
readonly object?: string;
|
|
923
957
|
/** Unix timestamp of model creation (or release date). */
|
|
924
|
-
readonly created?: number
|
|
958
|
+
readonly created?: number;
|
|
925
959
|
/** Organization or entity that owns the model. */
|
|
926
|
-
readonly ownedBy?: string
|
|
960
|
+
readonly ownedBy?: string;
|
|
927
961
|
}
|
|
928
962
|
|
|
929
963
|
/** Response listing available models. */
|
|
@@ -932,61 +966,61 @@ export interface ModelsListResponse {
|
|
|
932
966
|
* Always `"list"` from OpenAI-compatible APIs. Stored as a plain
|
|
933
967
|
* `String` so non-standard provider values do not break deserialization.
|
|
934
968
|
*/
|
|
935
|
-
readonly object?: string
|
|
969
|
+
readonly object?: string;
|
|
936
970
|
/** List of available models. */
|
|
937
|
-
readonly data?: Array<ModelObject
|
|
971
|
+
readonly data?: Array<ModelObject>;
|
|
938
972
|
}
|
|
939
973
|
|
|
940
974
|
/** Boolean flags for each moderation category. */
|
|
941
975
|
export interface ModerationCategories {
|
|
942
976
|
/** Sexual content. */
|
|
943
|
-
readonly sexual?: boolean
|
|
977
|
+
readonly sexual?: boolean;
|
|
944
978
|
/** Hate speech. */
|
|
945
|
-
readonly hate?: boolean
|
|
979
|
+
readonly hate?: boolean;
|
|
946
980
|
/** Harassment. */
|
|
947
|
-
readonly harassment?: boolean
|
|
981
|
+
readonly harassment?: boolean;
|
|
948
982
|
/** Self-harm content. */
|
|
949
|
-
readonly selfHarm?: boolean
|
|
983
|
+
readonly selfHarm?: boolean;
|
|
950
984
|
/** Sexual content involving minors. */
|
|
951
|
-
readonly sexualMinors?: boolean
|
|
985
|
+
readonly sexualMinors?: boolean;
|
|
952
986
|
/** Hate speech that threatens violence. */
|
|
953
|
-
readonly hateThreatening?: boolean
|
|
987
|
+
readonly hateThreatening?: boolean;
|
|
954
988
|
/** Graphic violence. */
|
|
955
|
-
readonly violenceGraphic?: boolean
|
|
989
|
+
readonly violenceGraphic?: boolean;
|
|
956
990
|
/** Intent to self-harm. */
|
|
957
|
-
readonly selfHarmIntent?: boolean
|
|
991
|
+
readonly selfHarmIntent?: boolean;
|
|
958
992
|
/** Instructions for self-harm. */
|
|
959
|
-
readonly selfHarmInstructions?: boolean
|
|
993
|
+
readonly selfHarmInstructions?: boolean;
|
|
960
994
|
/** Harassment that threatens violence. */
|
|
961
|
-
readonly harassmentThreatening?: boolean
|
|
995
|
+
readonly harassmentThreatening?: boolean;
|
|
962
996
|
/** Non-graphic violence. */
|
|
963
|
-
readonly violence?: boolean
|
|
997
|
+
readonly violence?: boolean;
|
|
964
998
|
}
|
|
965
999
|
|
|
966
1000
|
/** Confidence scores for each moderation category. */
|
|
967
1001
|
export interface ModerationCategoryScores {
|
|
968
1002
|
/** Sexual content score. */
|
|
969
|
-
readonly sexual?: number
|
|
1003
|
+
readonly sexual?: number;
|
|
970
1004
|
/** Hate speech score. */
|
|
971
|
-
readonly hate?: number
|
|
1005
|
+
readonly hate?: number;
|
|
972
1006
|
/** Harassment score. */
|
|
973
|
-
readonly harassment?: number
|
|
1007
|
+
readonly harassment?: number;
|
|
974
1008
|
/** Self-harm content score. */
|
|
975
|
-
readonly selfHarm?: number
|
|
1009
|
+
readonly selfHarm?: number;
|
|
976
1010
|
/** Sexual content involving minors score. */
|
|
977
|
-
readonly sexualMinors?: number
|
|
1011
|
+
readonly sexualMinors?: number;
|
|
978
1012
|
/** Hate speech that threatens violence score. */
|
|
979
|
-
readonly hateThreatening?: number
|
|
1013
|
+
readonly hateThreatening?: number;
|
|
980
1014
|
/** Graphic violence score. */
|
|
981
|
-
readonly violenceGraphic?: number
|
|
1015
|
+
readonly violenceGraphic?: number;
|
|
982
1016
|
/** Intent to self-harm score. */
|
|
983
|
-
readonly selfHarmIntent?: number
|
|
1017
|
+
readonly selfHarmIntent?: number;
|
|
984
1018
|
/** Instructions for self-harm score. */
|
|
985
|
-
readonly selfHarmInstructions?: number
|
|
1019
|
+
readonly selfHarmInstructions?: number;
|
|
986
1020
|
/** Harassment that threatens violence score. */
|
|
987
|
-
readonly harassmentThreatening?: number
|
|
1021
|
+
readonly harassmentThreatening?: number;
|
|
988
1022
|
/** Non-graphic violence score. */
|
|
989
|
-
readonly violence?: number
|
|
1023
|
+
readonly violence?: number;
|
|
990
1024
|
}
|
|
991
1025
|
|
|
992
1026
|
/** Input to the moderation endpoint — a single string or multiple strings. */
|
|
@@ -1000,84 +1034,84 @@ export declare enum ModerationInput {
|
|
|
1000
1034
|
/** Request to classify content for policy violations. */
|
|
1001
1035
|
export interface ModerationRequest {
|
|
1002
1036
|
/** Text or texts to check. */
|
|
1003
|
-
readonly input?: ModerationInput
|
|
1037
|
+
readonly input?: ModerationInput;
|
|
1004
1038
|
/** Model ID (e.g., `"text-moderation-latest"`). Optional; API uses default if unset. */
|
|
1005
|
-
readonly model?: string
|
|
1039
|
+
readonly model?: string;
|
|
1006
1040
|
}
|
|
1007
1041
|
|
|
1008
1042
|
/** Response from the moderation endpoint. */
|
|
1009
1043
|
export interface ModerationResponse {
|
|
1010
1044
|
/** Unique identifier for this moderation request. */
|
|
1011
|
-
readonly id: string
|
|
1045
|
+
readonly id: string;
|
|
1012
1046
|
/** Model used for classification. */
|
|
1013
|
-
readonly model: string
|
|
1047
|
+
readonly model: string;
|
|
1014
1048
|
/** Results for each input string. */
|
|
1015
|
-
readonly results: Array<ModerationResult
|
|
1049
|
+
readonly results: Array<ModerationResult>;
|
|
1016
1050
|
}
|
|
1017
1051
|
|
|
1018
1052
|
/** A single moderation classification result. */
|
|
1019
1053
|
export interface ModerationResult {
|
|
1020
1054
|
/** True if any category was flagged. */
|
|
1021
|
-
readonly flagged: boolean
|
|
1055
|
+
readonly flagged: boolean;
|
|
1022
1056
|
/** Boolean flags for each moderation category. */
|
|
1023
|
-
readonly categories: ModerationCategories
|
|
1057
|
+
readonly categories: ModerationCategories;
|
|
1024
1058
|
/** Confidence scores for each category. */
|
|
1025
|
-
readonly categoryScores: ModerationCategoryScores
|
|
1059
|
+
readonly categoryScores: ModerationCategoryScores;
|
|
1026
1060
|
}
|
|
1027
1061
|
|
|
1028
1062
|
/** Document input for OCR — either a URL or inline base64 data. */
|
|
1029
1063
|
export type OcrDocument =
|
|
1030
|
-
| { type:
|
|
1031
|
-
| { type:
|
|
1064
|
+
| { type: "document_url"; url: string }
|
|
1065
|
+
| { type: "base64"; data: string; mediaType: string };
|
|
1032
1066
|
|
|
1033
1067
|
/** An image extracted from an OCR page. */
|
|
1034
1068
|
export interface OcrImage {
|
|
1035
1069
|
/** Unique image identifier within the document. */
|
|
1036
|
-
readonly id: string
|
|
1070
|
+
readonly id: string;
|
|
1037
1071
|
/** Base64-encoded image data (if `include_image_base64` was true). */
|
|
1038
|
-
readonly imageBase64?: string
|
|
1072
|
+
readonly imageBase64?: string;
|
|
1039
1073
|
}
|
|
1040
1074
|
|
|
1041
1075
|
/** A single page of OCR output. */
|
|
1042
1076
|
export interface OcrPage {
|
|
1043
1077
|
/** Page index (0-based). */
|
|
1044
|
-
readonly index: number
|
|
1078
|
+
readonly index: number;
|
|
1045
1079
|
/** Extracted page content as Markdown. */
|
|
1046
|
-
readonly markdown: string
|
|
1080
|
+
readonly markdown: string;
|
|
1047
1081
|
/** Embedded images extracted from the page (if `include_image_base64` was true). */
|
|
1048
|
-
readonly images?: Array<OcrImage
|
|
1082
|
+
readonly images?: Array<OcrImage>;
|
|
1049
1083
|
/** Page dimensions in pixels, if available. */
|
|
1050
|
-
readonly dimensions?: PageDimensions
|
|
1084
|
+
readonly dimensions?: PageDimensions;
|
|
1051
1085
|
}
|
|
1052
1086
|
|
|
1053
1087
|
/** An OCR request. */
|
|
1054
1088
|
export interface OcrRequest {
|
|
1055
1089
|
/** The model/provider to use (e.g. `"mistral/mistral-ocr-latest"`). */
|
|
1056
|
-
readonly model?: string
|
|
1090
|
+
readonly model?: string;
|
|
1057
1091
|
/** The document to process (URL or base64). */
|
|
1058
|
-
readonly document?: OcrDocument
|
|
1092
|
+
readonly document?: OcrDocument;
|
|
1059
1093
|
/** Specific pages to process (1-indexed). `None` means all pages. */
|
|
1060
|
-
readonly pages?: Array<number
|
|
1094
|
+
readonly pages?: Array<number>;
|
|
1061
1095
|
/** Whether to include base64-encoded images of each processed page. */
|
|
1062
|
-
readonly includeImageBase64?: boolean
|
|
1096
|
+
readonly includeImageBase64?: boolean;
|
|
1063
1097
|
}
|
|
1064
1098
|
|
|
1065
1099
|
/** An OCR response. */
|
|
1066
1100
|
export interface OcrResponse {
|
|
1067
1101
|
/** Extracted pages in order. */
|
|
1068
|
-
readonly pages: Array<OcrPage
|
|
1102
|
+
readonly pages: Array<OcrPage>;
|
|
1069
1103
|
/** Model/provider used for OCR. */
|
|
1070
|
-
readonly model: string
|
|
1104
|
+
readonly model: string;
|
|
1071
1105
|
/** Token usage, if reported by the provider. */
|
|
1072
|
-
readonly usage?: Usage
|
|
1106
|
+
readonly usage?: Usage;
|
|
1073
1107
|
}
|
|
1074
1108
|
|
|
1075
1109
|
/** Page dimensions in pixels. */
|
|
1076
1110
|
export interface PageDimensions {
|
|
1077
1111
|
/** Width in pixels. */
|
|
1078
|
-
readonly width: number
|
|
1112
|
+
readonly width: number;
|
|
1079
1113
|
/** Height in pixels. */
|
|
1080
|
-
readonly height: number
|
|
1114
|
+
readonly height: number;
|
|
1081
1115
|
}
|
|
1082
1116
|
|
|
1083
1117
|
/**
|
|
@@ -1090,9 +1124,9 @@ export interface PageDimensions {
|
|
|
1090
1124
|
*/
|
|
1091
1125
|
export interface PromptTokensDetails {
|
|
1092
1126
|
/** Cached tokens present in the prompt. Defaults to 0 when absent. */
|
|
1093
|
-
readonly cachedTokens?: number
|
|
1127
|
+
readonly cachedTokens?: number;
|
|
1094
1128
|
/** Audio input tokens present in the prompt. Defaults to 0 when absent. */
|
|
1095
|
-
readonly audioTokens?: number
|
|
1129
|
+
readonly audioTokens?: number;
|
|
1096
1130
|
}
|
|
1097
1131
|
|
|
1098
1132
|
/**
|
|
@@ -1122,19 +1156,19 @@ export interface PromptTokensDetails {
|
|
|
1122
1156
|
*/
|
|
1123
1157
|
export interface ProviderCapabilities {
|
|
1124
1158
|
/** The provider accepts image input in chat messages. */
|
|
1125
|
-
readonly vision?: boolean
|
|
1159
|
+
readonly vision?: boolean;
|
|
1126
1160
|
/** The provider supports extended-thinking / reasoning tokens. */
|
|
1127
|
-
readonly reasoning?: boolean
|
|
1161
|
+
readonly reasoning?: boolean;
|
|
1128
1162
|
/** The provider supports JSON-mode or `response_format` structured output. */
|
|
1129
|
-
readonly structuredOutput?: boolean
|
|
1163
|
+
readonly structuredOutput?: boolean;
|
|
1130
1164
|
/** The provider supports tool / function calling. */
|
|
1131
|
-
readonly functionCalling?: boolean
|
|
1165
|
+
readonly functionCalling?: boolean;
|
|
1132
1166
|
/** The provider accepts audio as input. */
|
|
1133
|
-
readonly audioIn?: boolean
|
|
1167
|
+
readonly audioIn?: boolean;
|
|
1134
1168
|
/** The provider can generate audio / TTS output. */
|
|
1135
|
-
readonly audioOut?: boolean
|
|
1169
|
+
readonly audioOut?: boolean;
|
|
1136
1170
|
/** The provider accepts video as input. */
|
|
1137
|
-
readonly videoIn?: boolean
|
|
1171
|
+
readonly videoIn?: boolean;
|
|
1138
1172
|
}
|
|
1139
1173
|
|
|
1140
1174
|
/**
|
|
@@ -1147,17 +1181,17 @@ export interface ProviderCapabilities {
|
|
|
1147
1181
|
*/
|
|
1148
1182
|
export interface ProviderConfig {
|
|
1149
1183
|
/** Provider identifier (matches the entry key in providers.json). */
|
|
1150
|
-
readonly name: string
|
|
1184
|
+
readonly name: string;
|
|
1151
1185
|
/** Human-readable provider name shown in UIs. */
|
|
1152
|
-
readonly displayName?: string
|
|
1186
|
+
readonly displayName?: string;
|
|
1153
1187
|
/** Base URL used as the default for this provider's HTTP client. */
|
|
1154
|
-
readonly baseUrl?: string
|
|
1188
|
+
readonly baseUrl?: string;
|
|
1155
1189
|
/** Authentication scheme metadata (auth type + env var holding the key). */
|
|
1156
|
-
readonly auth?: AuthConfig
|
|
1190
|
+
readonly auth?: AuthConfig;
|
|
1157
1191
|
/** Supported endpoint kinds (e.g. `chat`, `embeddings`). */
|
|
1158
|
-
readonly endpoints?: Array<string
|
|
1192
|
+
readonly endpoints?: Array<string>;
|
|
1159
1193
|
/** Model-name prefixes claimed by this provider (e.g. `["gpt-", "o1-"]`). */
|
|
1160
|
-
readonly modelPrefixes?: Array<string
|
|
1194
|
+
readonly modelPrefixes?: Array<string>;
|
|
1161
1195
|
/**
|
|
1162
1196
|
* Parameter key renaming for this provider.
|
|
1163
1197
|
*
|
|
@@ -1165,17 +1199,17 @@ export interface ProviderConfig {
|
|
|
1165
1199
|
* to the name this provider expects (e.g. `"max_tokens"`). Applied
|
|
1166
1200
|
* automatically by [`ConfigDrivenProvider::transform_request`].
|
|
1167
1201
|
*/
|
|
1168
|
-
readonly paramMappings?: Record<string, string
|
|
1202
|
+
readonly paramMappings?: Record<string, string>;
|
|
1169
1203
|
}
|
|
1170
1204
|
|
|
1171
1205
|
/** Configuration for per-model rate limits. */
|
|
1172
1206
|
export interface RateLimitConfig {
|
|
1173
1207
|
/** Maximum requests per window. `None` means unlimited. */
|
|
1174
|
-
readonly rpm?: number
|
|
1208
|
+
readonly rpm?: number;
|
|
1175
1209
|
/** Maximum tokens per window. `None` means unlimited. */
|
|
1176
|
-
readonly tpm?: number
|
|
1210
|
+
readonly tpm?: number;
|
|
1177
1211
|
/** Fixed window duration (defaults to 60 s). */
|
|
1178
|
-
readonly window?: number
|
|
1212
|
+
readonly window?: number;
|
|
1179
1213
|
}
|
|
1180
1214
|
|
|
1181
1215
|
/** Controls how much reasoning effort the model should use. */
|
|
@@ -1196,127 +1230,127 @@ export declare enum RerankDocument {
|
|
|
1196
1230
|
/** Request to rerank documents by relevance to a query. */
|
|
1197
1231
|
export interface RerankRequest {
|
|
1198
1232
|
/** Model ID (e.g., `"cohere/rerank-english-v3.0"`). */
|
|
1199
|
-
readonly model?: string
|
|
1233
|
+
readonly model?: string;
|
|
1200
1234
|
/** The search query. */
|
|
1201
|
-
readonly query?: string
|
|
1235
|
+
readonly query?: string;
|
|
1202
1236
|
/** Documents to rerank. */
|
|
1203
|
-
readonly documents?: Array<RerankDocument
|
|
1237
|
+
readonly documents?: Array<RerankDocument>;
|
|
1204
1238
|
/** Return only the top N results. Optional. */
|
|
1205
|
-
readonly topN?: number
|
|
1239
|
+
readonly topN?: number;
|
|
1206
1240
|
/** Include the document content in results. Defaults to false. */
|
|
1207
|
-
readonly returnDocuments?: boolean
|
|
1241
|
+
readonly returnDocuments?: boolean;
|
|
1208
1242
|
}
|
|
1209
1243
|
|
|
1210
1244
|
/** Response from the rerank endpoint. */
|
|
1211
1245
|
export interface RerankResponse {
|
|
1212
1246
|
/** Unique identifier for this rerank request. */
|
|
1213
|
-
readonly id?: string
|
|
1247
|
+
readonly id?: string;
|
|
1214
1248
|
/** Reranked documents in order of relevance. */
|
|
1215
|
-
readonly results: Array<RerankResult
|
|
1249
|
+
readonly results: Array<RerankResult>;
|
|
1216
1250
|
/** Optional metadata about the reranking operation. */
|
|
1217
|
-
readonly meta?: JsonValue
|
|
1251
|
+
readonly meta?: JsonValue;
|
|
1218
1252
|
}
|
|
1219
1253
|
|
|
1220
1254
|
/** A single reranked document with its relevance score. */
|
|
1221
1255
|
export interface RerankResult {
|
|
1222
1256
|
/** Original document index in the input list. */
|
|
1223
|
-
readonly index: number
|
|
1257
|
+
readonly index: number;
|
|
1224
1258
|
/** Relevance score in `[0, 1]`. Higher indicates more relevant. */
|
|
1225
|
-
readonly relevanceScore: number
|
|
1259
|
+
readonly relevanceScore: number;
|
|
1226
1260
|
/** Original document content (if `return_documents` was true). */
|
|
1227
|
-
readonly document?: RerankResultDocument
|
|
1261
|
+
readonly document?: RerankResultDocument;
|
|
1228
1262
|
}
|
|
1229
1263
|
|
|
1230
1264
|
/** The text content of a reranked document, returned when `return_documents` is true. */
|
|
1231
1265
|
export interface RerankResultDocument {
|
|
1232
1266
|
/** Document text. */
|
|
1233
|
-
readonly text: string
|
|
1267
|
+
readonly text: string;
|
|
1234
1268
|
}
|
|
1235
1269
|
|
|
1236
1270
|
/** Response format constraint. */
|
|
1237
1271
|
export type ResponseFormat =
|
|
1238
|
-
| { type:
|
|
1239
|
-
| { type:
|
|
1240
|
-
| { type:
|
|
1272
|
+
| { type: "text" }
|
|
1273
|
+
| { type: "json_object" }
|
|
1274
|
+
| { type: "json_schema"; jsonSchema: JsonSchemaFormat };
|
|
1241
1275
|
|
|
1242
1276
|
/** Response from a structured response request. */
|
|
1243
1277
|
export interface ResponseObject {
|
|
1244
1278
|
/** Unique response ID. */
|
|
1245
|
-
readonly id?: string
|
|
1279
|
+
readonly id?: string;
|
|
1246
1280
|
/** Object type (e.g., `"response"`). */
|
|
1247
|
-
readonly object?: string
|
|
1281
|
+
readonly object?: string;
|
|
1248
1282
|
/** Unix timestamp of response creation. */
|
|
1249
|
-
readonly createdAt?: number
|
|
1283
|
+
readonly createdAt?: number;
|
|
1250
1284
|
/** Model used to generate the response. */
|
|
1251
|
-
readonly model?: string
|
|
1285
|
+
readonly model?: string;
|
|
1252
1286
|
/** Status (e.g., `"succeeded"`, `"failed"`). */
|
|
1253
|
-
readonly status?: string
|
|
1287
|
+
readonly status?: string;
|
|
1254
1288
|
/** Output items from the response. */
|
|
1255
|
-
readonly output?: Array<ResponseOutputItem
|
|
1289
|
+
readonly output?: Array<ResponseOutputItem>;
|
|
1256
1290
|
/** Token usage. */
|
|
1257
|
-
readonly usage?: ResponseUsage
|
|
1291
|
+
readonly usage?: ResponseUsage;
|
|
1258
1292
|
/** Error details (if status is "failed"). */
|
|
1259
|
-
readonly error?: JsonValue
|
|
1293
|
+
readonly error?: JsonValue;
|
|
1260
1294
|
}
|
|
1261
1295
|
|
|
1262
1296
|
/** A single output item from the response. */
|
|
1263
1297
|
export interface ResponseOutputItem {
|
|
1264
1298
|
/** Output type (e.g., `"text"`, `"object"`, `"error"`). */
|
|
1265
|
-
readonly itemType?: string
|
|
1299
|
+
readonly itemType?: string;
|
|
1266
1300
|
/** Output content (flattened into the object). */
|
|
1267
|
-
readonly content?: JsonValue
|
|
1301
|
+
readonly content?: JsonValue;
|
|
1268
1302
|
}
|
|
1269
1303
|
|
|
1270
1304
|
/** A tool available for the response request. */
|
|
1271
1305
|
export interface ResponseTool {
|
|
1272
1306
|
/** Tool type (e.g., "extractor", "search"). */
|
|
1273
|
-
readonly toolType?: string
|
|
1307
|
+
readonly toolType?: string;
|
|
1274
1308
|
/** Tool configuration (flattened into the object). */
|
|
1275
|
-
readonly config?: JsonValue
|
|
1309
|
+
readonly config?: JsonValue;
|
|
1276
1310
|
}
|
|
1277
1311
|
|
|
1278
1312
|
/** Token usage for a response. */
|
|
1279
1313
|
export interface ResponseUsage {
|
|
1280
1314
|
/** Input tokens used. */
|
|
1281
|
-
readonly inputTokens?: number
|
|
1315
|
+
readonly inputTokens?: number;
|
|
1282
1316
|
/** Output tokens used. */
|
|
1283
|
-
readonly outputTokens?: number
|
|
1317
|
+
readonly outputTokens?: number;
|
|
1284
1318
|
/** Total tokens used. */
|
|
1285
|
-
readonly totalTokens?: number
|
|
1319
|
+
readonly totalTokens?: number;
|
|
1286
1320
|
}
|
|
1287
1321
|
|
|
1288
1322
|
/** A search request. */
|
|
1289
1323
|
export interface SearchRequest {
|
|
1290
1324
|
/** The model/provider to use (e.g. `"brave/web-search"`, `"tavily/search"`). */
|
|
1291
|
-
readonly model?: string
|
|
1325
|
+
readonly model?: string;
|
|
1292
1326
|
/** The search query string. */
|
|
1293
|
-
readonly query?: string
|
|
1327
|
+
readonly query?: string;
|
|
1294
1328
|
/** Maximum number of results to return. */
|
|
1295
|
-
readonly maxResults?: number
|
|
1329
|
+
readonly maxResults?: number;
|
|
1296
1330
|
/** Domain filter — restrict results to specific domains. */
|
|
1297
|
-
readonly searchDomainFilter?: Array<string
|
|
1331
|
+
readonly searchDomainFilter?: Array<string>;
|
|
1298
1332
|
/** Country code for localized results (ISO 3166-1 alpha-2, e.g., `"US"`, `"FR"`). */
|
|
1299
|
-
readonly country?: string
|
|
1333
|
+
readonly country?: string;
|
|
1300
1334
|
}
|
|
1301
1335
|
|
|
1302
1336
|
/** A search response. */
|
|
1303
1337
|
export interface SearchResponse {
|
|
1304
1338
|
/** List of search results. */
|
|
1305
|
-
readonly results: Array<SearchResult
|
|
1339
|
+
readonly results: Array<SearchResult>;
|
|
1306
1340
|
/** Model/provider that performed the search. */
|
|
1307
|
-
readonly model: string
|
|
1341
|
+
readonly model: string;
|
|
1308
1342
|
}
|
|
1309
1343
|
|
|
1310
1344
|
/** An individual search result. */
|
|
1311
1345
|
export interface SearchResult {
|
|
1312
1346
|
/** Result title. */
|
|
1313
|
-
readonly title: string
|
|
1347
|
+
readonly title: string;
|
|
1314
1348
|
/** Result URL. */
|
|
1315
|
-
readonly url: string
|
|
1349
|
+
readonly url: string;
|
|
1316
1350
|
/** Text snippet or excerpt from the page. */
|
|
1317
|
-
readonly snippet: string
|
|
1351
|
+
readonly snippet: string;
|
|
1318
1352
|
/** Publication or last-updated date, if available. */
|
|
1319
|
-
readonly date?: string
|
|
1353
|
+
readonly date?: string;
|
|
1320
1354
|
}
|
|
1321
1355
|
|
|
1322
1356
|
/**
|
|
@@ -1326,21 +1360,20 @@ export interface SearchResult {
|
|
|
1326
1360
|
* broadcast channels require `T: Clone`. The `Arc` adds only a reference-count
|
|
1327
1361
|
* bump per follower, which is negligible under the burst loads this layer targets.
|
|
1328
1362
|
*/
|
|
1329
|
-
export declare class SingleflightResult {
|
|
1330
|
-
}
|
|
1363
|
+
export declare class SingleflightResult {}
|
|
1331
1364
|
|
|
1332
1365
|
/** Name of the specific function to invoke. */
|
|
1333
1366
|
export interface SpecificFunction {
|
|
1334
1367
|
/** Function name. */
|
|
1335
|
-
readonly name?: string
|
|
1368
|
+
readonly name?: string;
|
|
1336
1369
|
}
|
|
1337
1370
|
|
|
1338
1371
|
/** Directive to call a specific tool. */
|
|
1339
1372
|
export interface SpecificToolChoice {
|
|
1340
1373
|
/** Tool type (always "function"). */
|
|
1341
|
-
readonly choiceType?: ToolType
|
|
1374
|
+
readonly choiceType?: ToolType;
|
|
1342
1375
|
/** The specific function to invoke. */
|
|
1343
|
-
readonly function?: SpecificFunction
|
|
1376
|
+
readonly function?: SpecificFunction;
|
|
1344
1377
|
}
|
|
1345
1378
|
|
|
1346
1379
|
/** Stop sequence(s) that cause the model to stop generating. */
|
|
@@ -1354,25 +1387,25 @@ export declare enum StopSequence {
|
|
|
1354
1387
|
/** A streaming choice with incremental delta. */
|
|
1355
1388
|
export interface StreamChoice {
|
|
1356
1389
|
/** Index of this choice in the choices array. */
|
|
1357
|
-
readonly index?: number
|
|
1390
|
+
readonly index?: number;
|
|
1358
1391
|
/** Incremental update to the message (content, tool calls, etc.). */
|
|
1359
|
-
readonly delta?: StreamDelta
|
|
1392
|
+
readonly delta?: StreamDelta;
|
|
1360
1393
|
/** Why the stream ended (present only in final chunk). */
|
|
1361
|
-
readonly finishReason?: FinishReason
|
|
1394
|
+
readonly finishReason?: FinishReason;
|
|
1362
1395
|
}
|
|
1363
1396
|
|
|
1364
1397
|
/** Incremental delta in a stream chunk. */
|
|
1365
1398
|
export interface StreamDelta {
|
|
1366
1399
|
/** Role (typically present only in the first chunk). */
|
|
1367
|
-
readonly role?: string
|
|
1400
|
+
readonly role?: string;
|
|
1368
1401
|
/** Partial content chunk (e.g., a few words of the response). */
|
|
1369
|
-
readonly content?: string
|
|
1402
|
+
readonly content?: string;
|
|
1370
1403
|
/** Partial tool calls being streamed. */
|
|
1371
|
-
readonly toolCalls?: Array<StreamToolCall
|
|
1404
|
+
readonly toolCalls?: Array<StreamToolCall>;
|
|
1372
1405
|
/** Deprecated legacy function_call delta; retained for API compatibility. */
|
|
1373
|
-
readonly functionCall?: StreamFunctionCall
|
|
1406
|
+
readonly functionCall?: StreamFunctionCall;
|
|
1374
1407
|
/** Partial refusal message. */
|
|
1375
|
-
readonly refusal?: string
|
|
1408
|
+
readonly refusal?: string;
|
|
1376
1409
|
}
|
|
1377
1410
|
|
|
1378
1411
|
/**
|
|
@@ -1393,45 +1426,45 @@ export declare enum StreamFormat {
|
|
|
1393
1426
|
/** Partial function call details in a stream. */
|
|
1394
1427
|
export interface StreamFunctionCall {
|
|
1395
1428
|
/** Function name (typically in the first chunk). */
|
|
1396
|
-
readonly name?: string
|
|
1429
|
+
readonly name?: string;
|
|
1397
1430
|
/** Partial JSON arguments chunk. */
|
|
1398
|
-
readonly arguments?: string
|
|
1431
|
+
readonly arguments?: string;
|
|
1399
1432
|
}
|
|
1400
1433
|
|
|
1401
1434
|
/** Options for streaming responses. */
|
|
1402
1435
|
export interface StreamOptions {
|
|
1403
1436
|
/** If true, include token usage in the final stream chunk. */
|
|
1404
|
-
readonly includeUsage?: boolean
|
|
1437
|
+
readonly includeUsage?: boolean;
|
|
1405
1438
|
}
|
|
1406
1439
|
|
|
1407
1440
|
/** A streaming tool call being built incrementally. */
|
|
1408
1441
|
export interface StreamToolCall {
|
|
1409
1442
|
/** Index of this tool call in the tool_calls array. */
|
|
1410
|
-
readonly index?: number
|
|
1443
|
+
readonly index?: number;
|
|
1411
1444
|
/** Tool call ID (typically in the first chunk for this call). */
|
|
1412
|
-
readonly id?: string
|
|
1445
|
+
readonly id?: string;
|
|
1413
1446
|
/** Tool type (typically "function"). */
|
|
1414
|
-
readonly callType?: ToolType
|
|
1447
|
+
readonly callType?: ToolType;
|
|
1415
1448
|
/** Partial function name and arguments. */
|
|
1416
|
-
readonly function?: StreamFunctionCall
|
|
1449
|
+
readonly function?: StreamFunctionCall;
|
|
1417
1450
|
}
|
|
1418
1451
|
|
|
1419
1452
|
/** System message guiding model behavior for the entire conversation. */
|
|
1420
1453
|
export interface SystemMessage {
|
|
1421
1454
|
/** Instructions or context that apply throughout the conversation. */
|
|
1422
|
-
readonly content?: string
|
|
1455
|
+
readonly content?: string;
|
|
1423
1456
|
/** Optional name for the system message source. */
|
|
1424
|
-
readonly name?: string
|
|
1457
|
+
readonly name?: string;
|
|
1425
1458
|
}
|
|
1426
1459
|
|
|
1427
1460
|
/** A tool call the model wants to execute. */
|
|
1428
1461
|
export interface ToolCall {
|
|
1429
1462
|
/** Unique ID for this call, used to reference in tool result messages. */
|
|
1430
|
-
readonly id: string
|
|
1463
|
+
readonly id: string;
|
|
1431
1464
|
/** Tool type (always "function"). */
|
|
1432
|
-
readonly callType: ToolType
|
|
1465
|
+
readonly callType: ToolType;
|
|
1433
1466
|
/** Function name and arguments. */
|
|
1434
|
-
readonly function: FunctionCall
|
|
1467
|
+
readonly function: FunctionCall;
|
|
1435
1468
|
}
|
|
1436
1469
|
|
|
1437
1470
|
/** Tool usage mode or a specific tool to call. */
|
|
@@ -1455,11 +1488,11 @@ export declare enum ToolChoiceMode {
|
|
|
1455
1488
|
/** Tool execution result returned to the model. */
|
|
1456
1489
|
export interface ToolMessage {
|
|
1457
1490
|
/** Result of the tool execution. */
|
|
1458
|
-
readonly content?: string
|
|
1491
|
+
readonly content?: string;
|
|
1459
1492
|
/** ID of the tool call this result responds to. */
|
|
1460
|
-
readonly toolCallId?: string
|
|
1493
|
+
readonly toolCallId?: string;
|
|
1461
1494
|
/** Optional tool/function name. */
|
|
1462
|
-
readonly name?: string
|
|
1495
|
+
readonly name?: string;
|
|
1463
1496
|
}
|
|
1464
1497
|
|
|
1465
1498
|
/**
|
|
@@ -1476,41 +1509,41 @@ export declare enum ToolType {
|
|
|
1476
1509
|
/** Response from a transcription request. */
|
|
1477
1510
|
export interface TranscriptionResponse {
|
|
1478
1511
|
/** The transcribed text. */
|
|
1479
|
-
readonly text?: string
|
|
1512
|
+
readonly text?: string;
|
|
1480
1513
|
/** Detected language (ISO-639-1 code). */
|
|
1481
|
-
readonly language?: string
|
|
1514
|
+
readonly language?: string;
|
|
1482
1515
|
/** Total audio duration in seconds. */
|
|
1483
|
-
readonly duration?: number
|
|
1516
|
+
readonly duration?: number;
|
|
1484
1517
|
/** Detailed segment-level transcription (if response_format is "verbose_json"). */
|
|
1485
|
-
readonly segments?: Array<TranscriptionSegment
|
|
1518
|
+
readonly segments?: Array<TranscriptionSegment>;
|
|
1486
1519
|
}
|
|
1487
1520
|
|
|
1488
1521
|
/** A segment of transcribed audio with timing information. */
|
|
1489
1522
|
export interface TranscriptionSegment {
|
|
1490
1523
|
/** Segment index (0-based). */
|
|
1491
|
-
readonly id?: number
|
|
1524
|
+
readonly id?: number;
|
|
1492
1525
|
/** Start time in seconds. */
|
|
1493
|
-
readonly start?: number
|
|
1526
|
+
readonly start?: number;
|
|
1494
1527
|
/** End time in seconds. */
|
|
1495
|
-
readonly end?: number
|
|
1528
|
+
readonly end?: number;
|
|
1496
1529
|
/** Transcribed text for this segment. */
|
|
1497
|
-
readonly text?: string
|
|
1530
|
+
readonly text?: string;
|
|
1498
1531
|
}
|
|
1499
1532
|
|
|
1500
1533
|
/** Token-usage accounting returned by the provider on each completion / embedding call. */
|
|
1501
1534
|
export interface Usage {
|
|
1502
1535
|
/** Prompt tokens used. Defaults to 0 when absent (some providers omit this). */
|
|
1503
|
-
readonly promptTokens?: number
|
|
1536
|
+
readonly promptTokens?: number;
|
|
1504
1537
|
/** Completion tokens used. Defaults to 0 when absent (e.g. embedding responses). */
|
|
1505
|
-
readonly completionTokens?: number
|
|
1538
|
+
readonly completionTokens?: number;
|
|
1506
1539
|
/** Total tokens used. Defaults to 0 when absent (some providers omit this). */
|
|
1507
|
-
readonly totalTokens?: number
|
|
1540
|
+
readonly totalTokens?: number;
|
|
1508
1541
|
/**
|
|
1509
1542
|
* Breakdown of tokens used in the prompt, including cached tokens served
|
|
1510
1543
|
* at the provider's discounted cache-read rate. Absent when the provider
|
|
1511
1544
|
* does not return prompt-token details.
|
|
1512
1545
|
*/
|
|
1513
|
-
readonly promptTokensDetails?: PromptTokensDetails
|
|
1546
|
+
readonly promptTokensDetails?: PromptTokensDetails;
|
|
1514
1547
|
}
|
|
1515
1548
|
|
|
1516
1549
|
/** User message content as either plain text or a list of multimodal parts. */
|
|
@@ -1524,9 +1557,9 @@ export declare enum UserContent {
|
|
|
1524
1557
|
/** User message in the conversation. */
|
|
1525
1558
|
export interface UserMessage {
|
|
1526
1559
|
/** Message content as plain text or array of content parts (text, images, documents, audio). */
|
|
1527
|
-
readonly content?: UserContent
|
|
1560
|
+
readonly content?: UserContent;
|
|
1528
1561
|
/** Optional name for the user. */
|
|
1529
|
-
readonly name?: string
|
|
1562
|
+
readonly name?: string;
|
|
1530
1563
|
}
|
|
1531
1564
|
|
|
1532
1565
|
/**
|
|
@@ -1537,13 +1570,13 @@ export interface UserMessage {
|
|
|
1537
1570
|
*/
|
|
1538
1571
|
export interface WaitForBatchConfig {
|
|
1539
1572
|
/** Initial interval between polls, in seconds. */
|
|
1540
|
-
readonly initialIntervalSecs?: number
|
|
1573
|
+
readonly initialIntervalSecs?: number;
|
|
1541
1574
|
/** Maximum interval between polls (backoff plateau), in seconds. */
|
|
1542
|
-
readonly maxIntervalSecs?: number
|
|
1575
|
+
readonly maxIntervalSecs?: number;
|
|
1543
1576
|
/** Exponential backoff multiplier (e.g., 1.5 increases delay by 50% each poll). */
|
|
1544
|
-
readonly backoffMultiplier?: number
|
|
1577
|
+
readonly backoffMultiplier?: number;
|
|
1545
1578
|
/** Optional timeout in seconds — polling fails if this duration is exceeded. */
|
|
1546
|
-
readonly timeoutSecs?: number
|
|
1579
|
+
readonly timeoutSecs?: number;
|
|
1547
1580
|
}
|
|
1548
1581
|
|
|
1549
1582
|
/**
|
|
@@ -1566,12 +1599,12 @@ export declare function registerCustomProvider(config: CustomProviderConfig): vo
|
|
|
1566
1599
|
export declare function unregisterCustomProvider(name: string): boolean;
|
|
1567
1600
|
|
|
1568
1601
|
export declare class ChatStreamIterator {
|
|
1569
|
-
next(value?: undefined): Promise<IteratorResult<ChatCompletionChunk, void
|
|
1570
|
-
[Symbol.asyncIterator](): AsyncGenerator<ChatCompletionChunk, void, undefined
|
|
1602
|
+
next(value?: undefined): Promise<IteratorResult<ChatCompletionChunk, void>>;
|
|
1603
|
+
[Symbol.asyncIterator](): AsyncGenerator<ChatCompletionChunk, void, undefined>;
|
|
1571
1604
|
}
|
|
1572
1605
|
|
|
1573
1606
|
export declare class LiterLlmErrorInfo {
|
|
1574
|
-
statusCode(): number
|
|
1575
|
-
isTransient(): boolean
|
|
1576
|
-
errorType(): string
|
|
1607
|
+
statusCode(): number;
|
|
1608
|
+
isTransient(): boolean;
|
|
1609
|
+
errorType(): string;
|
|
1577
1610
|
}
|