@absolutejs/ai 0.0.50 → 0.0.51
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 +22 -12
- package/dist/ai/client/index.js +30 -1
- package/dist/ai/client/index.js.map +5 -5
- package/dist/ai/index.js +531 -56
- package/dist/ai/index.js.map +15 -15
- package/dist/ai/providers/anthropic.js +100 -25
- package/dist/ai/providers/anthropic.js.map +5 -5
- package/dist/ai/providers/gemini.js +5 -2
- package/dist/ai/providers/gemini.js.map +4 -4
- package/dist/ai/providers/ollama.js +5 -2
- package/dist/ai/providers/ollama.js.map +4 -4
- package/dist/ai/providers/openai.js +56 -10
- package/dist/ai/providers/openai.js.map +5 -5
- package/dist/ai/providers/openaiCompatible.js +56 -10
- package/dist/ai/providers/openaiCompatible.js.map +5 -5
- package/dist/ai/providers/openaiResponses.js +100 -16
- package/dist/ai/providers/openaiResponses.js.map +5 -5
- package/dist/ai/providers/openrouter.js +888 -38
- package/dist/ai/providers/openrouter.js.map +10 -9
- package/dist/angular/ai/index.js +30 -1
- package/dist/angular/ai/index.js.map +5 -5
- package/dist/react/ai/index.js +30 -1
- package/dist/react/ai/index.js.map +5 -5
- package/dist/src/ai/client/actions.d.ts +53 -0
- package/dist/src/ai/errors/providerError.d.ts +3 -0
- package/dist/src/ai/index.d.ts +2 -2
- package/dist/src/ai/providers/openrouter.d.ts +46 -2
- package/dist/src/ai/providers/openrouterClient.d.ts +132 -3
- package/dist/src/ai/streamAIWithTools.d.ts +6 -0
- package/dist/svelte/ai/index.js +30 -1
- package/dist/svelte/ai/index.js.map +5 -5
- package/dist/types/ai.d.ts +54 -3
- package/dist/types/anthropic.d.ts +13 -5
- package/dist/vue/ai/index.js +30 -1
- package/dist/vue/ai/index.js.map +5 -5
- package/package.json +1 -1
|
@@ -13,6 +13,8 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
|
|
|
13
13
|
imageId?: undefined;
|
|
14
14
|
isPartial?: undefined;
|
|
15
15
|
revisedPrompt?: undefined;
|
|
16
|
+
audioId?: undefined;
|
|
17
|
+
transcript?: undefined;
|
|
16
18
|
durationMs?: undefined;
|
|
17
19
|
model?: undefined;
|
|
18
20
|
sources?: undefined;
|
|
@@ -42,6 +44,8 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
|
|
|
42
44
|
imageId?: undefined;
|
|
43
45
|
isPartial?: undefined;
|
|
44
46
|
revisedPrompt?: undefined;
|
|
47
|
+
audioId?: undefined;
|
|
48
|
+
transcript?: undefined;
|
|
45
49
|
durationMs?: undefined;
|
|
46
50
|
model?: undefined;
|
|
47
51
|
sources?: undefined;
|
|
@@ -71,6 +75,8 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
|
|
|
71
75
|
imageId?: undefined;
|
|
72
76
|
isPartial?: undefined;
|
|
73
77
|
revisedPrompt?: undefined;
|
|
78
|
+
audioId?: undefined;
|
|
79
|
+
transcript?: undefined;
|
|
74
80
|
durationMs?: undefined;
|
|
75
81
|
model?: undefined;
|
|
76
82
|
sources?: undefined;
|
|
@@ -100,6 +106,39 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
|
|
|
100
106
|
name?: undefined;
|
|
101
107
|
result?: undefined;
|
|
102
108
|
status?: undefined;
|
|
109
|
+
audioId?: undefined;
|
|
110
|
+
transcript?: undefined;
|
|
111
|
+
durationMs?: undefined;
|
|
112
|
+
model?: undefined;
|
|
113
|
+
sources?: undefined;
|
|
114
|
+
usage?: undefined;
|
|
115
|
+
position?: undefined;
|
|
116
|
+
attachments?: undefined;
|
|
117
|
+
fromMessageId?: undefined;
|
|
118
|
+
mode?: undefined;
|
|
119
|
+
newConversationId?: undefined;
|
|
120
|
+
oldConversationId?: undefined;
|
|
121
|
+
retrievalStartedAt?: undefined;
|
|
122
|
+
retrievalDurationMs?: undefined;
|
|
123
|
+
retrievedAt?: undefined;
|
|
124
|
+
trace?: undefined;
|
|
125
|
+
message?: undefined;
|
|
126
|
+
} | {
|
|
127
|
+
audioId: string | undefined;
|
|
128
|
+
conversationId: string;
|
|
129
|
+
data: string;
|
|
130
|
+
format: string;
|
|
131
|
+
messageId: string;
|
|
132
|
+
transcript: string | undefined;
|
|
133
|
+
type: "audio";
|
|
134
|
+
content?: undefined;
|
|
135
|
+
input?: undefined;
|
|
136
|
+
name?: undefined;
|
|
137
|
+
result?: undefined;
|
|
138
|
+
status?: undefined;
|
|
139
|
+
imageId?: undefined;
|
|
140
|
+
isPartial?: undefined;
|
|
141
|
+
revisedPrompt?: undefined;
|
|
103
142
|
durationMs?: undefined;
|
|
104
143
|
model?: undefined;
|
|
105
144
|
sources?: undefined;
|
|
@@ -133,6 +172,8 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
|
|
|
133
172
|
imageId?: undefined;
|
|
134
173
|
isPartial?: undefined;
|
|
135
174
|
revisedPrompt?: undefined;
|
|
175
|
+
audioId?: undefined;
|
|
176
|
+
transcript?: undefined;
|
|
136
177
|
position?: undefined;
|
|
137
178
|
attachments?: undefined;
|
|
138
179
|
fromMessageId?: undefined;
|
|
@@ -159,6 +200,8 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
|
|
|
159
200
|
imageId?: undefined;
|
|
160
201
|
isPartial?: undefined;
|
|
161
202
|
revisedPrompt?: undefined;
|
|
203
|
+
audioId?: undefined;
|
|
204
|
+
transcript?: undefined;
|
|
162
205
|
durationMs?: undefined;
|
|
163
206
|
model?: undefined;
|
|
164
207
|
sources?: undefined;
|
|
@@ -187,6 +230,8 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
|
|
|
187
230
|
imageId?: undefined;
|
|
188
231
|
isPartial?: undefined;
|
|
189
232
|
revisedPrompt?: undefined;
|
|
233
|
+
audioId?: undefined;
|
|
234
|
+
transcript?: undefined;
|
|
190
235
|
durationMs?: undefined;
|
|
191
236
|
model?: undefined;
|
|
192
237
|
sources?: undefined;
|
|
@@ -221,6 +266,8 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
|
|
|
221
266
|
imageId?: undefined;
|
|
222
267
|
isPartial?: undefined;
|
|
223
268
|
revisedPrompt?: undefined;
|
|
269
|
+
audioId?: undefined;
|
|
270
|
+
transcript?: undefined;
|
|
224
271
|
durationMs?: undefined;
|
|
225
272
|
model?: undefined;
|
|
226
273
|
sources?: undefined;
|
|
@@ -246,6 +293,8 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
|
|
|
246
293
|
imageId?: undefined;
|
|
247
294
|
isPartial?: undefined;
|
|
248
295
|
revisedPrompt?: undefined;
|
|
296
|
+
audioId?: undefined;
|
|
297
|
+
transcript?: undefined;
|
|
249
298
|
durationMs?: undefined;
|
|
250
299
|
model?: undefined;
|
|
251
300
|
sources?: undefined;
|
|
@@ -279,6 +328,8 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
|
|
|
279
328
|
imageId?: undefined;
|
|
280
329
|
isPartial?: undefined;
|
|
281
330
|
revisedPrompt?: undefined;
|
|
331
|
+
audioId?: undefined;
|
|
332
|
+
transcript?: undefined;
|
|
282
333
|
durationMs?: undefined;
|
|
283
334
|
model?: undefined;
|
|
284
335
|
usage?: undefined;
|
|
@@ -304,6 +355,8 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
|
|
|
304
355
|
imageId?: undefined;
|
|
305
356
|
isPartial?: undefined;
|
|
306
357
|
revisedPrompt?: undefined;
|
|
358
|
+
audioId?: undefined;
|
|
359
|
+
transcript?: undefined;
|
|
307
360
|
durationMs?: undefined;
|
|
308
361
|
model?: undefined;
|
|
309
362
|
sources?: undefined;
|
|
@@ -9,6 +9,8 @@ export type ProviderErrorInit = {
|
|
|
9
9
|
type?: string | null;
|
|
10
10
|
retryable: boolean;
|
|
11
11
|
cause?: unknown;
|
|
12
|
+
/** Provider-native structured details, when the response exposes them. */
|
|
13
|
+
metadata?: Record<string, unknown>;
|
|
12
14
|
};
|
|
13
15
|
export declare class ProviderError extends Error {
|
|
14
16
|
readonly provider: string;
|
|
@@ -17,6 +19,7 @@ export declare class ProviderError extends Error {
|
|
|
17
19
|
readonly type: string | null;
|
|
18
20
|
/** Whether retrying the same request later could plausibly succeed. */
|
|
19
21
|
readonly retryable: boolean;
|
|
22
|
+
readonly metadata: Record<string, unknown> | undefined;
|
|
20
23
|
/** Provider status page, when known — for surfacing "is it them?" to users. */
|
|
21
24
|
readonly statusPageUrl: string | null;
|
|
22
25
|
constructor(init: ProviderErrorInit);
|
package/dist/src/ai/index.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ export { gemini } from "./providers/gemini";
|
|
|
24
24
|
export { anthropic } from "./providers/anthropic";
|
|
25
25
|
export { ollama } from "./providers/ollama";
|
|
26
26
|
export { openai } from "./providers/openai";
|
|
27
|
-
export { createOpenRouterClient, openrouter, openrouterResponses, openRouterModelMatchesRule, } from "./providers/openrouter";
|
|
28
|
-
export type { OpenRouterClient, OpenRouterClientConfig, OpenRouterConfig, OpenRouterDataCollection, OpenRouterEmbeddingRequest, OpenRouterEmbeddingResponse, OpenRouterHttpRequestOptions, OpenRouterImageRequest, OpenRouterImageResponse, OpenRouterMaxPrice, OpenRouterModel, OpenRouterModelList, OpenRouterPerformancePreference, OpenRouterPlugin, OpenRouterProviderRouting, OpenRouterQuantization, OpenRouterRequestOptions, OpenRouterRerankRequest, OpenRouterRerankResponse, OpenRouterResponseCache, OpenRouterResponsesRequest, OpenRouterServerTool, OpenRouterServiceTier, OpenRouterSpeechRequest, OpenRouterSort, OpenRouterSortStrategy, OpenRouterTranscriptionRequest, OpenRouterVideoRequest, } from "./providers/openrouter";
|
|
27
|
+
export { createOpenRouterClient, openrouter, openrouterMessages, openrouterResponses, openRouterModelMatchesRule, verifyOpenRouterWebhookSignature, } from "./providers/openrouter";
|
|
28
|
+
export type { OpenRouterClient, OpenRouterClientConfig, OpenRouterConfig, OpenRouterDataCollection, OpenRouterEmbeddingRequest, OpenRouterEmbeddingResponse, OpenRouterFile, OpenRouterFileList, OpenRouterHttpRequestOptions, OpenRouterImageModelEndpoint, OpenRouterImageModelEndpoints, OpenRouterImageRequest, OpenRouterImageResponse, OpenRouterImageStreamEvent, OpenRouterMaxPrice, OpenRouterModel, OpenRouterModelList, OpenRouterModelQuery, OpenRouterPerformancePreference, OpenRouterPlugin, OpenRouterProviderRouting, OpenRouterQuantization, OpenRouterRequestOptions, OpenRouterRerankRequest, OpenRouterRerankResponse, OpenRouterResponseCache, OpenRouterResponsesRequest, OpenRouterServerTool, OpenRouterServiceTier, OpenRouterSpeechRequest, OpenRouterSort, OpenRouterSortStrategy, OpenRouterTrace, OpenRouterTranscriptionRequest, OpenRouterVideoJob, OpenRouterVideoRequest, OpenRouterVideoWebhookEvent, OpenRouterZdrEndpoint, } from "./providers/openrouter";
|
|
29
29
|
export { createOAuth2ClientCredentialsTokenSource } from "./providers/oauth2TokenSource";
|
|
30
30
|
export type { OAuth2ClientCredentialsConfig } from "./providers/oauth2TokenSource";
|
|
31
31
|
export { ProviderError, PROVIDER_STATUS_PAGES, providerStatusPage, } from "./errors/providerError";
|
|
@@ -44,6 +44,34 @@ export type OpenRouterResponseCache = {
|
|
|
44
44
|
/** OpenRouter response-cache TTL in seconds (1-86400). */
|
|
45
45
|
ttlSeconds?: number;
|
|
46
46
|
};
|
|
47
|
+
export type OpenRouterCacheControl = {
|
|
48
|
+
type: "ephemeral";
|
|
49
|
+
ttl?: "5m" | "1h";
|
|
50
|
+
};
|
|
51
|
+
export type OpenRouterPromptCacheOptions = {
|
|
52
|
+
mode: "explicit";
|
|
53
|
+
ttl?: string;
|
|
54
|
+
};
|
|
55
|
+
export type OpenRouterReasoning = {
|
|
56
|
+
context?: "all_turns" | "auto" | "current_turn";
|
|
57
|
+
effort?: "minimal" | "low" | "medium" | "high" | "max" | "xhigh";
|
|
58
|
+
enabled?: boolean;
|
|
59
|
+
exclude?: boolean;
|
|
60
|
+
maxTokens?: number;
|
|
61
|
+
mode?: "pro";
|
|
62
|
+
summary?: "auto" | "concise" | "detailed";
|
|
63
|
+
};
|
|
64
|
+
export type OpenRouterTrace = Record<string, unknown> & {
|
|
65
|
+
generation_name?: string;
|
|
66
|
+
parent_span_id?: string;
|
|
67
|
+
span_name?: string;
|
|
68
|
+
trace_id?: string;
|
|
69
|
+
trace_name?: string;
|
|
70
|
+
};
|
|
71
|
+
export type OpenRouterAudioOutput = {
|
|
72
|
+
format: "wav" | "mp3" | "flac" | "opus" | "pcm16";
|
|
73
|
+
voice: string;
|
|
74
|
+
};
|
|
47
75
|
export type OpenRouterPlugin = {
|
|
48
76
|
id: string;
|
|
49
77
|
[option: string]: unknown;
|
|
@@ -53,20 +81,34 @@ export type OpenRouterServerTool = {
|
|
|
53
81
|
parameters?: Record<string, unknown>;
|
|
54
82
|
};
|
|
55
83
|
export type OpenRouterRequestOptions = {
|
|
84
|
+
/** Stream text and synthesized audio from an audio-output chat model. */
|
|
85
|
+
audioOutput?: OpenRouterAudioOutput;
|
|
86
|
+
/** Automatic top-level prompt caching, including optional Anthropic TTL. */
|
|
87
|
+
cacheControl?: OpenRouterCacheControl;
|
|
56
88
|
/** Future OpenRouter fields. Security-sensitive routing fields are rejected. */
|
|
57
89
|
extraBody?: Record<string, unknown>;
|
|
58
90
|
fallbackModels?: readonly string[];
|
|
59
91
|
includeReasoning?: boolean;
|
|
60
92
|
maxToolCalls?: number;
|
|
93
|
+
/** Native `/messages` server-tool definitions and replayable tool shapes. */
|
|
94
|
+
messagesTools?: readonly Record<string, unknown>[];
|
|
61
95
|
plugins?: readonly OpenRouterPlugin[];
|
|
96
|
+
/** Stable cache identity used by compatible OpenAI-family models. */
|
|
97
|
+
promptCacheKey?: string;
|
|
98
|
+
/** OpenAI explicit-cache mode and TTL. */
|
|
99
|
+
promptCacheOptions?: OpenRouterPromptCacheOptions;
|
|
62
100
|
preset?: string;
|
|
63
101
|
responseCache?: OpenRouterResponseCache;
|
|
102
|
+
/** OpenRouter-native reasoning controls beyond the portable effort knob. */
|
|
103
|
+
reasoning?: OpenRouterReasoning;
|
|
64
104
|
routerMetadata?: boolean;
|
|
65
105
|
routing?: OpenRouterProviderRouting;
|
|
66
106
|
serverTools?: readonly OpenRouterServerTool[];
|
|
67
107
|
serviceTier?: OpenRouterServiceTier;
|
|
68
108
|
sessionId?: string;
|
|
69
109
|
stopServerToolsWhen?: readonly Record<string, unknown>[];
|
|
110
|
+
/** Metadata forwarded to configured OpenRouter Broadcast destinations. */
|
|
111
|
+
trace?: OpenRouterTrace;
|
|
70
112
|
transforms?: readonly string[];
|
|
71
113
|
user?: string;
|
|
72
114
|
verbosity?: "low" | "medium" | "high";
|
|
@@ -109,5 +151,7 @@ export type OpenRouterConfig = {
|
|
|
109
151
|
export declare const openrouter: (config: OpenRouterConfig) => AIProviderConfig;
|
|
110
152
|
/** OpenRouter's stateless OpenAI-compatible Responses API provider skin. */
|
|
111
153
|
export declare const openrouterResponses: (config: OpenRouterConfig) => AIProviderConfig;
|
|
112
|
-
|
|
113
|
-
export
|
|
154
|
+
/** OpenRouter provider using the native Anthropic Messages protocol skin. */
|
|
155
|
+
export declare const openrouterMessages: (config: OpenRouterConfig) => AIProviderConfig;
|
|
156
|
+
export { createOpenRouterClient, openRouterModelMatchesRule, verifyOpenRouterWebhookSignature, } from "./openrouterClient";
|
|
157
|
+
export type { OpenRouterClient, OpenRouterClientConfig, OpenRouterEmbeddingRequest, OpenRouterEmbeddingResponse, OpenRouterFile, OpenRouterFileList, OpenRouterHttpRequestOptions, OpenRouterImageModelEndpoint, OpenRouterImageModelEndpoints, OpenRouterImageRequest, OpenRouterImageResponse, OpenRouterImageStreamEvent, OpenRouterModel, OpenRouterModelList, OpenRouterModelQuery, OpenRouterRerankRequest, OpenRouterRerankResponse, OpenRouterResponsesRequest, OpenRouterSpeechRequest, OpenRouterTranscriptionRequest, OpenRouterVideoJob, OpenRouterVideoRequest, OpenRouterVideoWebhookEvent, OpenRouterZdrEndpoint, } from "./openrouterClient";
|
|
@@ -19,6 +19,22 @@ export type OpenRouterModel = {
|
|
|
19
19
|
export type OpenRouterModelList = {
|
|
20
20
|
data: OpenRouterModel[];
|
|
21
21
|
};
|
|
22
|
+
export type OpenRouterModelQuery = {
|
|
23
|
+
arch?: string;
|
|
24
|
+
context?: number;
|
|
25
|
+
distillable?: "false" | "true";
|
|
26
|
+
input_modalities?: string;
|
|
27
|
+
max_price?: number;
|
|
28
|
+
min_price?: number;
|
|
29
|
+
model_authors?: string;
|
|
30
|
+
output_modalities?: string;
|
|
31
|
+
providers?: string;
|
|
32
|
+
q?: string;
|
|
33
|
+
region?: "eu";
|
|
34
|
+
supported_parameters?: string;
|
|
35
|
+
sort?: "pricing-low-to-high" | "pricing-high-to-low" | "context-high-to-low" | "throughput-high-to-low" | "latency-low-to-high" | "most-popular" | "top-weekly" | "newest" | "intelligence-high-to-low" | "design-arena-elo-high-to-low";
|
|
36
|
+
zdr?: "true";
|
|
37
|
+
};
|
|
22
38
|
export type OpenRouterEmbeddingRequest = {
|
|
23
39
|
model: string;
|
|
24
40
|
input: string | string[] | number[] | number[][];
|
|
@@ -76,6 +92,7 @@ export type OpenRouterImageRequest = {
|
|
|
76
92
|
seed?: number;
|
|
77
93
|
input_references?: Array<Record<string, unknown>>;
|
|
78
94
|
provider?: Record<string, unknown>;
|
|
95
|
+
stream?: boolean;
|
|
79
96
|
};
|
|
80
97
|
export type OpenRouterImageResponse = {
|
|
81
98
|
created: number;
|
|
@@ -85,6 +102,24 @@ export type OpenRouterImageResponse = {
|
|
|
85
102
|
}>;
|
|
86
103
|
usage?: Record<string, number>;
|
|
87
104
|
};
|
|
105
|
+
export type OpenRouterImageModelEndpoint = {
|
|
106
|
+
allowed_passthrough_parameters: string[];
|
|
107
|
+
pricing: Array<{
|
|
108
|
+
billable: string;
|
|
109
|
+
cost_usd: number;
|
|
110
|
+
unit: "image" | "megapixel" | "token" | string;
|
|
111
|
+
variant?: string;
|
|
112
|
+
}>;
|
|
113
|
+
provider_name: string;
|
|
114
|
+
provider_slug: string;
|
|
115
|
+
provider_tag: string | null;
|
|
116
|
+
supported_parameters: Record<string, unknown>;
|
|
117
|
+
supports_streaming: boolean;
|
|
118
|
+
};
|
|
119
|
+
export type OpenRouterImageModelEndpoints = {
|
|
120
|
+
endpoints: OpenRouterImageModelEndpoint[];
|
|
121
|
+
id: string;
|
|
122
|
+
};
|
|
88
123
|
export type OpenRouterResponsesRequest = Record<string, unknown> & {
|
|
89
124
|
input: unknown;
|
|
90
125
|
model: string;
|
|
@@ -102,6 +137,58 @@ export type OpenRouterVideoRequest = Record<string, unknown> & {
|
|
|
102
137
|
model: string;
|
|
103
138
|
prompt: string;
|
|
104
139
|
};
|
|
140
|
+
export type OpenRouterImageStreamEvent = Record<string, unknown> & {
|
|
141
|
+
type: string;
|
|
142
|
+
b64_json?: string;
|
|
143
|
+
media_type?: string;
|
|
144
|
+
partial_image_index?: number;
|
|
145
|
+
usage?: Record<string, number>;
|
|
146
|
+
};
|
|
147
|
+
export type OpenRouterFile = {
|
|
148
|
+
created_at: string;
|
|
149
|
+
downloadable: boolean;
|
|
150
|
+
filename: string;
|
|
151
|
+
id: string;
|
|
152
|
+
mime_type: string;
|
|
153
|
+
size_bytes: number;
|
|
154
|
+
type: "file";
|
|
155
|
+
};
|
|
156
|
+
export type OpenRouterFileList = {
|
|
157
|
+
cursor: string | null;
|
|
158
|
+
data: OpenRouterFile[];
|
|
159
|
+
first_id: string | null;
|
|
160
|
+
has_more: boolean;
|
|
161
|
+
last_id: string | null;
|
|
162
|
+
};
|
|
163
|
+
export type OpenRouterVideoJob = {
|
|
164
|
+
error?: string;
|
|
165
|
+
generation_id?: string | null;
|
|
166
|
+
id: string;
|
|
167
|
+
polling_url?: string;
|
|
168
|
+
status: "pending" | "in_progress" | "completed" | "failed" | "cancelled" | "expired";
|
|
169
|
+
unsigned_urls?: string[];
|
|
170
|
+
usage?: {
|
|
171
|
+
cost?: number;
|
|
172
|
+
is_byok?: boolean;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
export type OpenRouterVideoWebhookEvent = {
|
|
176
|
+
created_at: string;
|
|
177
|
+
data: OpenRouterVideoJob & {
|
|
178
|
+
model?: string | null;
|
|
179
|
+
};
|
|
180
|
+
type: "video.generation.completed" | "video.generation.failed" | "video.generation.cancelled" | "video.generation.expired";
|
|
181
|
+
};
|
|
182
|
+
export type OpenRouterZdrEndpoint = Record<string, unknown> & {
|
|
183
|
+
context_length: number;
|
|
184
|
+
model_id: string;
|
|
185
|
+
model_name: string;
|
|
186
|
+
name: string;
|
|
187
|
+
pricing: Record<string, string>;
|
|
188
|
+
provider_name: string;
|
|
189
|
+
supported_parameters: string[];
|
|
190
|
+
tag: string;
|
|
191
|
+
};
|
|
105
192
|
export type OpenRouterHttpRequestOptions = Omit<RequestInit, "body" | "headers"> & {
|
|
106
193
|
body?: unknown;
|
|
107
194
|
headers?: HeadersInit;
|
|
@@ -109,12 +196,26 @@ export type OpenRouterHttpRequestOptions = Omit<RequestInit, "body" | "headers">
|
|
|
109
196
|
};
|
|
110
197
|
export type OpenRouterClient = ReturnType<typeof createOpenRouterClient>;
|
|
111
198
|
export declare const openRouterModelMatchesRule: (model: string, rule: string) => boolean;
|
|
199
|
+
/** Verify `X-OpenRouter-Signature` against the exact raw webhook bytes. */
|
|
200
|
+
export declare const verifyOpenRouterWebhookSignature: (options: {
|
|
201
|
+
body: string | Uint8Array;
|
|
202
|
+
header: string;
|
|
203
|
+
secret: string;
|
|
204
|
+
nowSeconds?: number;
|
|
205
|
+
toleranceSeconds?: number;
|
|
206
|
+
}) => Promise<boolean>;
|
|
112
207
|
export declare const createOpenRouterClient: (config: OpenRouterClientConfig) => {
|
|
113
208
|
cancelBatch: (id: string) => Promise<Record<string, unknown>>;
|
|
114
209
|
createBatch: (body: Record<string, unknown>) => Promise<Record<string, unknown>>;
|
|
115
210
|
createEmbedding: (body: OpenRouterEmbeddingRequest) => Promise<OpenRouterEmbeddingResponse>;
|
|
116
211
|
generateImage: (body: OpenRouterImageRequest) => Promise<OpenRouterImageResponse>;
|
|
117
|
-
|
|
212
|
+
deleteFile: (id: string, workspaceId?: string) => Promise<{
|
|
213
|
+
id: string;
|
|
214
|
+
type: "file_deleted";
|
|
215
|
+
}>;
|
|
216
|
+
downloadFile: (id: string, workspaceId?: string) => Promise<Response>;
|
|
217
|
+
downloadVideo: (id: string, index?: number) => Promise<Response>;
|
|
218
|
+
generateVideo: (body: OpenRouterVideoRequest) => Promise<OpenRouterVideoJob>;
|
|
118
219
|
getBatch: (id: string) => Promise<Record<string, unknown>>;
|
|
119
220
|
getCredits: () => Promise<{
|
|
120
221
|
data: Record<string, number>;
|
|
@@ -122,17 +223,40 @@ export declare const createOpenRouterClient: (config: OpenRouterClientConfig) =>
|
|
|
122
223
|
getCurrentKey: () => Promise<{
|
|
123
224
|
data: Record<string, unknown>;
|
|
124
225
|
}>;
|
|
226
|
+
getFile: (id: string, workspaceId?: string) => Promise<OpenRouterFile>;
|
|
125
227
|
getGeneration: (id: string) => Promise<{
|
|
126
228
|
data: Record<string, unknown>;
|
|
127
229
|
}>;
|
|
128
230
|
getModelEndpoints: (model: string) => Promise<Record<string, unknown>>;
|
|
129
|
-
|
|
231
|
+
getModel: (model: string) => Promise<{
|
|
232
|
+
data: OpenRouterModel;
|
|
233
|
+
}>;
|
|
234
|
+
getImageModelEndpoints: (model: string) => Promise<OpenRouterImageModelEndpoints>;
|
|
235
|
+
getVideo: (id: string) => Promise<OpenRouterVideoJob>;
|
|
130
236
|
listImageModels: () => Promise<OpenRouterModelList>;
|
|
131
|
-
|
|
237
|
+
listFiles: (query?: {
|
|
238
|
+
cursor?: string;
|
|
239
|
+
limit?: number;
|
|
240
|
+
workspace_id?: string;
|
|
241
|
+
}) => Promise<OpenRouterFileList>;
|
|
242
|
+
listModels: (query?: OpenRouterModelQuery) => Promise<OpenRouterModelList>;
|
|
243
|
+
listUserModels: () => Promise<OpenRouterModelList>;
|
|
244
|
+
listZdrEndpoints: () => Promise<{
|
|
245
|
+
data: OpenRouterZdrEndpoint[];
|
|
246
|
+
}>;
|
|
247
|
+
countModels: (outputModalities?: string) => Promise<{
|
|
248
|
+
data: {
|
|
249
|
+
count: number;
|
|
250
|
+
};
|
|
251
|
+
}>;
|
|
132
252
|
listPresets: (offset?: number, limit?: number) => Promise<{
|
|
133
253
|
data: Record<string, unknown>[];
|
|
134
254
|
total_count: number;
|
|
135
255
|
}>;
|
|
256
|
+
listPresetVersions: (slug: string, offset?: number, limit?: number) => Promise<{
|
|
257
|
+
data: Record<string, unknown>[];
|
|
258
|
+
total_count: number;
|
|
259
|
+
}>;
|
|
136
260
|
listProviders: () => Promise<{
|
|
137
261
|
data: Record<string, unknown>[];
|
|
138
262
|
}>;
|
|
@@ -140,8 +264,13 @@ export declare const createOpenRouterClient: (config: OpenRouterClientConfig) =>
|
|
|
140
264
|
listVideoModels: () => Promise<OpenRouterModelList>;
|
|
141
265
|
request: <T>(path: string, options?: OpenRouterHttpRequestOptions) => Promise<T>;
|
|
142
266
|
requestRaw: (path: string, options?: OpenRouterHttpRequestOptions) => Promise<Response>;
|
|
267
|
+
streamImage: (body: Omit<OpenRouterImageRequest, "stream">, options?: Omit<OpenRouterHttpRequestOptions, "body" | "method">) => AsyncGenerator<OpenRouterImageStreamEvent, void, any>;
|
|
143
268
|
respond: (body: OpenRouterResponsesRequest) => Promise<Response> | Promise<Record<string, unknown>>;
|
|
144
269
|
rerank: (body: OpenRouterRerankRequest) => Promise<OpenRouterRerankResponse>;
|
|
145
270
|
speak: (body: OpenRouterSpeechRequest) => Promise<Response>;
|
|
146
271
|
transcribe: (body: OpenRouterTranscriptionRequest | FormData) => Promise<Record<string, unknown>>;
|
|
272
|
+
uploadFile: (file: Blob, options?: {
|
|
273
|
+
filename?: string;
|
|
274
|
+
workspaceId?: string;
|
|
275
|
+
}) => Promise<OpenRouterFile>;
|
|
147
276
|
};
|
|
@@ -23,6 +23,12 @@ export type StreamAIWithToolsEvent = {
|
|
|
23
23
|
} | {
|
|
24
24
|
type: "text";
|
|
25
25
|
content: string;
|
|
26
|
+
} | {
|
|
27
|
+
type: "audio";
|
|
28
|
+
data: string;
|
|
29
|
+
format: string;
|
|
30
|
+
transcript?: string;
|
|
31
|
+
audioId?: string;
|
|
26
32
|
}
|
|
27
33
|
/** A model turn finished streaming — carries that turn's own usage, so
|
|
28
34
|
* metering can bill per-turn instead of waiting for the summed total. */
|
package/dist/svelte/ai/index.js
CHANGED
|
@@ -106,6 +106,16 @@ var serverMessageToAction = (message) => {
|
|
|
106
106
|
revisedPrompt: message.revisedPrompt,
|
|
107
107
|
type: "image"
|
|
108
108
|
};
|
|
109
|
+
case "audio":
|
|
110
|
+
return {
|
|
111
|
+
audioId: message.audioId,
|
|
112
|
+
conversationId: message.conversationId,
|
|
113
|
+
data: message.data,
|
|
114
|
+
format: message.format,
|
|
115
|
+
messageId: message.messageId,
|
|
116
|
+
transcript: message.transcript,
|
|
117
|
+
type: "audio"
|
|
118
|
+
};
|
|
109
119
|
case "complete":
|
|
110
120
|
return {
|
|
111
121
|
conversationId: message.conversationId,
|
|
@@ -181,6 +191,8 @@ var isValidAIServerMessage = (data) => {
|
|
|
181
191
|
return "name" in data && "status" in data && "messageId" in data && "conversationId" in data;
|
|
182
192
|
case "image":
|
|
183
193
|
return "data" in data && typeof data.data === "string" && "format" in data && typeof data.format === "string" && "isPartial" in data && typeof data.isPartial === "boolean" && "messageId" in data && "conversationId" in data;
|
|
194
|
+
case "audio":
|
|
195
|
+
return "data" in data && typeof data.data === "string" && "format" in data && typeof data.format === "string" && "messageId" in data && "conversationId" in data;
|
|
184
196
|
case "complete":
|
|
185
197
|
return "messageId" in data && "conversationId" in data;
|
|
186
198
|
case "turn_queued":
|
|
@@ -543,6 +555,20 @@ var handleImage = (state, action) => {
|
|
|
543
555
|
});
|
|
544
556
|
conversation.messages = [...conversation.messages];
|
|
545
557
|
};
|
|
558
|
+
var handleAudio = (state, action) => {
|
|
559
|
+
const conversation = getOrCreate(state, action.conversationId);
|
|
560
|
+
const message = getOrCreateAssistantMessage(conversation, action.messageId, action.conversationId);
|
|
561
|
+
message.audio = [
|
|
562
|
+
...message.audio ?? [],
|
|
563
|
+
{
|
|
564
|
+
audioId: action.audioId,
|
|
565
|
+
data: action.data,
|
|
566
|
+
format: action.format,
|
|
567
|
+
transcript: action.transcript
|
|
568
|
+
}
|
|
569
|
+
];
|
|
570
|
+
conversation.messages = [...conversation.messages];
|
|
571
|
+
};
|
|
546
572
|
var handleComplete = (state, action) => {
|
|
547
573
|
const conversation = state.conversations.get(action.conversationId);
|
|
548
574
|
if (conversation) {
|
|
@@ -613,6 +639,9 @@ var applyAction = (state, action) => {
|
|
|
613
639
|
case "image":
|
|
614
640
|
handleImage(state, action);
|
|
615
641
|
break;
|
|
642
|
+
case "audio":
|
|
643
|
+
handleAudio(state, action);
|
|
644
|
+
break;
|
|
616
645
|
case "complete":
|
|
617
646
|
handleComplete(state, action);
|
|
618
647
|
break;
|
|
@@ -772,5 +801,5 @@ export {
|
|
|
772
801
|
createAIStream
|
|
773
802
|
};
|
|
774
803
|
|
|
775
|
-
//# debugId=
|
|
804
|
+
//# debugId=D75F7C4E06A093F864756E2164756E21
|
|
776
805
|
//# sourceMappingURL=index.js.map
|