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