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