@effect/ai-openrouter 4.0.0-beta.8 → 4.0.0-beta.81
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/dist/Generated.d.ts +1 -1
- package/dist/Generated.js +1 -1
- package/dist/OpenRouterClient.d.ts +86 -20
- package/dist/OpenRouterClient.d.ts.map +1 -1
- package/dist/OpenRouterClient.js +62 -12
- package/dist/OpenRouterClient.js.map +1 -1
- package/dist/OpenRouterConfig.d.ts +95 -10
- package/dist/OpenRouterConfig.d.ts.map +1 -1
- package/dist/OpenRouterConfig.js +45 -7
- package/dist/OpenRouterConfig.js.map +1 -1
- package/dist/OpenRouterError.d.ts +166 -35
- package/dist/OpenRouterError.d.ts.map +1 -1
- package/dist/OpenRouterError.js +1 -1
- package/dist/OpenRouterLanguageModel.d.ts +361 -21
- package/dist/OpenRouterLanguageModel.d.ts.map +1 -1
- package/dist/OpenRouterLanguageModel.js +92 -14
- package/dist/OpenRouterLanguageModel.js.map +1 -1
- package/dist/index.d.ts +6 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -11
- package/dist/index.js.map +1 -1
- package/dist/internal/errors.js +4 -4
- package/dist/internal/errors.js.map +1 -1
- package/dist/internal/utilities.js +0 -1
- package/dist/internal/utilities.js.map +1 -1
- package/package.json +3 -3
- package/src/Generated.ts +1 -1
- package/src/OpenRouterClient.ts +87 -21
- package/src/OpenRouterConfig.ts +140 -13
- package/src/OpenRouterError.ts +168 -35
- package/src/OpenRouterLanguageModel.ts +397 -23
- package/src/index.ts +6 -11
- package/src/internal/errors.ts +6 -4
- package/src/internal/utilities.ts +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
1
2
|
import * as Effect from "effect/Effect";
|
|
2
3
|
import * as Layer from "effect/Layer";
|
|
3
|
-
import * as ServiceMap from "effect/ServiceMap";
|
|
4
4
|
import * as LanguageModel from "effect/unstable/ai/LanguageModel";
|
|
5
5
|
import * as AiModel from "effect/unstable/ai/Model";
|
|
6
6
|
import type * as Generated from "./Generated.ts";
|
|
7
7
|
import { OpenRouterClient } from "./OpenRouterClient.ts";
|
|
8
|
-
declare const Config_base:
|
|
8
|
+
declare const Config_base: Context.ServiceClass<Config, "@effect/ai-openrouter/OpenRouterLanguageModel/Config", {
|
|
9
9
|
readonly metadata?: {};
|
|
10
10
|
readonly max_tokens?: number | null;
|
|
11
11
|
readonly model?: string;
|
|
@@ -26,10 +26,6 @@ declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-openroute
|
|
|
26
26
|
readonly summary?: "auto" | "concise" | "detailed" | null;
|
|
27
27
|
};
|
|
28
28
|
readonly provider?: {
|
|
29
|
-
readonly sort?: "price" | "throughput" | "latency" | {
|
|
30
|
-
readonly by?: "price" | "throughput" | "latency" | null;
|
|
31
|
-
readonly partition?: "none" | "model" | null;
|
|
32
|
-
} | null;
|
|
33
29
|
readonly allow_fallbacks?: boolean | null;
|
|
34
30
|
readonly require_parameters?: boolean | null;
|
|
35
31
|
readonly data_collection?: "deny" | "allow" | null;
|
|
@@ -39,12 +35,16 @@ declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-openroute
|
|
|
39
35
|
readonly only?: readonly string[] | null;
|
|
40
36
|
readonly ignore?: readonly string[] | null;
|
|
41
37
|
readonly quantizations?: readonly ("int4" | "int8" | "fp4" | "fp6" | "fp8" | "fp16" | "bf16" | "fp32" | "unknown")[] | null;
|
|
38
|
+
readonly sort?: "price" | "throughput" | "latency" | {
|
|
39
|
+
readonly by?: "price" | "throughput" | "latency" | null;
|
|
40
|
+
readonly partition?: "none" | "model" | null;
|
|
41
|
+
} | null;
|
|
42
42
|
readonly max_price?: {
|
|
43
|
-
readonly image?: unknown;
|
|
44
|
-
readonly request?: unknown;
|
|
45
|
-
readonly audio?: unknown;
|
|
46
43
|
readonly prompt?: unknown;
|
|
47
44
|
readonly completion?: unknown;
|
|
45
|
+
readonly image?: unknown;
|
|
46
|
+
readonly audio?: unknown;
|
|
47
|
+
readonly request?: unknown;
|
|
48
48
|
};
|
|
49
49
|
readonly preferred_min_throughput?: number | {
|
|
50
50
|
readonly p50?: number | null;
|
|
@@ -68,9 +68,9 @@ declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-openroute
|
|
|
68
68
|
} | {
|
|
69
69
|
readonly id: "web";
|
|
70
70
|
readonly enabled?: boolean;
|
|
71
|
-
readonly engine?: "native" | "exa";
|
|
72
71
|
readonly max_results?: number;
|
|
73
72
|
readonly search_prompt?: string;
|
|
73
|
+
readonly engine?: "native" | "exa";
|
|
74
74
|
} | {
|
|
75
75
|
readonly id: "file-parser";
|
|
76
76
|
readonly enabled?: boolean;
|
|
@@ -99,27 +99,54 @@ declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-openroute
|
|
|
99
99
|
readonly strictJsonSchema?: boolean | undefined | undefined;
|
|
100
100
|
}>;
|
|
101
101
|
/**
|
|
102
|
-
*
|
|
102
|
+
* Context service for OpenRouter language model configuration.
|
|
103
|
+
*
|
|
104
|
+
* **When to use**
|
|
105
|
+
*
|
|
106
|
+
* Use to provide scoped OpenRouter chat completion defaults or per-operation
|
|
107
|
+
* overrides for an OpenRouter language model service.
|
|
108
|
+
*
|
|
109
|
+
* @see {@link withConfigOverride} for scoping language model request overrides
|
|
103
110
|
*
|
|
104
|
-
* @since 1.0.0
|
|
105
111
|
* @category services
|
|
112
|
+
* @since 4.0.0
|
|
106
113
|
*/
|
|
107
114
|
export declare class Config extends Config_base {
|
|
108
115
|
}
|
|
109
116
|
/**
|
|
110
|
-
*
|
|
117
|
+
* OpenRouter assistant reasoning detail blocks preserved for multi-turn
|
|
118
|
+
* conversations.
|
|
119
|
+
*
|
|
111
120
|
* @category models
|
|
121
|
+
* @since 4.0.0
|
|
112
122
|
*/
|
|
113
123
|
export type ReasoningDetails = Exclude<typeof Generated.AssistantMessage.Encoded["reasoning_details"], undefined>;
|
|
114
124
|
/**
|
|
115
|
-
*
|
|
125
|
+
* File annotations emitted on OpenRouter assistant messages and exposed in
|
|
126
|
+
* finish metadata.
|
|
127
|
+
*
|
|
116
128
|
* @category models
|
|
129
|
+
* @since 4.0.0
|
|
117
130
|
*/
|
|
118
131
|
export type FileAnnotation = Extract<NonNullable<typeof Generated.AssistantMessage.fields.annotations.Type>[number], {
|
|
119
132
|
type: "file";
|
|
120
133
|
}>;
|
|
121
134
|
declare module "effect/unstable/ai/Prompt" {
|
|
135
|
+
/**
|
|
136
|
+
* OpenRouter-specific options for system messages.
|
|
137
|
+
*
|
|
138
|
+
* **Details**
|
|
139
|
+
*
|
|
140
|
+
* These options are used when translating system instructions into
|
|
141
|
+
* OpenRouter chat messages.
|
|
142
|
+
*
|
|
143
|
+
* @category request
|
|
144
|
+
* @since 4.0.0
|
|
145
|
+
*/
|
|
122
146
|
interface SystemMessageOptions extends ProviderOptions {
|
|
147
|
+
/**
|
|
148
|
+
* Provider-specific options sent to OpenRouter for the system message.
|
|
149
|
+
*/
|
|
123
150
|
readonly openrouter?: {
|
|
124
151
|
/**
|
|
125
152
|
* A breakpoint which marks the end of reusable content eligible for caching.
|
|
@@ -127,7 +154,21 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
127
154
|
readonly cacheControl?: typeof Generated.ChatMessageContentItemCacheControl.Encoded | null;
|
|
128
155
|
} | null;
|
|
129
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* OpenRouter-specific options for user messages.
|
|
159
|
+
*
|
|
160
|
+
* **Details**
|
|
161
|
+
*
|
|
162
|
+
* These options are used when translating user content into OpenRouter chat
|
|
163
|
+
* messages.
|
|
164
|
+
*
|
|
165
|
+
* @category request
|
|
166
|
+
* @since 4.0.0
|
|
167
|
+
*/
|
|
130
168
|
interface UserMessageOptions extends ProviderOptions {
|
|
169
|
+
/**
|
|
170
|
+
* Provider-specific options sent to OpenRouter for the user message.
|
|
171
|
+
*/
|
|
131
172
|
readonly openrouter?: {
|
|
132
173
|
/**
|
|
133
174
|
* A breakpoint which marks the end of reusable content eligible for caching.
|
|
@@ -135,7 +176,21 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
135
176
|
readonly cacheControl?: typeof Generated.ChatMessageContentItemCacheControl.Encoded | null;
|
|
136
177
|
} | null;
|
|
137
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* OpenRouter-specific options for assistant messages.
|
|
181
|
+
*
|
|
182
|
+
* **Details**
|
|
183
|
+
*
|
|
184
|
+
* Preserves reasoning metadata when assistant messages are replayed in later
|
|
185
|
+
* OpenRouter requests.
|
|
186
|
+
*
|
|
187
|
+
* @category request
|
|
188
|
+
* @since 4.0.0
|
|
189
|
+
*/
|
|
138
190
|
interface AssistantMessageOptions extends ProviderOptions {
|
|
191
|
+
/**
|
|
192
|
+
* Provider-specific options sent to OpenRouter for the assistant message.
|
|
193
|
+
*/
|
|
139
194
|
readonly openrouter?: {
|
|
140
195
|
/**
|
|
141
196
|
* A breakpoint which marks the end of reusable content eligible for caching.
|
|
@@ -147,7 +202,21 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
147
202
|
readonly reasoningDetails?: ReasoningDetails | null;
|
|
148
203
|
} | null;
|
|
149
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* OpenRouter-specific options for tool messages.
|
|
207
|
+
*
|
|
208
|
+
* **Details**
|
|
209
|
+
*
|
|
210
|
+
* These options are used when converting tool results into OpenRouter chat
|
|
211
|
+
* messages.
|
|
212
|
+
*
|
|
213
|
+
* @category request
|
|
214
|
+
* @since 4.0.0
|
|
215
|
+
*/
|
|
150
216
|
interface ToolMessageOptions extends ProviderOptions {
|
|
217
|
+
/**
|
|
218
|
+
* Provider-specific options sent to OpenRouter for the tool message.
|
|
219
|
+
*/
|
|
151
220
|
readonly openrouter?: {
|
|
152
221
|
/**
|
|
153
222
|
* A breakpoint which marks the end of reusable content eligible for caching.
|
|
@@ -155,7 +224,20 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
155
224
|
readonly cacheControl?: typeof Generated.ChatMessageContentItemCacheControl.Encoded | null;
|
|
156
225
|
} | null;
|
|
157
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* OpenRouter-specific options for text prompt parts.
|
|
229
|
+
*
|
|
230
|
+
* **When to use**
|
|
231
|
+
*
|
|
232
|
+
* Use when you use these options to control how text content is sent to OpenRouter.
|
|
233
|
+
*
|
|
234
|
+
* @category request
|
|
235
|
+
* @since 4.0.0
|
|
236
|
+
*/
|
|
158
237
|
interface TextPartOptions extends ProviderOptions {
|
|
238
|
+
/**
|
|
239
|
+
* Provider-specific options sent to OpenRouter for the text part.
|
|
240
|
+
*/
|
|
159
241
|
readonly openrouter?: {
|
|
160
242
|
/**
|
|
161
243
|
* A breakpoint which marks the end of reusable content eligible for caching.
|
|
@@ -163,7 +245,21 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
163
245
|
readonly cacheControl?: typeof Generated.ChatMessageContentItemCacheControl.Encoded | null;
|
|
164
246
|
} | null;
|
|
165
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* OpenRouter-specific options for reasoning prompt parts.
|
|
250
|
+
*
|
|
251
|
+
* **Details**
|
|
252
|
+
*
|
|
253
|
+
* Preserves provider reasoning blocks so reasoning-aware conversations can
|
|
254
|
+
* continue across OpenRouter requests.
|
|
255
|
+
*
|
|
256
|
+
* @category request
|
|
257
|
+
* @since 4.0.0
|
|
258
|
+
*/
|
|
166
259
|
interface ReasoningPartOptions extends ProviderOptions {
|
|
260
|
+
/**
|
|
261
|
+
* Provider-specific options sent to OpenRouter for the reasoning part.
|
|
262
|
+
*/
|
|
167
263
|
readonly openrouter?: {
|
|
168
264
|
/**
|
|
169
265
|
* A breakpoint which marks the end of reusable content eligible for caching.
|
|
@@ -175,7 +271,20 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
175
271
|
readonly reasoningDetails?: ReasoningDetails | null;
|
|
176
272
|
} | null;
|
|
177
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* OpenRouter-specific options for file prompt parts.
|
|
276
|
+
*
|
|
277
|
+
* **Details**
|
|
278
|
+
*
|
|
279
|
+
* Controls file naming and prompt caching for files sent to OpenRouter.
|
|
280
|
+
*
|
|
281
|
+
* @category request
|
|
282
|
+
* @since 4.0.0
|
|
283
|
+
*/
|
|
178
284
|
interface FilePartOptions extends ProviderOptions {
|
|
285
|
+
/**
|
|
286
|
+
* Provider-specific options sent to OpenRouter for the file part.
|
|
287
|
+
*/
|
|
179
288
|
readonly openrouter?: {
|
|
180
289
|
/**
|
|
181
290
|
* The name to give to the file. Will be prioritized over the file name
|
|
@@ -188,7 +297,21 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
188
297
|
readonly cacheControl?: typeof Generated.ChatMessageContentItemCacheControl.Encoded | null;
|
|
189
298
|
} | null;
|
|
190
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* OpenRouter-specific options for tool call prompt parts.
|
|
302
|
+
*
|
|
303
|
+
* **Details**
|
|
304
|
+
*
|
|
305
|
+
* Preserves reasoning details associated with tool calls when a conversation
|
|
306
|
+
* is sent back to OpenRouter.
|
|
307
|
+
*
|
|
308
|
+
* @category request
|
|
309
|
+
* @since 4.0.0
|
|
310
|
+
*/
|
|
191
311
|
interface ToolCallPartOptions extends ProviderOptions {
|
|
312
|
+
/**
|
|
313
|
+
* Provider-specific options sent to OpenRouter for the tool call part.
|
|
314
|
+
*/
|
|
192
315
|
readonly openrouter?: {
|
|
193
316
|
/**
|
|
194
317
|
* Reasoning details associated with the tool call part.
|
|
@@ -196,7 +319,20 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
196
319
|
readonly reasoningDetails?: ReasoningDetails | null;
|
|
197
320
|
} | null;
|
|
198
321
|
}
|
|
322
|
+
/**
|
|
323
|
+
* OpenRouter-specific options for tool result prompt parts.
|
|
324
|
+
*
|
|
325
|
+
* **Details**
|
|
326
|
+
*
|
|
327
|
+
* Controls prompt caching for tool results sent to OpenRouter.
|
|
328
|
+
*
|
|
329
|
+
* @category request
|
|
330
|
+
* @since 4.0.0
|
|
331
|
+
*/
|
|
199
332
|
interface ToolResultPartOptions extends ProviderOptions {
|
|
333
|
+
/**
|
|
334
|
+
* Provider-specific options sent to OpenRouter for the tool result part.
|
|
335
|
+
*/
|
|
200
336
|
readonly openrouter?: {
|
|
201
337
|
/**
|
|
202
338
|
* A breakpoint which marks the end of reusable content eligible for caching.
|
|
@@ -206,52 +342,205 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
206
342
|
}
|
|
207
343
|
}
|
|
208
344
|
declare module "effect/unstable/ai/Response" {
|
|
345
|
+
/**
|
|
346
|
+
* OpenRouter metadata attached to completed reasoning response parts.
|
|
347
|
+
*
|
|
348
|
+
* **Details**
|
|
349
|
+
*
|
|
350
|
+
* Preserves provider reasoning details that can be sent back in later turns.
|
|
351
|
+
*
|
|
352
|
+
* @category response
|
|
353
|
+
* @since 4.0.0
|
|
354
|
+
*/
|
|
209
355
|
interface ReasoningPartMetadata extends ProviderMetadata {
|
|
356
|
+
/**
|
|
357
|
+
* Provider-specific metadata returned for the reasoning part.
|
|
358
|
+
*/
|
|
210
359
|
readonly openrouter?: {
|
|
360
|
+
/**
|
|
361
|
+
* Reasoning details emitted by the underlying provider for this part.
|
|
362
|
+
*/
|
|
211
363
|
readonly reasoningDetails?: ReasoningDetails | null;
|
|
212
364
|
} | null;
|
|
213
365
|
}
|
|
366
|
+
/**
|
|
367
|
+
* OpenRouter metadata emitted when a streamed reasoning part starts.
|
|
368
|
+
*
|
|
369
|
+
* **Details**
|
|
370
|
+
*
|
|
371
|
+
* Carries the first reasoning detail chunk when OpenRouter exposes one.
|
|
372
|
+
*
|
|
373
|
+
* @category response
|
|
374
|
+
* @since 4.0.0
|
|
375
|
+
*/
|
|
214
376
|
interface ReasoningStartPartMetadata extends ProviderMetadata {
|
|
377
|
+
/**
|
|
378
|
+
* Provider-specific metadata returned for the streamed reasoning start.
|
|
379
|
+
*/
|
|
215
380
|
readonly openrouter?: {
|
|
381
|
+
/**
|
|
382
|
+
* Reasoning details emitted by the underlying provider for this part.
|
|
383
|
+
*/
|
|
216
384
|
readonly reasoningDetails?: ReasoningDetails | null;
|
|
217
385
|
} | null;
|
|
218
386
|
}
|
|
387
|
+
/**
|
|
388
|
+
* OpenRouter metadata emitted for streamed reasoning deltas.
|
|
389
|
+
*
|
|
390
|
+
* **Details**
|
|
391
|
+
*
|
|
392
|
+
* Carries provider reasoning detail chunks as they arrive from OpenRouter.
|
|
393
|
+
*
|
|
394
|
+
* @category response
|
|
395
|
+
* @since 4.0.0
|
|
396
|
+
*/
|
|
219
397
|
interface ReasoningDeltaPartMetadata extends ProviderMetadata {
|
|
398
|
+
/**
|
|
399
|
+
* Provider-specific metadata returned for the streamed reasoning delta.
|
|
400
|
+
*/
|
|
220
401
|
readonly openrouter?: {
|
|
402
|
+
/**
|
|
403
|
+
* Reasoning details emitted by the underlying provider for this delta.
|
|
404
|
+
*/
|
|
221
405
|
readonly reasoningDetails?: ReasoningDetails | null;
|
|
222
406
|
} | null;
|
|
223
407
|
}
|
|
408
|
+
/**
|
|
409
|
+
* OpenRouter metadata attached to tool-call response parts.
|
|
410
|
+
*
|
|
411
|
+
* **Details**
|
|
412
|
+
*
|
|
413
|
+
* Associates tool calls with provider reasoning details when the model emits
|
|
414
|
+
* reasoning and tool calls together.
|
|
415
|
+
*
|
|
416
|
+
* @category response
|
|
417
|
+
* @since 4.0.0
|
|
418
|
+
*/
|
|
224
419
|
interface ToolCallPartMetadata extends ProviderMetadata {
|
|
420
|
+
/**
|
|
421
|
+
* Provider-specific metadata returned for the tool call.
|
|
422
|
+
*/
|
|
225
423
|
readonly openrouter?: {
|
|
424
|
+
/**
|
|
425
|
+
* Reasoning details associated with this tool call.
|
|
426
|
+
*/
|
|
226
427
|
readonly reasoningDetails?: ReasoningDetails | null;
|
|
227
428
|
} | null;
|
|
228
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* OpenRouter metadata attached to URL source citations.
|
|
432
|
+
*
|
|
433
|
+
* **Details**
|
|
434
|
+
*
|
|
435
|
+
* Includes citation text and offsets returned by providers that support URL
|
|
436
|
+
* annotations.
|
|
437
|
+
*
|
|
438
|
+
* @category response
|
|
439
|
+
* @since 4.0.0
|
|
440
|
+
*/
|
|
229
441
|
interface UrlSourcePartMetadata extends ProviderMetadata {
|
|
442
|
+
/**
|
|
443
|
+
* Provider-specific citation metadata returned for the URL source.
|
|
444
|
+
*/
|
|
230
445
|
readonly openrouter?: {
|
|
446
|
+
/**
|
|
447
|
+
* The cited source content returned by the provider.
|
|
448
|
+
*/
|
|
231
449
|
readonly content?: string | null;
|
|
450
|
+
/**
|
|
451
|
+
* The zero-based start index of the citation in the generated text.
|
|
452
|
+
*/
|
|
232
453
|
readonly startIndex?: number | null;
|
|
454
|
+
/**
|
|
455
|
+
* The zero-based end index of the citation in the generated text.
|
|
456
|
+
*/
|
|
233
457
|
readonly endIndex?: number | null;
|
|
234
458
|
} | null;
|
|
235
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* OpenRouter metadata attached to finish response parts.
|
|
462
|
+
*
|
|
463
|
+
* **Details**
|
|
464
|
+
*
|
|
465
|
+
* Exposes provider response details that are not represented by the common
|
|
466
|
+
* Effect AI finish part fields.
|
|
467
|
+
*
|
|
468
|
+
* @category response
|
|
469
|
+
* @since 4.0.0
|
|
470
|
+
*/
|
|
236
471
|
interface FinishPartMetadata extends ProviderMetadata {
|
|
472
|
+
/**
|
|
473
|
+
* Provider-specific metadata returned when the OpenRouter response finishes.
|
|
474
|
+
*/
|
|
237
475
|
readonly openrouter?: {
|
|
476
|
+
/**
|
|
477
|
+
* Provider fingerprint for the backend configuration that served the request.
|
|
478
|
+
*/
|
|
238
479
|
readonly systemFingerprint?: string | null;
|
|
480
|
+
/**
|
|
481
|
+
* Raw token usage reported by OpenRouter.
|
|
482
|
+
*/
|
|
239
483
|
readonly usage?: typeof Generated.ChatGenerationTokenUsage.Encoded | null;
|
|
484
|
+
/**
|
|
485
|
+
* File annotations returned by the provider.
|
|
486
|
+
*/
|
|
240
487
|
readonly annotations?: ReadonlyArray<FileAnnotation> | null;
|
|
488
|
+
/**
|
|
489
|
+
* The OpenRouter provider that served the request, when reported.
|
|
490
|
+
*/
|
|
241
491
|
readonly provider?: string | null;
|
|
242
492
|
} | null;
|
|
243
493
|
}
|
|
244
494
|
}
|
|
245
495
|
/**
|
|
246
|
-
*
|
|
496
|
+
* Creates an OpenRouter model descriptor that can be provided with
|
|
497
|
+
* `Effect.provide`.
|
|
498
|
+
*
|
|
499
|
+
* **When to use**
|
|
500
|
+
*
|
|
501
|
+
* Use when you want an OpenRouter language model value that carries provider
|
|
502
|
+
* and model metadata and can be supplied directly to an Effect program.
|
|
503
|
+
*
|
|
504
|
+
* **Details**
|
|
505
|
+
*
|
|
506
|
+
* The returned model requires `OpenRouterClient` and provides
|
|
507
|
+
* `LanguageModel.LanguageModel`.
|
|
508
|
+
*
|
|
509
|
+
* @see {@link layer} for creating a `LanguageModel.LanguageModel` layer directly
|
|
510
|
+
* @see {@link make} for constructing the language model service effectfully
|
|
511
|
+
* @see {@link withConfigOverride} for scoping OpenRouter request overrides
|
|
512
|
+
*
|
|
247
513
|
* @category constructors
|
|
514
|
+
* @since 4.0.0
|
|
248
515
|
*/
|
|
249
516
|
export declare const model: (model: string, config?: Omit<typeof Config.Service, "model">) => AiModel.Model<"openai", LanguageModel.LanguageModel, OpenRouterClient>;
|
|
250
517
|
/**
|
|
251
|
-
* Creates an OpenRouter
|
|
518
|
+
* Creates an OpenRouter `LanguageModel` service from a model identifier and
|
|
519
|
+
* optional request defaults.
|
|
520
|
+
*
|
|
521
|
+
* **When to use**
|
|
522
|
+
*
|
|
523
|
+
* Use when you need to construct a `LanguageModel.Service` value backed by
|
|
524
|
+
* `OpenRouterClient` inside an Effect.
|
|
525
|
+
*
|
|
526
|
+
* **Details**
|
|
527
|
+
*
|
|
528
|
+
* The returned effect requires `OpenRouterClient`. Request defaults from the
|
|
529
|
+
* `config` option are merged with any `Config` service in the context, with
|
|
530
|
+
* context values taking precedence. The service supports both `generateText`
|
|
531
|
+
* and `streamText`.
|
|
532
|
+
*
|
|
533
|
+
* **Gotchas**
|
|
534
|
+
*
|
|
535
|
+
* Provider-defined tools are not supported by this provider integration;
|
|
536
|
+
* requests that include them fail with an `InvalidUserInputError`.
|
|
537
|
+
*
|
|
538
|
+
* @see {@link layer} for providing the service as a `Layer`
|
|
539
|
+
* @see {@link model} for creating a model descriptor for `Effect.provide`
|
|
540
|
+
* @see {@link withConfigOverride} for scoping request defaults around operations
|
|
252
541
|
*
|
|
253
|
-
* @since 1.0.0
|
|
254
542
|
* @category constructors
|
|
543
|
+
* @since 4.0.0
|
|
255
544
|
*/
|
|
256
545
|
export declare const make: (args_0: {
|
|
257
546
|
readonly model: string;
|
|
@@ -260,8 +549,17 @@ export declare const make: (args_0: {
|
|
|
260
549
|
/**
|
|
261
550
|
* Creates a layer for the OpenRouter language model.
|
|
262
551
|
*
|
|
263
|
-
*
|
|
552
|
+
* **When to use**
|
|
553
|
+
*
|
|
554
|
+
* Use when composing application layers and you want OpenRouter to satisfy
|
|
555
|
+
* `LanguageModel.LanguageModel` while supplying `OpenRouterClient` from another
|
|
556
|
+
* layer.
|
|
557
|
+
*
|
|
558
|
+
* @see {@link make} for constructing the language model service effectfully
|
|
559
|
+
* @see {@link model} for creating a model descriptor for `Effect.provide`
|
|
560
|
+
*
|
|
264
561
|
* @category layers
|
|
562
|
+
* @since 4.0.0
|
|
265
563
|
*/
|
|
266
564
|
export declare const layer: (options: {
|
|
267
565
|
readonly model: string;
|
|
@@ -270,22 +568,64 @@ export declare const layer: (options: {
|
|
|
270
568
|
/**
|
|
271
569
|
* Provides config overrides for OpenRouter language model operations.
|
|
272
570
|
*
|
|
273
|
-
*
|
|
571
|
+
* **When to use**
|
|
572
|
+
*
|
|
573
|
+
* Use to apply OpenRouter request configuration to one effect without changing
|
|
574
|
+
* the model's default configuration.
|
|
575
|
+
*
|
|
576
|
+
* **Details**
|
|
577
|
+
*
|
|
578
|
+
* The overrides are merged with any existing `Config` service for the duration
|
|
579
|
+
* of the supplied effect. Fields in `overrides` take precedence over existing
|
|
580
|
+
* config, and the helper supports both pipe form and
|
|
581
|
+
* `withConfigOverride(effect, overrides)`.
|
|
582
|
+
*
|
|
583
|
+
* @see {@link Config} for available OpenRouter request configuration fields
|
|
584
|
+
*
|
|
274
585
|
* @category configuration
|
|
586
|
+
* @since 4.0.0
|
|
275
587
|
*/
|
|
276
588
|
export declare const withConfigOverride: {
|
|
277
589
|
/**
|
|
278
590
|
* Provides config overrides for OpenRouter language model operations.
|
|
279
591
|
*
|
|
280
|
-
*
|
|
592
|
+
* **When to use**
|
|
593
|
+
*
|
|
594
|
+
* Use to apply OpenRouter request configuration to one effect without changing
|
|
595
|
+
* the model's default configuration.
|
|
596
|
+
*
|
|
597
|
+
* **Details**
|
|
598
|
+
*
|
|
599
|
+
* The overrides are merged with any existing `Config` service for the duration
|
|
600
|
+
* of the supplied effect. Fields in `overrides` take precedence over existing
|
|
601
|
+
* config, and the helper supports both pipe form and
|
|
602
|
+
* `withConfigOverride(effect, overrides)`.
|
|
603
|
+
*
|
|
604
|
+
* @see {@link Config} for available OpenRouter request configuration fields
|
|
605
|
+
*
|
|
281
606
|
* @category configuration
|
|
607
|
+
* @since 4.0.0
|
|
282
608
|
*/
|
|
283
609
|
(overrides: typeof Config.Service): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Config>>;
|
|
284
610
|
/**
|
|
285
611
|
* Provides config overrides for OpenRouter language model operations.
|
|
286
612
|
*
|
|
287
|
-
*
|
|
613
|
+
* **When to use**
|
|
614
|
+
*
|
|
615
|
+
* Use to apply OpenRouter request configuration to one effect without changing
|
|
616
|
+
* the model's default configuration.
|
|
617
|
+
*
|
|
618
|
+
* **Details**
|
|
619
|
+
*
|
|
620
|
+
* The overrides are merged with any existing `Config` service for the duration
|
|
621
|
+
* of the supplied effect. Fields in `overrides` take precedence over existing
|
|
622
|
+
* config, and the helper supports both pipe form and
|
|
623
|
+
* `withConfigOverride(effect, overrides)`.
|
|
624
|
+
*
|
|
625
|
+
* @see {@link Config} for available OpenRouter request configuration fields
|
|
626
|
+
*
|
|
288
627
|
* @category configuration
|
|
628
|
+
* @since 4.0.0
|
|
289
629
|
*/
|
|
290
630
|
<A, E, R>(self: Effect.Effect<A, E, R>, overrides: typeof Config.Service): Effect.Effect<A, E, Exclude<R, Config>>;
|
|
291
631
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenRouterLanguageModel.d.ts","sourceRoot":"","sources":["../src/OpenRouterLanguageModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OpenRouterLanguageModel.d.ts","sourceRoot":"","sources":["../src/OpenRouterLanguageModel.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAYrC,OAAO,KAAK,aAAa,MAAM,kCAAkC,CAAA;AACjE,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AAQnD,OAAO,KAAK,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAEhD,OAAO,EAAuC,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAmC3D,OAAO,GAAG,SAAS;;AA7BrD;;;;;;;;;;;;GAYG;AACH,qBAAa,MAAO,SAAQ,WAmB+B;CAAG;AAM9D;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,SAAS,CAAC,CAAA;AAEjH;;;;;;GAMG;AACH,MAAM,MAAM,cA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