@effect/ai-openrouter 4.0.0-beta.7 → 4.0.0-beta.71
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 +171 -92
- package/dist/Generated.d.ts.map +1 -1
- package/dist/Generated.js +60 -31
- package/dist/Generated.js.map +1 -1
- package/dist/OpenRouterClient.d.ts +101 -17
- package/dist/OpenRouterClient.d.ts.map +1 -1
- package/dist/OpenRouterClient.js +62 -11
- package/dist/OpenRouterClient.js.map +1 -1
- package/dist/OpenRouterConfig.d.ts +121 -10
- package/dist/OpenRouterConfig.d.ts.map +1 -1
- package/dist/OpenRouterConfig.js +71 -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 +368 -20
- package/dist/OpenRouterLanguageModel.d.ts.map +1 -1
- package/dist/OpenRouterLanguageModel.js +344 -241
- 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 +123 -53
- package/src/OpenRouterClient.ts +102 -18
- package/src/OpenRouterConfig.ts +166 -13
- package/src/OpenRouterError.ts +168 -35
- package/src/OpenRouterLanguageModel.ts +644 -246
- 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;
|
|
@@ -20,15 +20,12 @@ declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-openroute
|
|
|
20
20
|
readonly top_logprobs?: number | null;
|
|
21
21
|
readonly seed?: number | null;
|
|
22
22
|
readonly stop?: string | readonly string[] | null;
|
|
23
|
+
readonly parallel_tool_calls?: boolean | null;
|
|
23
24
|
readonly reasoning?: {
|
|
24
25
|
readonly effort?: "high" | "low" | "medium" | "none" | "xhigh" | "minimal" | null;
|
|
25
26
|
readonly summary?: "auto" | "concise" | "detailed" | null;
|
|
26
27
|
};
|
|
27
28
|
readonly provider?: {
|
|
28
|
-
readonly sort?: "price" | "throughput" | "latency" | {
|
|
29
|
-
readonly by?: "price" | "throughput" | "latency" | null;
|
|
30
|
-
readonly partition?: "none" | "model" | null;
|
|
31
|
-
} | null;
|
|
32
29
|
readonly allow_fallbacks?: boolean | null;
|
|
33
30
|
readonly require_parameters?: boolean | null;
|
|
34
31
|
readonly data_collection?: "deny" | "allow" | null;
|
|
@@ -38,12 +35,16 @@ declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-openroute
|
|
|
38
35
|
readonly only?: readonly string[] | null;
|
|
39
36
|
readonly ignore?: readonly string[] | null;
|
|
40
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;
|
|
41
42
|
readonly max_price?: {
|
|
42
|
-
readonly image?: unknown;
|
|
43
|
-
readonly request?: unknown;
|
|
44
|
-
readonly audio?: unknown;
|
|
45
43
|
readonly prompt?: unknown;
|
|
46
44
|
readonly completion?: unknown;
|
|
45
|
+
readonly image?: unknown;
|
|
46
|
+
readonly audio?: unknown;
|
|
47
|
+
readonly request?: unknown;
|
|
47
48
|
};
|
|
48
49
|
readonly preferred_min_throughput?: number | {
|
|
49
50
|
readonly p50?: number | null;
|
|
@@ -67,9 +68,9 @@ declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-openroute
|
|
|
67
68
|
} | {
|
|
68
69
|
readonly id: "web";
|
|
69
70
|
readonly enabled?: boolean;
|
|
70
|
-
readonly engine?: "native" | "exa";
|
|
71
71
|
readonly max_results?: number;
|
|
72
72
|
readonly search_prompt?: string;
|
|
73
|
+
readonly engine?: "native" | "exa";
|
|
73
74
|
} | {
|
|
74
75
|
readonly id: "file-parser";
|
|
75
76
|
readonly enabled?: boolean;
|
|
@@ -82,6 +83,13 @@ declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-openroute
|
|
|
82
83
|
})[];
|
|
83
84
|
readonly route?: "sort" | "fallback" | null;
|
|
84
85
|
readonly session_id?: string;
|
|
86
|
+
readonly trace?: {
|
|
87
|
+
readonly trace_id?: string;
|
|
88
|
+
readonly trace_name?: string;
|
|
89
|
+
readonly span_name?: string;
|
|
90
|
+
readonly generation_name?: string;
|
|
91
|
+
readonly parent_span_id?: string;
|
|
92
|
+
};
|
|
85
93
|
readonly models?: readonly string[];
|
|
86
94
|
readonly image_config?: {};
|
|
87
95
|
readonly modalities?: readonly ("text" | "image")[];
|
|
@@ -93,25 +101,52 @@ declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-openroute
|
|
|
93
101
|
/**
|
|
94
102
|
* Service definition for OpenRouter language model configuration.
|
|
95
103
|
*
|
|
96
|
-
*
|
|
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
|
|
110
|
+
*
|
|
97
111
|
* @category services
|
|
112
|
+
* @since 4.0.0
|
|
98
113
|
*/
|
|
99
114
|
export declare class Config extends Config_base {
|
|
100
115
|
}
|
|
101
116
|
/**
|
|
102
|
-
*
|
|
117
|
+
* OpenRouter assistant reasoning detail blocks preserved for multi-turn
|
|
118
|
+
* conversations.
|
|
119
|
+
*
|
|
103
120
|
* @category models
|
|
121
|
+
* @since 4.0.0
|
|
104
122
|
*/
|
|
105
123
|
export type ReasoningDetails = Exclude<typeof Generated.AssistantMessage.Encoded["reasoning_details"], undefined>;
|
|
106
124
|
/**
|
|
107
|
-
*
|
|
125
|
+
* File annotations emitted on OpenRouter assistant messages and exposed in
|
|
126
|
+
* finish metadata.
|
|
127
|
+
*
|
|
108
128
|
* @category models
|
|
129
|
+
* @since 4.0.0
|
|
109
130
|
*/
|
|
110
131
|
export type FileAnnotation = Extract<NonNullable<typeof Generated.AssistantMessage.fields.annotations.Type>[number], {
|
|
111
132
|
type: "file";
|
|
112
133
|
}>;
|
|
113
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
|
+
*/
|
|
114
146
|
interface SystemMessageOptions extends ProviderOptions {
|
|
147
|
+
/**
|
|
148
|
+
* Provider-specific options sent to OpenRouter for the system message.
|
|
149
|
+
*/
|
|
115
150
|
readonly openrouter?: {
|
|
116
151
|
/**
|
|
117
152
|
* A breakpoint which marks the end of reusable content eligible for caching.
|
|
@@ -119,7 +154,21 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
119
154
|
readonly cacheControl?: typeof Generated.ChatMessageContentItemCacheControl.Encoded | null;
|
|
120
155
|
} | null;
|
|
121
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
|
+
*/
|
|
122
168
|
interface UserMessageOptions extends ProviderOptions {
|
|
169
|
+
/**
|
|
170
|
+
* Provider-specific options sent to OpenRouter for the user message.
|
|
171
|
+
*/
|
|
123
172
|
readonly openrouter?: {
|
|
124
173
|
/**
|
|
125
174
|
* A breakpoint which marks the end of reusable content eligible for caching.
|
|
@@ -127,7 +176,21 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
127
176
|
readonly cacheControl?: typeof Generated.ChatMessageContentItemCacheControl.Encoded | null;
|
|
128
177
|
} | null;
|
|
129
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
|
+
*/
|
|
130
190
|
interface AssistantMessageOptions extends ProviderOptions {
|
|
191
|
+
/**
|
|
192
|
+
* Provider-specific options sent to OpenRouter for the assistant message.
|
|
193
|
+
*/
|
|
131
194
|
readonly openrouter?: {
|
|
132
195
|
/**
|
|
133
196
|
* A breakpoint which marks the end of reusable content eligible for caching.
|
|
@@ -139,7 +202,21 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
139
202
|
readonly reasoningDetails?: ReasoningDetails | null;
|
|
140
203
|
} | null;
|
|
141
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
|
+
*/
|
|
142
216
|
interface ToolMessageOptions extends ProviderOptions {
|
|
217
|
+
/**
|
|
218
|
+
* Provider-specific options sent to OpenRouter for the tool message.
|
|
219
|
+
*/
|
|
143
220
|
readonly openrouter?: {
|
|
144
221
|
/**
|
|
145
222
|
* A breakpoint which marks the end of reusable content eligible for caching.
|
|
@@ -147,7 +224,20 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
147
224
|
readonly cacheControl?: typeof Generated.ChatMessageContentItemCacheControl.Encoded | null;
|
|
148
225
|
} | null;
|
|
149
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
|
+
*/
|
|
150
237
|
interface TextPartOptions extends ProviderOptions {
|
|
238
|
+
/**
|
|
239
|
+
* Provider-specific options sent to OpenRouter for the text part.
|
|
240
|
+
*/
|
|
151
241
|
readonly openrouter?: {
|
|
152
242
|
/**
|
|
153
243
|
* A breakpoint which marks the end of reusable content eligible for caching.
|
|
@@ -155,7 +245,21 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
155
245
|
readonly cacheControl?: typeof Generated.ChatMessageContentItemCacheControl.Encoded | null;
|
|
156
246
|
} | null;
|
|
157
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
|
+
*/
|
|
158
259
|
interface ReasoningPartOptions extends ProviderOptions {
|
|
260
|
+
/**
|
|
261
|
+
* Provider-specific options sent to OpenRouter for the reasoning part.
|
|
262
|
+
*/
|
|
159
263
|
readonly openrouter?: {
|
|
160
264
|
/**
|
|
161
265
|
* A breakpoint which marks the end of reusable content eligible for caching.
|
|
@@ -167,7 +271,20 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
167
271
|
readonly reasoningDetails?: ReasoningDetails | null;
|
|
168
272
|
} | null;
|
|
169
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
|
+
*/
|
|
170
284
|
interface FilePartOptions extends ProviderOptions {
|
|
285
|
+
/**
|
|
286
|
+
* Provider-specific options sent to OpenRouter for the file part.
|
|
287
|
+
*/
|
|
171
288
|
readonly openrouter?: {
|
|
172
289
|
/**
|
|
173
290
|
* The name to give to the file. Will be prioritized over the file name
|
|
@@ -180,7 +297,21 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
180
297
|
readonly cacheControl?: typeof Generated.ChatMessageContentItemCacheControl.Encoded | null;
|
|
181
298
|
} | null;
|
|
182
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
|
+
*/
|
|
183
311
|
interface ToolCallPartOptions extends ProviderOptions {
|
|
312
|
+
/**
|
|
313
|
+
* Provider-specific options sent to OpenRouter for the tool call part.
|
|
314
|
+
*/
|
|
184
315
|
readonly openrouter?: {
|
|
185
316
|
/**
|
|
186
317
|
* Reasoning details associated with the tool call part.
|
|
@@ -188,7 +319,20 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
188
319
|
readonly reasoningDetails?: ReasoningDetails | null;
|
|
189
320
|
} | null;
|
|
190
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
|
+
*/
|
|
191
332
|
interface ToolResultPartOptions extends ProviderOptions {
|
|
333
|
+
/**
|
|
334
|
+
* Provider-specific options sent to OpenRouter for the tool result part.
|
|
335
|
+
*/
|
|
192
336
|
readonly openrouter?: {
|
|
193
337
|
/**
|
|
194
338
|
* A breakpoint which marks the end of reusable content eligible for caching.
|
|
@@ -198,52 +342,205 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
198
342
|
}
|
|
199
343
|
}
|
|
200
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
|
+
*/
|
|
201
355
|
interface ReasoningPartMetadata extends ProviderMetadata {
|
|
356
|
+
/**
|
|
357
|
+
* Provider-specific metadata returned for the reasoning part.
|
|
358
|
+
*/
|
|
202
359
|
readonly openrouter?: {
|
|
360
|
+
/**
|
|
361
|
+
* Reasoning details emitted by the underlying provider for this part.
|
|
362
|
+
*/
|
|
203
363
|
readonly reasoningDetails?: ReasoningDetails | null;
|
|
204
364
|
} | null;
|
|
205
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
|
+
*/
|
|
206
376
|
interface ReasoningStartPartMetadata extends ProviderMetadata {
|
|
377
|
+
/**
|
|
378
|
+
* Provider-specific metadata returned for the streamed reasoning start.
|
|
379
|
+
*/
|
|
207
380
|
readonly openrouter?: {
|
|
381
|
+
/**
|
|
382
|
+
* Reasoning details emitted by the underlying provider for this part.
|
|
383
|
+
*/
|
|
208
384
|
readonly reasoningDetails?: ReasoningDetails | null;
|
|
209
385
|
} | null;
|
|
210
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
|
+
*/
|
|
211
397
|
interface ReasoningDeltaPartMetadata extends ProviderMetadata {
|
|
398
|
+
/**
|
|
399
|
+
* Provider-specific metadata returned for the streamed reasoning delta.
|
|
400
|
+
*/
|
|
212
401
|
readonly openrouter?: {
|
|
402
|
+
/**
|
|
403
|
+
* Reasoning details emitted by the underlying provider for this delta.
|
|
404
|
+
*/
|
|
213
405
|
readonly reasoningDetails?: ReasoningDetails | null;
|
|
214
406
|
} | null;
|
|
215
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
|
+
*/
|
|
216
419
|
interface ToolCallPartMetadata extends ProviderMetadata {
|
|
420
|
+
/**
|
|
421
|
+
* Provider-specific metadata returned for the tool call.
|
|
422
|
+
*/
|
|
217
423
|
readonly openrouter?: {
|
|
424
|
+
/**
|
|
425
|
+
* Reasoning details associated with this tool call.
|
|
426
|
+
*/
|
|
218
427
|
readonly reasoningDetails?: ReasoningDetails | null;
|
|
219
428
|
} | null;
|
|
220
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
|
+
*/
|
|
221
441
|
interface UrlSourcePartMetadata extends ProviderMetadata {
|
|
442
|
+
/**
|
|
443
|
+
* Provider-specific citation metadata returned for the URL source.
|
|
444
|
+
*/
|
|
222
445
|
readonly openrouter?: {
|
|
446
|
+
/**
|
|
447
|
+
* The cited source content returned by the provider.
|
|
448
|
+
*/
|
|
223
449
|
readonly content?: string | null;
|
|
450
|
+
/**
|
|
451
|
+
* The zero-based start index of the citation in the generated text.
|
|
452
|
+
*/
|
|
224
453
|
readonly startIndex?: number | null;
|
|
454
|
+
/**
|
|
455
|
+
* The zero-based end index of the citation in the generated text.
|
|
456
|
+
*/
|
|
225
457
|
readonly endIndex?: number | null;
|
|
226
458
|
} | null;
|
|
227
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
|
+
*/
|
|
228
471
|
interface FinishPartMetadata extends ProviderMetadata {
|
|
472
|
+
/**
|
|
473
|
+
* Provider-specific metadata returned when the OpenRouter response finishes.
|
|
474
|
+
*/
|
|
229
475
|
readonly openrouter?: {
|
|
476
|
+
/**
|
|
477
|
+
* Provider fingerprint for the backend configuration that served the request.
|
|
478
|
+
*/
|
|
230
479
|
readonly systemFingerprint?: string | null;
|
|
480
|
+
/**
|
|
481
|
+
* Raw token usage reported by OpenRouter.
|
|
482
|
+
*/
|
|
231
483
|
readonly usage?: typeof Generated.ChatGenerationTokenUsage.Encoded | null;
|
|
484
|
+
/**
|
|
485
|
+
* File annotations returned by the provider.
|
|
486
|
+
*/
|
|
232
487
|
readonly annotations?: ReadonlyArray<FileAnnotation> | null;
|
|
488
|
+
/**
|
|
489
|
+
* The OpenRouter provider that served the request, when reported.
|
|
490
|
+
*/
|
|
233
491
|
readonly provider?: string | null;
|
|
234
492
|
} | null;
|
|
235
493
|
}
|
|
236
494
|
}
|
|
237
495
|
/**
|
|
238
|
-
*
|
|
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
|
+
*
|
|
239
513
|
* @category constructors
|
|
514
|
+
* @since 4.0.0
|
|
240
515
|
*/
|
|
241
516
|
export declare const model: (model: string, config?: Omit<typeof Config.Service, "model">) => AiModel.Model<"openai", LanguageModel.LanguageModel, OpenRouterClient>;
|
|
242
517
|
/**
|
|
243
|
-
* 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 an Effect needs to construct a `LanguageModel.Service` value backed
|
|
524
|
+
* by `OpenRouterClient`.
|
|
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
|
|
244
541
|
*
|
|
245
|
-
* @since 1.0.0
|
|
246
542
|
* @category constructors
|
|
543
|
+
* @since 4.0.0
|
|
247
544
|
*/
|
|
248
545
|
export declare const make: (args_0: {
|
|
249
546
|
readonly model: string;
|
|
@@ -252,8 +549,17 @@ export declare const make: (args_0: {
|
|
|
252
549
|
/**
|
|
253
550
|
* Creates a layer for the OpenRouter language model.
|
|
254
551
|
*
|
|
255
|
-
*
|
|
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
|
+
*
|
|
256
561
|
* @category layers
|
|
562
|
+
* @since 4.0.0
|
|
257
563
|
*/
|
|
258
564
|
export declare const layer: (options: {
|
|
259
565
|
readonly model: string;
|
|
@@ -262,22 +568,64 @@ export declare const layer: (options: {
|
|
|
262
568
|
/**
|
|
263
569
|
* Provides config overrides for OpenRouter language model operations.
|
|
264
570
|
*
|
|
265
|
-
*
|
|
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
|
+
*
|
|
266
585
|
* @category configuration
|
|
586
|
+
* @since 4.0.0
|
|
267
587
|
*/
|
|
268
588
|
export declare const withConfigOverride: {
|
|
269
589
|
/**
|
|
270
590
|
* Provides config overrides for OpenRouter language model operations.
|
|
271
591
|
*
|
|
272
|
-
*
|
|
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
|
+
*
|
|
273
606
|
* @category configuration
|
|
607
|
+
* @since 4.0.0
|
|
274
608
|
*/
|
|
275
609
|
(overrides: typeof Config.Service): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Config>>;
|
|
276
610
|
/**
|
|
277
611
|
* Provides config overrides for OpenRouter language model operations.
|
|
278
612
|
*
|
|
279
|
-
*
|
|
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
|
+
*
|
|
280
627
|
* @category configuration
|
|
628
|
+
* @since 4.0.0
|
|
281
629
|
*/
|
|
282
630
|
<A, E, R>(self: Effect.Effect<A, E, R>, overrides: typeof Config.Service): Effect.Effect<A, E, Exclude<R, Config>>;
|
|
283
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":"AA4CA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,KAAK,MAAM,cAAc,C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