@absolutejs/ai 0.0.51 → 0.0.53
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 +107 -8
- package/dist/ai/index.js +317 -13
- package/dist/ai/index.js.map +4 -4
- package/dist/ai/providers/openrouter.js +318 -14
- package/dist/ai/providers/openrouter.js.map +4 -4
- package/dist/ai/providers/openrouterSDK.js +37 -0
- package/dist/ai/providers/openrouterSDK.js.map +10 -0
- package/dist/src/ai/index.d.ts +2 -2
- package/dist/src/ai/providers/openrouter.d.ts +153 -5
- package/dist/src/ai/providers/openrouterClient.d.ts +380 -10
- package/dist/src/ai/providers/openrouterSDK.d.ts +21 -0
- package/package.json +10 -2
|
@@ -1,10 +1,96 @@
|
|
|
1
1
|
export type OpenRouterClientConfig = {
|
|
2
2
|
allowedModels?: readonly string[];
|
|
3
3
|
apiKey?: string;
|
|
4
|
+
batchBaseUrl?: string;
|
|
4
5
|
baseUrl?: string;
|
|
5
6
|
fetch?: typeof globalThis.fetch;
|
|
6
7
|
headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
|
|
7
8
|
tokenSource?: () => Promise<string> | string;
|
|
9
|
+
/** Default workspace for APIs that accept explicit workspace selection. */
|
|
10
|
+
workspaceId?: string;
|
|
11
|
+
};
|
|
12
|
+
export type OpenRouterPKCE = {
|
|
13
|
+
codeChallenge: string;
|
|
14
|
+
codeChallengeMethod: "S256";
|
|
15
|
+
codeVerifier: string;
|
|
16
|
+
};
|
|
17
|
+
export type OpenRouterAuthorizationUrlOptions = {
|
|
18
|
+
baseUrl?: string;
|
|
19
|
+
callbackUrl?: string;
|
|
20
|
+
codeChallenge?: string;
|
|
21
|
+
codeChallengeMethod?: "S256" | "plain";
|
|
22
|
+
keyLabel?: string;
|
|
23
|
+
};
|
|
24
|
+
export type OpenRouterAuthCodeExchangeRequest = {
|
|
25
|
+
code: string;
|
|
26
|
+
code_challenge_method?: "S256" | "plain";
|
|
27
|
+
code_verifier?: string;
|
|
28
|
+
};
|
|
29
|
+
export type OpenRouterAuthCodeExchangeResponse = {
|
|
30
|
+
key: string;
|
|
31
|
+
user_id: string | null;
|
|
32
|
+
};
|
|
33
|
+
export type OpenRouterCreateAuthCodeRequest = {
|
|
34
|
+
callback_url: string;
|
|
35
|
+
code_challenge?: string;
|
|
36
|
+
code_challenge_method?: "S256" | "plain";
|
|
37
|
+
expires_at?: string;
|
|
38
|
+
key_label?: string;
|
|
39
|
+
limit?: number;
|
|
40
|
+
usage_limit_type?: string;
|
|
41
|
+
workspace_id?: string;
|
|
42
|
+
};
|
|
43
|
+
export type OpenRouterCreateAuthCodeResponse = {
|
|
44
|
+
data: {
|
|
45
|
+
app_id: number;
|
|
46
|
+
created_at: string;
|
|
47
|
+
id: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export type OpenRouterBatchEndpoint = "/v1/chat/completions" | "/v1/responses" | "/v1/messages" | "/v1/embeddings";
|
|
51
|
+
export type OpenRouterBatchStatus = "validating" | "in_progress" | "finalizing" | "completed" | "failed" | "expired" | "cancelling" | "cancelled";
|
|
52
|
+
export type OpenRouterBatchRequest = {
|
|
53
|
+
custom_id: string;
|
|
54
|
+
body: Record<string, unknown>;
|
|
55
|
+
};
|
|
56
|
+
export type OpenRouterBatchResult = {
|
|
57
|
+
custom_id: string;
|
|
58
|
+
id: string;
|
|
59
|
+
response?: {
|
|
60
|
+
body: Record<string, unknown>;
|
|
61
|
+
request_id: string;
|
|
62
|
+
status_code: number;
|
|
63
|
+
};
|
|
64
|
+
error?: Record<string, unknown>;
|
|
65
|
+
};
|
|
66
|
+
export type OpenRouterBatch = {
|
|
67
|
+
id: string;
|
|
68
|
+
endpoint: OpenRouterBatchEndpoint;
|
|
69
|
+
model: string;
|
|
70
|
+
status: OpenRouterBatchStatus;
|
|
71
|
+
completion_window?: "24h";
|
|
72
|
+
created_at?: string;
|
|
73
|
+
completed_at?: string | null;
|
|
74
|
+
request_counts?: {
|
|
75
|
+
completed: number;
|
|
76
|
+
failed: number;
|
|
77
|
+
total: number;
|
|
78
|
+
};
|
|
79
|
+
results?: OpenRouterBatchResult[];
|
|
80
|
+
usage?: {
|
|
81
|
+
completion_tokens: number;
|
|
82
|
+
cost: number;
|
|
83
|
+
is_byok: boolean;
|
|
84
|
+
prompt_tokens: number;
|
|
85
|
+
total_tokens: number;
|
|
86
|
+
};
|
|
87
|
+
[field: string]: unknown;
|
|
88
|
+
};
|
|
89
|
+
export type OpenRouterCreateBatchRequest = {
|
|
90
|
+
endpoint: OpenRouterBatchEndpoint;
|
|
91
|
+
model: string;
|
|
92
|
+
requests: [OpenRouterBatchRequest, ...OpenRouterBatchRequest[]];
|
|
93
|
+
completion_window?: "24h";
|
|
8
94
|
};
|
|
9
95
|
export type OpenRouterModel = {
|
|
10
96
|
id: string;
|
|
@@ -12,10 +98,20 @@ export type OpenRouterModel = {
|
|
|
12
98
|
description?: string;
|
|
13
99
|
context_length?: number;
|
|
14
100
|
architecture?: Record<string, unknown>;
|
|
15
|
-
pricing?:
|
|
101
|
+
pricing?: OpenRouterPricing;
|
|
16
102
|
supported_parameters?: string[] | Record<string, unknown>;
|
|
17
103
|
[field: string]: unknown;
|
|
18
104
|
};
|
|
105
|
+
export type OpenRouterPricingKey = "prompt" | "completion" | "request" | "image" | "web_search" | "internal_reasoning" | "input_cache_read" | "input_cache_write";
|
|
106
|
+
export type OpenRouterPricing = Partial<Record<OpenRouterPricingKey, string>> & Record<string, string | undefined>;
|
|
107
|
+
export type OpenRouterCostUnits = Partial<Record<OpenRouterPricingKey, number>>;
|
|
108
|
+
export type OpenRouterCostEstimate = {
|
|
109
|
+
components: Partial<Record<OpenRouterPricingKey, number>>;
|
|
110
|
+
total: number;
|
|
111
|
+
};
|
|
112
|
+
/** Estimate USD cost using OpenRouter's per-unit model pricing fields. */
|
|
113
|
+
export declare const estimateOpenRouterCost: (pricing: OpenRouterPricing, units: OpenRouterCostUnits) => OpenRouterCostEstimate;
|
|
114
|
+
export declare const estimateOpenRouterModelCost: (model: Pick<OpenRouterModel, "pricing">, units: OpenRouterCostUnits) => OpenRouterCostEstimate;
|
|
19
115
|
export type OpenRouterModelList = {
|
|
20
116
|
data: OpenRouterModel[];
|
|
21
117
|
};
|
|
@@ -43,6 +139,17 @@ export type OpenRouterEmbeddingRequest = {
|
|
|
43
139
|
provider?: Record<string, unknown>;
|
|
44
140
|
user?: string;
|
|
45
141
|
};
|
|
142
|
+
export type OpenRouterChatRequest = Record<string, unknown> & {
|
|
143
|
+
messages: readonly unknown[];
|
|
144
|
+
model: string;
|
|
145
|
+
stream?: false;
|
|
146
|
+
};
|
|
147
|
+
export type OpenRouterChatResponse = Record<string, unknown> & {
|
|
148
|
+
choices: Array<Record<string, unknown>>;
|
|
149
|
+
id: string;
|
|
150
|
+
model: string;
|
|
151
|
+
usage?: Record<string, unknown>;
|
|
152
|
+
};
|
|
46
153
|
export type OpenRouterEmbeddingResponse = {
|
|
47
154
|
data: Array<{
|
|
48
155
|
embedding: number[] | string;
|
|
@@ -131,7 +238,24 @@ export type OpenRouterSpeechRequest = Record<string, unknown> & {
|
|
|
131
238
|
voice: string;
|
|
132
239
|
};
|
|
133
240
|
export type OpenRouterTranscriptionRequest = Record<string, unknown> & {
|
|
241
|
+
input_audio: {
|
|
242
|
+
data: string;
|
|
243
|
+
format: string;
|
|
244
|
+
};
|
|
245
|
+
language?: string;
|
|
134
246
|
model: string;
|
|
247
|
+
provider?: Record<string, unknown>;
|
|
248
|
+
temperature?: number;
|
|
249
|
+
};
|
|
250
|
+
export type OpenRouterTranscriptionResponse = {
|
|
251
|
+
text: string;
|
|
252
|
+
usage: {
|
|
253
|
+
cost: number;
|
|
254
|
+
input_tokens: number;
|
|
255
|
+
output_tokens: number;
|
|
256
|
+
seconds: number;
|
|
257
|
+
total_tokens: number;
|
|
258
|
+
};
|
|
135
259
|
};
|
|
136
260
|
export type OpenRouterVideoRequest = Record<string, unknown> & {
|
|
137
261
|
model: string;
|
|
@@ -189,6 +313,188 @@ export type OpenRouterZdrEndpoint = Record<string, unknown> & {
|
|
|
189
313
|
supported_parameters: string[];
|
|
190
314
|
tag: string;
|
|
191
315
|
};
|
|
316
|
+
export type OpenRouterPresetVersion = {
|
|
317
|
+
config: Record<string, unknown>;
|
|
318
|
+
created_at: string;
|
|
319
|
+
creator_id: string;
|
|
320
|
+
id: string;
|
|
321
|
+
preset_id: string;
|
|
322
|
+
system_prompt: string | null;
|
|
323
|
+
updated_at: string | null;
|
|
324
|
+
version: number;
|
|
325
|
+
};
|
|
326
|
+
export type OpenRouterPreset = {
|
|
327
|
+
created_at: string;
|
|
328
|
+
creator_user_id: string;
|
|
329
|
+
designated_version: OpenRouterPresetVersion;
|
|
330
|
+
designated_version_id: string;
|
|
331
|
+
description: string | null;
|
|
332
|
+
id: string;
|
|
333
|
+
name: string;
|
|
334
|
+
slug: string;
|
|
335
|
+
status: string;
|
|
336
|
+
status_updated_at: string | null;
|
|
337
|
+
updated_at: string | null;
|
|
338
|
+
workspace_id: string;
|
|
339
|
+
};
|
|
340
|
+
export type OpenRouterPresetResponse = {
|
|
341
|
+
data: OpenRouterPreset;
|
|
342
|
+
};
|
|
343
|
+
export type OpenRouterPresetVersionResponse = {
|
|
344
|
+
data: OpenRouterPresetVersion;
|
|
345
|
+
};
|
|
346
|
+
export type OpenRouterPresetInferenceRequest = Record<string, unknown> & {
|
|
347
|
+
model?: string;
|
|
348
|
+
models?: string[];
|
|
349
|
+
};
|
|
350
|
+
export type OpenRouterActivityQuery = {
|
|
351
|
+
api_key_hash?: string;
|
|
352
|
+
date?: string;
|
|
353
|
+
user_id?: string;
|
|
354
|
+
workspace_id?: string;
|
|
355
|
+
};
|
|
356
|
+
export type OpenRouterActivityItem = {
|
|
357
|
+
byok_usage_inference: number;
|
|
358
|
+
completion_tokens: number;
|
|
359
|
+
date: string;
|
|
360
|
+
endpoint_id: string;
|
|
361
|
+
model: string;
|
|
362
|
+
model_permaslug: string;
|
|
363
|
+
prompt_tokens: number;
|
|
364
|
+
provider_name: string;
|
|
365
|
+
reasoning_tokens: number;
|
|
366
|
+
requests: number;
|
|
367
|
+
usage: number;
|
|
368
|
+
workspace_id?: string;
|
|
369
|
+
};
|
|
370
|
+
export type OpenRouterAnalyticsQuery = {
|
|
371
|
+
metrics: [string, ...string[]];
|
|
372
|
+
dimensions?: string[];
|
|
373
|
+
filters?: Array<{
|
|
374
|
+
field: string;
|
|
375
|
+
operator: string;
|
|
376
|
+
value: unknown;
|
|
377
|
+
}>;
|
|
378
|
+
granularity?: string;
|
|
379
|
+
group_limit?: number;
|
|
380
|
+
limit?: number;
|
|
381
|
+
order_by?: {
|
|
382
|
+
direction: "asc" | "desc";
|
|
383
|
+
field: string;
|
|
384
|
+
};
|
|
385
|
+
time_range?: {
|
|
386
|
+
end: string;
|
|
387
|
+
start: string;
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
export type OpenRouterAnalyticsResponse = {
|
|
391
|
+
data: {
|
|
392
|
+
data: Record<string, unknown>[];
|
|
393
|
+
metadata: {
|
|
394
|
+
query_time_ms: number;
|
|
395
|
+
row_count: number;
|
|
396
|
+
truncated: boolean;
|
|
397
|
+
};
|
|
398
|
+
};
|
|
399
|
+
};
|
|
400
|
+
export type OpenRouterAnalyticsMeta = {
|
|
401
|
+
data: {
|
|
402
|
+
dimensions: Array<{
|
|
403
|
+
display_label: string;
|
|
404
|
+
name: string;
|
|
405
|
+
}>;
|
|
406
|
+
granularities: Array<{
|
|
407
|
+
display_label: string;
|
|
408
|
+
name: string;
|
|
409
|
+
}>;
|
|
410
|
+
metrics: Array<{
|
|
411
|
+
display_format: string;
|
|
412
|
+
display_label: string;
|
|
413
|
+
is_rate: boolean;
|
|
414
|
+
name: string;
|
|
415
|
+
}>;
|
|
416
|
+
operators: Array<{
|
|
417
|
+
name: string;
|
|
418
|
+
value_type: string;
|
|
419
|
+
}>;
|
|
420
|
+
};
|
|
421
|
+
};
|
|
422
|
+
export type OpenRouterTaskClassifications = {
|
|
423
|
+
data: {
|
|
424
|
+
as_of: string;
|
|
425
|
+
classifications: Array<{
|
|
426
|
+
category_token_share: number;
|
|
427
|
+
category_usage_share: number;
|
|
428
|
+
display_name: string;
|
|
429
|
+
macro_category: string;
|
|
430
|
+
models: Array<{
|
|
431
|
+
id: string;
|
|
432
|
+
tag_token_share: number;
|
|
433
|
+
tag_usage_share: number;
|
|
434
|
+
}>;
|
|
435
|
+
tag: string;
|
|
436
|
+
token_share: number;
|
|
437
|
+
usage_share: number;
|
|
438
|
+
}>;
|
|
439
|
+
macro_categories: Array<{
|
|
440
|
+
key: string;
|
|
441
|
+
label: string;
|
|
442
|
+
token_share: number;
|
|
443
|
+
usage_share: number;
|
|
444
|
+
}>;
|
|
445
|
+
window_days: 7;
|
|
446
|
+
};
|
|
447
|
+
};
|
|
448
|
+
export type OpenRouterWorkspace = {
|
|
449
|
+
created_at: string;
|
|
450
|
+
created_by: string;
|
|
451
|
+
default_image_model: string | null;
|
|
452
|
+
default_provider_sort: "price" | "throughput" | "latency" | "exacto" | null;
|
|
453
|
+
default_text_model: string | null;
|
|
454
|
+
description: string | null;
|
|
455
|
+
id: string;
|
|
456
|
+
io_logging_api_key_ids: number[] | null;
|
|
457
|
+
io_logging_sampling_rate: number;
|
|
458
|
+
is_data_discount_logging_enabled: boolean;
|
|
459
|
+
is_observability_broadcast_enabled: boolean;
|
|
460
|
+
is_observability_io_logging_enabled: boolean;
|
|
461
|
+
name: string;
|
|
462
|
+
slug: string;
|
|
463
|
+
updated_at: string | null;
|
|
464
|
+
};
|
|
465
|
+
export type OpenRouterWorkspaceOptions = {
|
|
466
|
+
default_image_model?: string | null;
|
|
467
|
+
default_provider_sort?: OpenRouterWorkspace["default_provider_sort"];
|
|
468
|
+
default_text_model?: string | null;
|
|
469
|
+
description?: string | null;
|
|
470
|
+
io_logging_api_key_ids?: number[] | null;
|
|
471
|
+
io_logging_sampling_rate?: number;
|
|
472
|
+
is_data_discount_logging_enabled?: boolean;
|
|
473
|
+
is_observability_broadcast_enabled?: boolean;
|
|
474
|
+
is_observability_io_logging_enabled?: boolean;
|
|
475
|
+
name?: string;
|
|
476
|
+
slug?: string;
|
|
477
|
+
};
|
|
478
|
+
export type OpenRouterCreateWorkspaceRequest = OpenRouterWorkspaceOptions & {
|
|
479
|
+
name: string;
|
|
480
|
+
slug: string;
|
|
481
|
+
};
|
|
482
|
+
export type OpenRouterWorkspaceBudgetInterval = "daily" | "weekly" | "monthly" | "lifetime";
|
|
483
|
+
export type OpenRouterWorkspaceBudget = {
|
|
484
|
+
created_at: string;
|
|
485
|
+
id: string;
|
|
486
|
+
limit_usd: number;
|
|
487
|
+
reset_interval: OpenRouterWorkspaceBudgetInterval;
|
|
488
|
+
updated_at: string | null;
|
|
489
|
+
workspace_id: string;
|
|
490
|
+
};
|
|
491
|
+
export type OpenRouterWorkspaceMember = {
|
|
492
|
+
created_at: string;
|
|
493
|
+
id: string;
|
|
494
|
+
role: string;
|
|
495
|
+
user_id: string;
|
|
496
|
+
workspace_id: string;
|
|
497
|
+
};
|
|
192
498
|
export type OpenRouterHttpRequestOptions = Omit<RequestInit, "body" | "headers"> & {
|
|
193
499
|
body?: unknown;
|
|
194
500
|
headers?: HeadersInit;
|
|
@@ -196,6 +502,18 @@ export type OpenRouterHttpRequestOptions = Omit<RequestInit, "body" | "headers">
|
|
|
196
502
|
};
|
|
197
503
|
export type OpenRouterClient = ReturnType<typeof createOpenRouterClient>;
|
|
198
504
|
export declare const openRouterModelMatchesRule: (model: string, rule: string) => boolean;
|
|
505
|
+
export declare const generateOpenRouterPKCE: () => Promise<OpenRouterPKCE>;
|
|
506
|
+
export declare const createOpenRouterAuthorizationUrl: (options?: OpenRouterAuthorizationUrlOptions) => string;
|
|
507
|
+
/** Exchange a single-use OAuth code. This endpoint intentionally has no API-key authentication. */
|
|
508
|
+
export declare const exchangeOpenRouterAuthCode: (body: OpenRouterAuthCodeExchangeRequest, options?: {
|
|
509
|
+
baseUrl?: string;
|
|
510
|
+
fetch?: typeof globalThis.fetch;
|
|
511
|
+
}) => Promise<OpenRouterAuthCodeExchangeResponse>;
|
|
512
|
+
export declare const createOpenRouterKeyLinks: (key: string, siteUrl?: string) => Promise<{
|
|
513
|
+
hash: string;
|
|
514
|
+
logsUrl: string;
|
|
515
|
+
settingsUrl: string;
|
|
516
|
+
}>;
|
|
199
517
|
/** Verify `X-OpenRouter-Signature` against the exact raw webhook bytes. */
|
|
200
518
|
export declare const verifyOpenRouterWebhookSignature: (options: {
|
|
201
519
|
body: string | Uint8Array;
|
|
@@ -205,35 +523,64 @@ export declare const verifyOpenRouterWebhookSignature: (options: {
|
|
|
205
523
|
toleranceSeconds?: number;
|
|
206
524
|
}) => Promise<boolean>;
|
|
207
525
|
export declare const createOpenRouterClient: (config: OpenRouterClientConfig) => {
|
|
208
|
-
|
|
209
|
-
|
|
526
|
+
addWorkspaceMembers: (id: string, userIds: readonly string[]) => Promise<{
|
|
527
|
+
added_count: number;
|
|
528
|
+
data: OpenRouterWorkspaceMember[];
|
|
529
|
+
}>;
|
|
530
|
+
createAuthCode: (body: OpenRouterCreateAuthCodeRequest) => Promise<OpenRouterCreateAuthCodeResponse>;
|
|
531
|
+
chat: (body: OpenRouterChatRequest) => Promise<OpenRouterChatResponse>;
|
|
532
|
+
createPresetFromChatCompletions: (slug: string, body: OpenRouterPresetInferenceRequest) => Promise<OpenRouterPresetResponse>;
|
|
533
|
+
createPresetFromMessages: (slug: string, body: OpenRouterPresetInferenceRequest) => Promise<OpenRouterPresetResponse>;
|
|
534
|
+
createPresetFromResponses: (slug: string, body: OpenRouterPresetInferenceRequest) => Promise<OpenRouterPresetResponse>;
|
|
535
|
+
createWorkspace: (body: OpenRouterCreateWorkspaceRequest) => Promise<{
|
|
536
|
+
data: OpenRouterWorkspace;
|
|
537
|
+
}>;
|
|
538
|
+
createBatch: (body: OpenRouterCreateBatchRequest) => Promise<OpenRouterBatch>;
|
|
210
539
|
createEmbedding: (body: OpenRouterEmbeddingRequest) => Promise<OpenRouterEmbeddingResponse>;
|
|
211
540
|
generateImage: (body: OpenRouterImageRequest) => Promise<OpenRouterImageResponse>;
|
|
212
|
-
deleteFile: (id: string, workspaceId?: string) => Promise<{
|
|
541
|
+
deleteFile: (id: string, workspaceId?: string | undefined) => Promise<{
|
|
213
542
|
id: string;
|
|
214
543
|
type: "file_deleted";
|
|
215
544
|
}>;
|
|
216
|
-
|
|
545
|
+
deleteWorkspace: (id: string) => Promise<{
|
|
546
|
+
deleted: true;
|
|
547
|
+
}>;
|
|
548
|
+
deleteWorkspaceBudget: (id: string, interval: OpenRouterWorkspaceBudgetInterval) => Promise<{
|
|
549
|
+
deleted: true;
|
|
550
|
+
}>;
|
|
551
|
+
downloadFile: (id: string, workspaceId?: string | undefined) => Promise<Response>;
|
|
217
552
|
downloadVideo: (id: string, index?: number) => Promise<Response>;
|
|
218
553
|
generateVideo: (body: OpenRouterVideoRequest) => Promise<OpenRouterVideoJob>;
|
|
219
|
-
getBatch: (id: string) => Promise<
|
|
554
|
+
getBatch: (id: string) => Promise<OpenRouterBatch>;
|
|
555
|
+
getActivity: (query?: OpenRouterActivityQuery) => Promise<{
|
|
556
|
+
data: OpenRouterActivityItem[];
|
|
557
|
+
}>;
|
|
558
|
+
getAnalyticsMeta: () => Promise<OpenRouterAnalyticsMeta>;
|
|
220
559
|
getCredits: () => Promise<{
|
|
221
560
|
data: Record<string, number>;
|
|
222
561
|
}>;
|
|
223
562
|
getCurrentKey: () => Promise<{
|
|
224
563
|
data: Record<string, unknown>;
|
|
225
564
|
}>;
|
|
226
|
-
getFile: (id: string, workspaceId?: string) => Promise<OpenRouterFile>;
|
|
565
|
+
getFile: (id: string, workspaceId?: string | undefined) => Promise<OpenRouterFile>;
|
|
227
566
|
getGeneration: (id: string) => Promise<{
|
|
228
567
|
data: Record<string, unknown>;
|
|
229
568
|
}>;
|
|
569
|
+
getGenerationContent: (id: string) => Promise<Record<string, unknown>>;
|
|
230
570
|
getModelEndpoints: (model: string) => Promise<Record<string, unknown>>;
|
|
231
571
|
getModel: (model: string) => Promise<{
|
|
232
572
|
data: OpenRouterModel;
|
|
233
573
|
}>;
|
|
234
574
|
getImageModelEndpoints: (model: string) => Promise<OpenRouterImageModelEndpoints>;
|
|
575
|
+
getPreset: (slug: string) => Promise<OpenRouterPresetResponse>;
|
|
576
|
+
getPresetVersion: (slug: string, version: number | string) => Promise<OpenRouterPresetVersionResponse>;
|
|
577
|
+
getTaskClassifications: (window?: "7d") => Promise<OpenRouterTaskClassifications>;
|
|
235
578
|
getVideo: (id: string) => Promise<OpenRouterVideoJob>;
|
|
579
|
+
getWorkspace: (id: string) => Promise<{
|
|
580
|
+
data: OpenRouterWorkspace;
|
|
581
|
+
}>;
|
|
236
582
|
listImageModels: () => Promise<OpenRouterModelList>;
|
|
583
|
+
listEmbeddingModels: () => Promise<OpenRouterModelList>;
|
|
237
584
|
listFiles: (query?: {
|
|
238
585
|
cursor?: string;
|
|
239
586
|
limit?: number;
|
|
@@ -250,11 +597,11 @@ export declare const createOpenRouterClient: (config: OpenRouterClientConfig) =>
|
|
|
250
597
|
};
|
|
251
598
|
}>;
|
|
252
599
|
listPresets: (offset?: number, limit?: number) => Promise<{
|
|
253
|
-
data:
|
|
600
|
+
data: OpenRouterPreset[];
|
|
254
601
|
total_count: number;
|
|
255
602
|
}>;
|
|
256
603
|
listPresetVersions: (slug: string, offset?: number, limit?: number) => Promise<{
|
|
257
|
-
data:
|
|
604
|
+
data: OpenRouterPresetVersion[];
|
|
258
605
|
total_count: number;
|
|
259
606
|
}>;
|
|
260
607
|
listProviders: () => Promise<{
|
|
@@ -262,15 +609,38 @@ export declare const createOpenRouterClient: (config: OpenRouterClientConfig) =>
|
|
|
262
609
|
}>;
|
|
263
610
|
listRerankModels: () => Promise<OpenRouterModelList>;
|
|
264
611
|
listVideoModels: () => Promise<OpenRouterModelList>;
|
|
612
|
+
listWorkspaceBudgets: (id: string) => Promise<{
|
|
613
|
+
data: OpenRouterWorkspaceBudget[];
|
|
614
|
+
}>;
|
|
615
|
+
listWorkspaces: (offset?: number, limit?: number) => Promise<{
|
|
616
|
+
data: OpenRouterWorkspace[];
|
|
617
|
+
total_count: number;
|
|
618
|
+
}>;
|
|
619
|
+
queryAnalytics: (body: OpenRouterAnalyticsQuery) => Promise<OpenRouterAnalyticsResponse>;
|
|
620
|
+
removeWorkspaceMembers: (id: string, userIds: readonly string[]) => Promise<{
|
|
621
|
+
data: OpenRouterWorkspaceMember[];
|
|
622
|
+
removed_count: number;
|
|
623
|
+
}>;
|
|
265
624
|
request: <T>(path: string, options?: OpenRouterHttpRequestOptions) => Promise<T>;
|
|
266
625
|
requestRaw: (path: string, options?: OpenRouterHttpRequestOptions) => Promise<Response>;
|
|
267
626
|
streamImage: (body: Omit<OpenRouterImageRequest, "stream">, options?: Omit<OpenRouterHttpRequestOptions, "body" | "method">) => AsyncGenerator<OpenRouterImageStreamEvent, void, any>;
|
|
268
627
|
respond: (body: OpenRouterResponsesRequest) => Promise<Response> | Promise<Record<string, unknown>>;
|
|
269
628
|
rerank: (body: OpenRouterRerankRequest) => Promise<OpenRouterRerankResponse>;
|
|
270
629
|
speak: (body: OpenRouterSpeechRequest) => Promise<Response>;
|
|
271
|
-
transcribe: (body: OpenRouterTranscriptionRequest | FormData) => Promise<
|
|
630
|
+
transcribe: (body: OpenRouterTranscriptionRequest | FormData) => Promise<OpenRouterTranscriptionResponse>;
|
|
272
631
|
uploadFile: (file: Blob, options?: {
|
|
273
632
|
filename?: string;
|
|
274
633
|
workspaceId?: string;
|
|
275
634
|
}) => Promise<OpenRouterFile>;
|
|
635
|
+
updateWorkspace: (id: string, body: OpenRouterWorkspaceOptions) => Promise<{
|
|
636
|
+
data: OpenRouterWorkspace;
|
|
637
|
+
}>;
|
|
638
|
+
upsertWorkspaceBudget: (id: string, interval: OpenRouterWorkspaceBudgetInterval, limitUsd: number) => Promise<{
|
|
639
|
+
data: OpenRouterWorkspaceBudget;
|
|
640
|
+
}>;
|
|
641
|
+
waitForBatch: (id: string, options?: {
|
|
642
|
+
intervalMs?: number;
|
|
643
|
+
signal?: AbortSignal;
|
|
644
|
+
timeoutMs?: number;
|
|
645
|
+
}) => Promise<OpenRouterBatch>;
|
|
276
646
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OpenRouter as OfficialOpenRouterSDK, type SDKOptions } from "@openrouter/sdk";
|
|
2
|
+
export type OpenRouterSDKConfig = Omit<SDKOptions, "apiKey" | "appCategories" | "appTitle" | "httpReferer" | "serverURL"> & {
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
/** Comma-separated marketplace categories are produced from this list. */
|
|
5
|
+
appCategories?: readonly string[];
|
|
6
|
+
appName?: string;
|
|
7
|
+
appUrl?: string;
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
tokenSource?: () => Promise<string> | string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Create OpenRouter's generated SDK with AbsoluteJS-style configuration.
|
|
13
|
+
*
|
|
14
|
+
* Use this for the complete REST surface: API keys, BYOK, guardrails,
|
|
15
|
+
* observability, organizations, SCIM, datasets, benchmarks, and future
|
|
16
|
+
* OpenAPI-generated additions. Use `openrouter()` for policy-aware inference.
|
|
17
|
+
*/
|
|
18
|
+
export declare const createOpenRouterSDK: (config?: OpenRouterSDKConfig) => OfficialOpenRouterSDK;
|
|
19
|
+
export { OfficialOpenRouterSDK as OpenRouterSDK };
|
|
20
|
+
export type { SDKOptions as OfficialOpenRouterSDKOptions } from "@openrouter/sdk";
|
|
21
|
+
export type { RequestOptions as OpenRouterSDKRequestOptions } from "@openrouter/sdk/lib/sdks.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absolutejs/ai",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.53",
|
|
4
4
|
"homepage": "https://github.com/absolutejs/ai",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/absolutejs/ai/issues"
|
|
@@ -63,6 +63,10 @@
|
|
|
63
63
|
"import": "./dist/ai/providers/openrouter.js",
|
|
64
64
|
"types": "./dist/src/ai/providers/openrouter.d.ts"
|
|
65
65
|
},
|
|
66
|
+
"./openrouter/sdk": {
|
|
67
|
+
"import": "./dist/ai/providers/openrouterSDK.js",
|
|
68
|
+
"types": "./dist/src/ai/providers/openrouterSDK.d.ts"
|
|
69
|
+
},
|
|
66
70
|
"./openai-responses": {
|
|
67
71
|
"import": "./dist/ai/providers/openaiResponses.js",
|
|
68
72
|
"types": "./dist/src/ai/providers/openaiResponses.d.ts"
|
|
@@ -85,7 +89,8 @@
|
|
|
85
89
|
}
|
|
86
90
|
},
|
|
87
91
|
"dependencies": {
|
|
88
|
-
"@absolutejs/linked-providers": "0.0.2"
|
|
92
|
+
"@absolutejs/linked-providers": "0.0.2",
|
|
93
|
+
"@openrouter/sdk": "^1.2.47"
|
|
89
94
|
},
|
|
90
95
|
"peerDependencies": {
|
|
91
96
|
"@absolutejs/isolated-jsc": ">= 0.4.0",
|
|
@@ -182,6 +187,9 @@
|
|
|
182
187
|
"openrouter": [
|
|
183
188
|
"dist/src/ai/providers/openrouter.d.ts"
|
|
184
189
|
],
|
|
190
|
+
"openrouter/sdk": [
|
|
191
|
+
"dist/src/ai/providers/openrouterSDK.d.ts"
|
|
192
|
+
],
|
|
185
193
|
"openai-responses": [
|
|
186
194
|
"dist/src/ai/providers/openaiResponses.d.ts"
|
|
187
195
|
],
|