@effect/ai-openrouter 4.0.0-beta.8 → 4.0.0-beta.80
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
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* Provides OpenRouter-specific metadata fields for AI error types through
|
|
5
5
|
* module augmentation, enabling typed access to OpenRouter error details.
|
|
6
6
|
*
|
|
7
|
-
* @since
|
|
7
|
+
* @since 4.0.0
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* OpenRouter-specific error metadata fields.
|
|
11
11
|
*
|
|
12
|
-
* @since 1.0.0
|
|
13
12
|
* @category models
|
|
13
|
+
* @since 4.0.0
|
|
14
14
|
*/
|
|
15
15
|
export type OpenRouterErrorMetadata = {
|
|
16
16
|
/**
|
|
@@ -29,8 +29,8 @@ export type OpenRouterErrorMetadata = {
|
|
|
29
29
|
/**
|
|
30
30
|
* OpenRouter-specific rate limit metadata fields.
|
|
31
31
|
*
|
|
32
|
-
* @since 1.0.0
|
|
33
32
|
* @category models
|
|
33
|
+
* @since 4.0.0
|
|
34
34
|
*/
|
|
35
35
|
export type OpenRouterRateLimitMetadata = OpenRouterErrorMetadata & {
|
|
36
36
|
readonly limit: string | null;
|
|
@@ -39,45 +39,176 @@ export type OpenRouterRateLimitMetadata = OpenRouterErrorMetadata & {
|
|
|
39
39
|
readonly resetTokens: string | null;
|
|
40
40
|
};
|
|
41
41
|
declare module "effect/unstable/ai/AiError" {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
/**
|
|
43
|
+
* OpenRouter metadata attached to `RateLimitError` values.
|
|
44
|
+
*
|
|
45
|
+
* **Details**
|
|
46
|
+
*
|
|
47
|
+
* Captures OpenRouter error details together with rate limit header
|
|
48
|
+
* information from responses where the provider rejected the request because
|
|
49
|
+
* a limit was reached.
|
|
50
|
+
*
|
|
51
|
+
* @category configuration
|
|
52
|
+
* @since 4.0.0
|
|
53
|
+
*/
|
|
54
|
+
interface RateLimitErrorMetadata {
|
|
55
|
+
/**
|
|
56
|
+
* OpenRouter-specific details for the rate limit response.
|
|
57
|
+
*/
|
|
58
|
+
readonly openrouter?: OpenRouterRateLimitMetadata | null;
|
|
46
59
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
/**
|
|
61
|
+
* OpenRouter metadata attached to `QuotaExhaustedError` values.
|
|
62
|
+
*
|
|
63
|
+
* **Details**
|
|
64
|
+
*
|
|
65
|
+
* Preserves provider error details for failures caused by exhausted account,
|
|
66
|
+
* billing, or usage quota.
|
|
67
|
+
*
|
|
68
|
+
* @category configuration
|
|
69
|
+
* @since 4.0.0
|
|
70
|
+
*/
|
|
71
|
+
interface QuotaExhaustedErrorMetadata {
|
|
72
|
+
/**
|
|
73
|
+
* OpenRouter-specific details for the quota exhaustion response.
|
|
74
|
+
*/
|
|
75
|
+
readonly openrouter?: OpenRouterErrorMetadata | null;
|
|
51
76
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
77
|
+
/**
|
|
78
|
+
* OpenRouter metadata attached to `AuthenticationError` values.
|
|
79
|
+
*
|
|
80
|
+
* **Details**
|
|
81
|
+
*
|
|
82
|
+
* Preserves provider error details for failed API key, authorization, or
|
|
83
|
+
* permission checks.
|
|
84
|
+
*
|
|
85
|
+
* @category configuration
|
|
86
|
+
* @since 4.0.0
|
|
87
|
+
*/
|
|
88
|
+
interface AuthenticationErrorMetadata {
|
|
89
|
+
/**
|
|
90
|
+
* OpenRouter-specific details for the authentication failure.
|
|
91
|
+
*/
|
|
92
|
+
readonly openrouter?: OpenRouterErrorMetadata | null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* OpenRouter metadata attached to `ContentPolicyError` values.
|
|
96
|
+
*
|
|
97
|
+
* **Details**
|
|
98
|
+
*
|
|
99
|
+
* Preserves provider error details when OpenRouter rejects input or output
|
|
100
|
+
* because it violates a content policy.
|
|
101
|
+
*
|
|
102
|
+
* @category configuration
|
|
103
|
+
* @since 4.0.0
|
|
104
|
+
*/
|
|
105
|
+
interface ContentPolicyErrorMetadata {
|
|
106
|
+
/**
|
|
107
|
+
* OpenRouter-specific details for the content policy response.
|
|
108
|
+
*/
|
|
109
|
+
readonly openrouter?: OpenRouterErrorMetadata | null;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* OpenRouter metadata attached to `InvalidRequestError` values.
|
|
113
|
+
*
|
|
114
|
+
* **Details**
|
|
115
|
+
*
|
|
116
|
+
* Preserves provider error details for malformed requests, unsupported
|
|
117
|
+
* parameters, or other request validation failures reported by OpenRouter.
|
|
118
|
+
*
|
|
119
|
+
* @category configuration
|
|
120
|
+
* @since 4.0.0
|
|
121
|
+
*/
|
|
122
|
+
interface InvalidRequestErrorMetadata {
|
|
123
|
+
/**
|
|
124
|
+
* OpenRouter-specific details for the invalid request response.
|
|
125
|
+
*/
|
|
126
|
+
readonly openrouter?: OpenRouterErrorMetadata | null;
|
|
56
127
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
128
|
+
/**
|
|
129
|
+
* OpenRouter metadata attached to `InternalProviderError` values.
|
|
130
|
+
*
|
|
131
|
+
* **Details**
|
|
132
|
+
*
|
|
133
|
+
* Preserves provider error details for OpenRouter-side failures such as
|
|
134
|
+
* transient server errors or overload responses.
|
|
135
|
+
*
|
|
136
|
+
* @category configuration
|
|
137
|
+
* @since 4.0.0
|
|
138
|
+
*/
|
|
139
|
+
interface InternalProviderErrorMetadata {
|
|
140
|
+
/**
|
|
141
|
+
* OpenRouter-specific details for the internal provider response.
|
|
142
|
+
*/
|
|
143
|
+
readonly openrouter?: OpenRouterErrorMetadata | null;
|
|
61
144
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
145
|
+
/**
|
|
146
|
+
* OpenRouter metadata attached to `InvalidOutputError` values.
|
|
147
|
+
*
|
|
148
|
+
* **Details**
|
|
149
|
+
*
|
|
150
|
+
* Preserves provider error details when an OpenRouter response cannot be
|
|
151
|
+
* parsed or validated as the expected output.
|
|
152
|
+
*
|
|
153
|
+
* @category configuration
|
|
154
|
+
* @since 4.0.0
|
|
155
|
+
*/
|
|
156
|
+
interface InvalidOutputErrorMetadata {
|
|
157
|
+
/**
|
|
158
|
+
* OpenRouter-specific details for the invalid output response.
|
|
159
|
+
*/
|
|
160
|
+
readonly openrouter?: OpenRouterErrorMetadata | null;
|
|
66
161
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
162
|
+
/**
|
|
163
|
+
* OpenRouter metadata attached to `StructuredOutputError` values.
|
|
164
|
+
*
|
|
165
|
+
* **Details**
|
|
166
|
+
*
|
|
167
|
+
* Preserves provider error details when OpenRouter returns content that does
|
|
168
|
+
* not satisfy the requested structured output schema.
|
|
169
|
+
*
|
|
170
|
+
* @category configuration
|
|
171
|
+
* @since 4.0.0
|
|
172
|
+
*/
|
|
173
|
+
interface StructuredOutputErrorMetadata {
|
|
174
|
+
/**
|
|
175
|
+
* OpenRouter-specific details for the structured output failure.
|
|
176
|
+
*/
|
|
177
|
+
readonly openrouter?: OpenRouterErrorMetadata | null;
|
|
71
178
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
179
|
+
/**
|
|
180
|
+
* OpenRouter metadata attached to `UnsupportedSchemaError` values.
|
|
181
|
+
*
|
|
182
|
+
* **Details**
|
|
183
|
+
*
|
|
184
|
+
* Preserves provider error details when an unsupported schema failure is
|
|
185
|
+
* associated with an OpenRouter response.
|
|
186
|
+
*
|
|
187
|
+
* @category configuration
|
|
188
|
+
* @since 4.0.0
|
|
189
|
+
*/
|
|
190
|
+
interface UnsupportedSchemaErrorMetadata {
|
|
191
|
+
/**
|
|
192
|
+
* OpenRouter-specific details for the unsupported schema failure.
|
|
193
|
+
*/
|
|
194
|
+
readonly openrouter?: OpenRouterErrorMetadata | null;
|
|
76
195
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
196
|
+
/**
|
|
197
|
+
* OpenRouter metadata attached to `UnknownError` values.
|
|
198
|
+
*
|
|
199
|
+
* **Details**
|
|
200
|
+
*
|
|
201
|
+
* Preserves provider error details for OpenRouter failures that do not map
|
|
202
|
+
* cleanly to a more specific AI error category.
|
|
203
|
+
*
|
|
204
|
+
* @category configuration
|
|
205
|
+
* @since 4.0.0
|
|
206
|
+
*/
|
|
207
|
+
interface UnknownErrorMetadata {
|
|
208
|
+
/**
|
|
209
|
+
* OpenRouter-specific details for the unclassified provider failure.
|
|
210
|
+
*/
|
|
211
|
+
readonly openrouter?: OpenRouterErrorMetadata | null;
|
|
81
212
|
}
|
|
82
213
|
}
|
|
83
214
|
//# sourceMappingURL=OpenRouterError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenRouterError.d.ts","sourceRoot":"","sources":["../src/OpenRouterError.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAC1C;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAClC,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GAAG,uBAAuB,GAAG;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IACrC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC,CAAA;AAED,OAAO,QAAQ,4BAA4B,CAAC;IAC1C,UAAiB,
|
|
1
|
+
{"version":3,"file":"OpenRouterError.d.ts","sourceRoot":"","sources":["../src/OpenRouterError.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAC1C;;OAEG;IACH,QAAQ,CAAC,SAAS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