@absolutejs/ai 0.0.51 → 0.0.52
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 +66 -7
- package/dist/ai/index.js +229 -13
- package/dist/ai/index.js.map +4 -4
- package/dist/ai/providers/openrouter.js +230 -14
- package/dist/ai/providers/openrouter.js.map +4 -4
- package/dist/src/ai/index.d.ts +2 -2
- package/dist/src/ai/providers/openrouter.d.ts +12 -3
- package/dist/src/ai/providers/openrouterClient.d.ts +367 -10
- package/package.json +1 -1
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, 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";
|
|
27
|
+
export { createOpenRouterAuthorizationUrl, createOpenRouterClient, createOpenRouterKeyLinks, estimateOpenRouterCost, estimateOpenRouterModelCost, exchangeOpenRouterAuthCode, generateOpenRouterPKCE, openrouter, openrouterMessages, openrouterResponses, openRouterModelMatchesRule, verifyOpenRouterWebhookSignature, } from "./providers/openrouter";
|
|
28
|
+
export type { OpenRouterActivityItem, OpenRouterActivityQuery, OpenRouterAnalyticsMeta, OpenRouterAnalyticsQuery, OpenRouterAnalyticsResponse, OpenRouterAuthCodeExchangeRequest, OpenRouterAuthCodeExchangeResponse, OpenRouterAutoRouterCostTier, OpenRouterAutoRouterPlugin, OpenRouterAuthorizationUrlOptions, OpenRouterBatch, OpenRouterBatchEndpoint, OpenRouterBatchRequest, OpenRouterBatchResult, OpenRouterBatchStatus, OpenRouterClient, OpenRouterClientConfig, OpenRouterConfig, OpenRouterCostEstimate, OpenRouterCostUnits, OpenRouterCreateAuthCodeRequest, OpenRouterCreateAuthCodeResponse, OpenRouterCreateBatchRequest, OpenRouterCreateWorkspaceRequest, OpenRouterDataCollection, OpenRouterEmbeddingRequest, OpenRouterEmbeddingResponse, OpenRouterFile, OpenRouterFileList, OpenRouterHttpRequestOptions, OpenRouterImageModelEndpoint, OpenRouterImageModelEndpoints, OpenRouterImageRequest, OpenRouterImageResponse, OpenRouterImageStreamEvent, OpenRouterMaxPrice, OpenRouterModel, OpenRouterModelList, OpenRouterModelQuery, OpenRouterPerformancePreference, OpenRouterPlugin, OpenRouterPKCE, OpenRouterPreset, OpenRouterPresetInferenceRequest, OpenRouterPresetResponse, OpenRouterPresetVersion, OpenRouterPresetVersionResponse, OpenRouterPricing, OpenRouterPricingKey, OpenRouterProviderRouting, OpenRouterQuantization, OpenRouterRequestOptions, OpenRouterRerankRequest, OpenRouterRerankResponse, OpenRouterResponseCache, OpenRouterResponsesRequest, OpenRouterServerTool, OpenRouterServiceTier, OpenRouterSpeechRequest, OpenRouterSort, OpenRouterSortStrategy, OpenRouterTrace, OpenRouterTaskClassifications, OpenRouterTranscriptionRequest, OpenRouterTranscriptionResponse, OpenRouterVideoJob, OpenRouterVideoRequest, OpenRouterVideoWebhookEvent, OpenRouterWorkspace, OpenRouterWorkspaceBudget, OpenRouterWorkspaceBudgetInterval, OpenRouterWorkspaceMember, OpenRouterWorkspaceOptions, 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";
|
|
@@ -72,7 +72,16 @@ export type OpenRouterAudioOutput = {
|
|
|
72
72
|
format: "wav" | "mp3" | "flac" | "opus" | "pcm16";
|
|
73
73
|
voice: string;
|
|
74
74
|
};
|
|
75
|
-
export type
|
|
75
|
+
export type OpenRouterAutoRouterCostTier = "low" | "medium" | "high" | "xhigh" | "max";
|
|
76
|
+
export type OpenRouterAutoRouterPlugin = {
|
|
77
|
+
id: "auto-router";
|
|
78
|
+
/** Restrict Auto Router candidates; omitted means the full catalog. */
|
|
79
|
+
allowed_models?: readonly string[];
|
|
80
|
+
cost_tier?: OpenRouterAutoRouterCostTier;
|
|
81
|
+
/** Legacy numeric control. When present, OpenRouter prioritizes it over cost_tier. */
|
|
82
|
+
cost_quality_tradeoff?: number;
|
|
83
|
+
};
|
|
84
|
+
export type OpenRouterPlugin = OpenRouterAutoRouterPlugin | {
|
|
76
85
|
id: string;
|
|
77
86
|
[option: string]: unknown;
|
|
78
87
|
};
|
|
@@ -153,5 +162,5 @@ export declare const openrouter: (config: OpenRouterConfig) => AIProviderConfig;
|
|
|
153
162
|
export declare const openrouterResponses: (config: OpenRouterConfig) => AIProviderConfig;
|
|
154
163
|
/** OpenRouter provider using the native Anthropic Messages protocol skin. */
|
|
155
164
|
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";
|
|
165
|
+
export { createOpenRouterAuthorizationUrl, createOpenRouterClient, createOpenRouterKeyLinks, estimateOpenRouterCost, estimateOpenRouterModelCost, exchangeOpenRouterAuthCode, generateOpenRouterPKCE, openRouterModelMatchesRule, verifyOpenRouterWebhookSignature, } from "./openrouterClient";
|
|
166
|
+
export type { OpenRouterActivityItem, OpenRouterActivityQuery, OpenRouterAnalyticsMeta, OpenRouterAnalyticsQuery, OpenRouterAnalyticsResponse, OpenRouterAuthCodeExchangeRequest, OpenRouterAuthCodeExchangeResponse, OpenRouterAuthorizationUrlOptions, OpenRouterBatch, OpenRouterBatchEndpoint, OpenRouterBatchRequest, OpenRouterBatchResult, OpenRouterBatchStatus, OpenRouterClient, OpenRouterClientConfig, OpenRouterCostEstimate, OpenRouterCostUnits, OpenRouterCreateAuthCodeRequest, OpenRouterCreateAuthCodeResponse, OpenRouterCreateBatchRequest, OpenRouterCreateWorkspaceRequest, OpenRouterEmbeddingRequest, OpenRouterEmbeddingResponse, OpenRouterFile, OpenRouterFileList, OpenRouterHttpRequestOptions, OpenRouterImageModelEndpoint, OpenRouterImageModelEndpoints, OpenRouterImageRequest, OpenRouterImageResponse, OpenRouterImageStreamEvent, OpenRouterModel, OpenRouterModelList, OpenRouterModelQuery, OpenRouterPreset, OpenRouterPresetInferenceRequest, OpenRouterPresetResponse, OpenRouterPresetVersion, OpenRouterPresetVersionResponse, OpenRouterPricing, OpenRouterPricingKey, OpenRouterPKCE, OpenRouterRerankRequest, OpenRouterRerankResponse, OpenRouterResponsesRequest, OpenRouterSpeechRequest, OpenRouterTranscriptionRequest, OpenRouterTranscriptionResponse, OpenRouterTaskClassifications, OpenRouterVideoJob, OpenRouterVideoRequest, OpenRouterVideoWebhookEvent, OpenRouterWorkspace, OpenRouterWorkspaceBudget, OpenRouterWorkspaceBudgetInterval, OpenRouterWorkspaceMember, OpenRouterWorkspaceOptions, OpenRouterZdrEndpoint, } from "./openrouterClient";
|
|
@@ -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
|
};
|
|
@@ -131,7 +227,24 @@ export type OpenRouterSpeechRequest = Record<string, unknown> & {
|
|
|
131
227
|
voice: string;
|
|
132
228
|
};
|
|
133
229
|
export type OpenRouterTranscriptionRequest = Record<string, unknown> & {
|
|
230
|
+
input_audio: {
|
|
231
|
+
data: string;
|
|
232
|
+
format: string;
|
|
233
|
+
};
|
|
234
|
+
language?: string;
|
|
134
235
|
model: string;
|
|
236
|
+
provider?: Record<string, unknown>;
|
|
237
|
+
temperature?: number;
|
|
238
|
+
};
|
|
239
|
+
export type OpenRouterTranscriptionResponse = {
|
|
240
|
+
text: string;
|
|
241
|
+
usage: {
|
|
242
|
+
cost: number;
|
|
243
|
+
input_tokens: number;
|
|
244
|
+
output_tokens: number;
|
|
245
|
+
seconds: number;
|
|
246
|
+
total_tokens: number;
|
|
247
|
+
};
|
|
135
248
|
};
|
|
136
249
|
export type OpenRouterVideoRequest = Record<string, unknown> & {
|
|
137
250
|
model: string;
|
|
@@ -189,6 +302,188 @@ export type OpenRouterZdrEndpoint = Record<string, unknown> & {
|
|
|
189
302
|
supported_parameters: string[];
|
|
190
303
|
tag: string;
|
|
191
304
|
};
|
|
305
|
+
export type OpenRouterPresetVersion = {
|
|
306
|
+
config: Record<string, unknown>;
|
|
307
|
+
created_at: string;
|
|
308
|
+
creator_id: string;
|
|
309
|
+
id: string;
|
|
310
|
+
preset_id: string;
|
|
311
|
+
system_prompt: string | null;
|
|
312
|
+
updated_at: string | null;
|
|
313
|
+
version: number;
|
|
314
|
+
};
|
|
315
|
+
export type OpenRouterPreset = {
|
|
316
|
+
created_at: string;
|
|
317
|
+
creator_user_id: string;
|
|
318
|
+
designated_version: OpenRouterPresetVersion;
|
|
319
|
+
designated_version_id: string;
|
|
320
|
+
description: string | null;
|
|
321
|
+
id: string;
|
|
322
|
+
name: string;
|
|
323
|
+
slug: string;
|
|
324
|
+
status: string;
|
|
325
|
+
status_updated_at: string | null;
|
|
326
|
+
updated_at: string | null;
|
|
327
|
+
workspace_id: string;
|
|
328
|
+
};
|
|
329
|
+
export type OpenRouterPresetResponse = {
|
|
330
|
+
data: OpenRouterPreset;
|
|
331
|
+
};
|
|
332
|
+
export type OpenRouterPresetVersionResponse = {
|
|
333
|
+
data: OpenRouterPresetVersion;
|
|
334
|
+
};
|
|
335
|
+
export type OpenRouterPresetInferenceRequest = Record<string, unknown> & {
|
|
336
|
+
model?: string;
|
|
337
|
+
models?: string[];
|
|
338
|
+
};
|
|
339
|
+
export type OpenRouterActivityQuery = {
|
|
340
|
+
api_key_hash?: string;
|
|
341
|
+
date?: string;
|
|
342
|
+
user_id?: string;
|
|
343
|
+
workspace_id?: string;
|
|
344
|
+
};
|
|
345
|
+
export type OpenRouterActivityItem = {
|
|
346
|
+
byok_usage_inference: number;
|
|
347
|
+
completion_tokens: number;
|
|
348
|
+
date: string;
|
|
349
|
+
endpoint_id: string;
|
|
350
|
+
model: string;
|
|
351
|
+
model_permaslug: string;
|
|
352
|
+
prompt_tokens: number;
|
|
353
|
+
provider_name: string;
|
|
354
|
+
reasoning_tokens: number;
|
|
355
|
+
requests: number;
|
|
356
|
+
usage: number;
|
|
357
|
+
workspace_id?: string;
|
|
358
|
+
};
|
|
359
|
+
export type OpenRouterAnalyticsQuery = {
|
|
360
|
+
metrics: [string, ...string[]];
|
|
361
|
+
dimensions?: string[];
|
|
362
|
+
filters?: Array<{
|
|
363
|
+
field: string;
|
|
364
|
+
operator: string;
|
|
365
|
+
value: unknown;
|
|
366
|
+
}>;
|
|
367
|
+
granularity?: string;
|
|
368
|
+
group_limit?: number;
|
|
369
|
+
limit?: number;
|
|
370
|
+
order_by?: {
|
|
371
|
+
direction: "asc" | "desc";
|
|
372
|
+
field: string;
|
|
373
|
+
};
|
|
374
|
+
time_range?: {
|
|
375
|
+
end: string;
|
|
376
|
+
start: string;
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
export type OpenRouterAnalyticsResponse = {
|
|
380
|
+
data: {
|
|
381
|
+
data: Record<string, unknown>[];
|
|
382
|
+
metadata: {
|
|
383
|
+
query_time_ms: number;
|
|
384
|
+
row_count: number;
|
|
385
|
+
truncated: boolean;
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
};
|
|
389
|
+
export type OpenRouterAnalyticsMeta = {
|
|
390
|
+
data: {
|
|
391
|
+
dimensions: Array<{
|
|
392
|
+
display_label: string;
|
|
393
|
+
name: string;
|
|
394
|
+
}>;
|
|
395
|
+
granularities: Array<{
|
|
396
|
+
display_label: string;
|
|
397
|
+
name: string;
|
|
398
|
+
}>;
|
|
399
|
+
metrics: Array<{
|
|
400
|
+
display_format: string;
|
|
401
|
+
display_label: string;
|
|
402
|
+
is_rate: boolean;
|
|
403
|
+
name: string;
|
|
404
|
+
}>;
|
|
405
|
+
operators: Array<{
|
|
406
|
+
name: string;
|
|
407
|
+
value_type: string;
|
|
408
|
+
}>;
|
|
409
|
+
};
|
|
410
|
+
};
|
|
411
|
+
export type OpenRouterTaskClassifications = {
|
|
412
|
+
data: {
|
|
413
|
+
as_of: string;
|
|
414
|
+
classifications: Array<{
|
|
415
|
+
category_token_share: number;
|
|
416
|
+
category_usage_share: number;
|
|
417
|
+
display_name: string;
|
|
418
|
+
macro_category: string;
|
|
419
|
+
models: Array<{
|
|
420
|
+
id: string;
|
|
421
|
+
tag_token_share: number;
|
|
422
|
+
tag_usage_share: number;
|
|
423
|
+
}>;
|
|
424
|
+
tag: string;
|
|
425
|
+
token_share: number;
|
|
426
|
+
usage_share: number;
|
|
427
|
+
}>;
|
|
428
|
+
macro_categories: Array<{
|
|
429
|
+
key: string;
|
|
430
|
+
label: string;
|
|
431
|
+
token_share: number;
|
|
432
|
+
usage_share: number;
|
|
433
|
+
}>;
|
|
434
|
+
window_days: 7;
|
|
435
|
+
};
|
|
436
|
+
};
|
|
437
|
+
export type OpenRouterWorkspace = {
|
|
438
|
+
created_at: string;
|
|
439
|
+
created_by: string;
|
|
440
|
+
default_image_model: string | null;
|
|
441
|
+
default_provider_sort: "price" | "throughput" | "latency" | "exacto" | null;
|
|
442
|
+
default_text_model: string | null;
|
|
443
|
+
description: string | null;
|
|
444
|
+
id: string;
|
|
445
|
+
io_logging_api_key_ids: number[] | null;
|
|
446
|
+
io_logging_sampling_rate: number;
|
|
447
|
+
is_data_discount_logging_enabled: boolean;
|
|
448
|
+
is_observability_broadcast_enabled: boolean;
|
|
449
|
+
is_observability_io_logging_enabled: boolean;
|
|
450
|
+
name: string;
|
|
451
|
+
slug: string;
|
|
452
|
+
updated_at: string | null;
|
|
453
|
+
};
|
|
454
|
+
export type OpenRouterWorkspaceOptions = {
|
|
455
|
+
default_image_model?: string | null;
|
|
456
|
+
default_provider_sort?: OpenRouterWorkspace["default_provider_sort"];
|
|
457
|
+
default_text_model?: string | null;
|
|
458
|
+
description?: string | null;
|
|
459
|
+
io_logging_api_key_ids?: number[] | null;
|
|
460
|
+
io_logging_sampling_rate?: number;
|
|
461
|
+
is_data_discount_logging_enabled?: boolean;
|
|
462
|
+
is_observability_broadcast_enabled?: boolean;
|
|
463
|
+
is_observability_io_logging_enabled?: boolean;
|
|
464
|
+
name?: string;
|
|
465
|
+
slug?: string;
|
|
466
|
+
};
|
|
467
|
+
export type OpenRouterCreateWorkspaceRequest = OpenRouterWorkspaceOptions & {
|
|
468
|
+
name: string;
|
|
469
|
+
slug: string;
|
|
470
|
+
};
|
|
471
|
+
export type OpenRouterWorkspaceBudgetInterval = "daily" | "weekly" | "monthly" | "lifetime";
|
|
472
|
+
export type OpenRouterWorkspaceBudget = {
|
|
473
|
+
created_at: string;
|
|
474
|
+
id: string;
|
|
475
|
+
limit_usd: number;
|
|
476
|
+
reset_interval: OpenRouterWorkspaceBudgetInterval;
|
|
477
|
+
updated_at: string | null;
|
|
478
|
+
workspace_id: string;
|
|
479
|
+
};
|
|
480
|
+
export type OpenRouterWorkspaceMember = {
|
|
481
|
+
created_at: string;
|
|
482
|
+
id: string;
|
|
483
|
+
role: string;
|
|
484
|
+
user_id: string;
|
|
485
|
+
workspace_id: string;
|
|
486
|
+
};
|
|
192
487
|
export type OpenRouterHttpRequestOptions = Omit<RequestInit, "body" | "headers"> & {
|
|
193
488
|
body?: unknown;
|
|
194
489
|
headers?: HeadersInit;
|
|
@@ -196,6 +491,18 @@ export type OpenRouterHttpRequestOptions = Omit<RequestInit, "body" | "headers">
|
|
|
196
491
|
};
|
|
197
492
|
export type OpenRouterClient = ReturnType<typeof createOpenRouterClient>;
|
|
198
493
|
export declare const openRouterModelMatchesRule: (model: string, rule: string) => boolean;
|
|
494
|
+
export declare const generateOpenRouterPKCE: () => Promise<OpenRouterPKCE>;
|
|
495
|
+
export declare const createOpenRouterAuthorizationUrl: (options?: OpenRouterAuthorizationUrlOptions) => string;
|
|
496
|
+
/** Exchange a single-use OAuth code. This endpoint intentionally has no API-key authentication. */
|
|
497
|
+
export declare const exchangeOpenRouterAuthCode: (body: OpenRouterAuthCodeExchangeRequest, options?: {
|
|
498
|
+
baseUrl?: string;
|
|
499
|
+
fetch?: typeof globalThis.fetch;
|
|
500
|
+
}) => Promise<OpenRouterAuthCodeExchangeResponse>;
|
|
501
|
+
export declare const createOpenRouterKeyLinks: (key: string, siteUrl?: string) => Promise<{
|
|
502
|
+
hash: string;
|
|
503
|
+
logsUrl: string;
|
|
504
|
+
settingsUrl: string;
|
|
505
|
+
}>;
|
|
199
506
|
/** Verify `X-OpenRouter-Signature` against the exact raw webhook bytes. */
|
|
200
507
|
export declare const verifyOpenRouterWebhookSignature: (options: {
|
|
201
508
|
body: string | Uint8Array;
|
|
@@ -205,34 +512,61 @@ export declare const verifyOpenRouterWebhookSignature: (options: {
|
|
|
205
512
|
toleranceSeconds?: number;
|
|
206
513
|
}) => Promise<boolean>;
|
|
207
514
|
export declare const createOpenRouterClient: (config: OpenRouterClientConfig) => {
|
|
208
|
-
|
|
209
|
-
|
|
515
|
+
addWorkspaceMembers: (id: string, userIds: readonly string[]) => Promise<{
|
|
516
|
+
added_count: number;
|
|
517
|
+
data: OpenRouterWorkspaceMember[];
|
|
518
|
+
}>;
|
|
519
|
+
createAuthCode: (body: OpenRouterCreateAuthCodeRequest) => Promise<OpenRouterCreateAuthCodeResponse>;
|
|
520
|
+
createPresetFromChatCompletions: (slug: string, body: OpenRouterPresetInferenceRequest) => Promise<OpenRouterPresetResponse>;
|
|
521
|
+
createPresetFromMessages: (slug: string, body: OpenRouterPresetInferenceRequest) => Promise<OpenRouterPresetResponse>;
|
|
522
|
+
createPresetFromResponses: (slug: string, body: OpenRouterPresetInferenceRequest) => Promise<OpenRouterPresetResponse>;
|
|
523
|
+
createWorkspace: (body: OpenRouterCreateWorkspaceRequest) => Promise<{
|
|
524
|
+
data: OpenRouterWorkspace;
|
|
525
|
+
}>;
|
|
526
|
+
createBatch: (body: OpenRouterCreateBatchRequest) => Promise<OpenRouterBatch>;
|
|
210
527
|
createEmbedding: (body: OpenRouterEmbeddingRequest) => Promise<OpenRouterEmbeddingResponse>;
|
|
211
528
|
generateImage: (body: OpenRouterImageRequest) => Promise<OpenRouterImageResponse>;
|
|
212
|
-
deleteFile: (id: string, workspaceId?: string) => Promise<{
|
|
529
|
+
deleteFile: (id: string, workspaceId?: string | undefined) => Promise<{
|
|
213
530
|
id: string;
|
|
214
531
|
type: "file_deleted";
|
|
215
532
|
}>;
|
|
216
|
-
|
|
533
|
+
deleteWorkspace: (id: string) => Promise<{
|
|
534
|
+
deleted: true;
|
|
535
|
+
}>;
|
|
536
|
+
deleteWorkspaceBudget: (id: string, interval: OpenRouterWorkspaceBudgetInterval) => Promise<{
|
|
537
|
+
deleted: true;
|
|
538
|
+
}>;
|
|
539
|
+
downloadFile: (id: string, workspaceId?: string | undefined) => Promise<Response>;
|
|
217
540
|
downloadVideo: (id: string, index?: number) => Promise<Response>;
|
|
218
541
|
generateVideo: (body: OpenRouterVideoRequest) => Promise<OpenRouterVideoJob>;
|
|
219
|
-
getBatch: (id: string) => Promise<
|
|
542
|
+
getBatch: (id: string) => Promise<OpenRouterBatch>;
|
|
543
|
+
getActivity: (query?: OpenRouterActivityQuery) => Promise<{
|
|
544
|
+
data: OpenRouterActivityItem[];
|
|
545
|
+
}>;
|
|
546
|
+
getAnalyticsMeta: () => Promise<OpenRouterAnalyticsMeta>;
|
|
220
547
|
getCredits: () => Promise<{
|
|
221
548
|
data: Record<string, number>;
|
|
222
549
|
}>;
|
|
223
550
|
getCurrentKey: () => Promise<{
|
|
224
551
|
data: Record<string, unknown>;
|
|
225
552
|
}>;
|
|
226
|
-
getFile: (id: string, workspaceId?: string) => Promise<OpenRouterFile>;
|
|
553
|
+
getFile: (id: string, workspaceId?: string | undefined) => Promise<OpenRouterFile>;
|
|
227
554
|
getGeneration: (id: string) => Promise<{
|
|
228
555
|
data: Record<string, unknown>;
|
|
229
556
|
}>;
|
|
557
|
+
getGenerationContent: (id: string) => Promise<Record<string, unknown>>;
|
|
230
558
|
getModelEndpoints: (model: string) => Promise<Record<string, unknown>>;
|
|
231
559
|
getModel: (model: string) => Promise<{
|
|
232
560
|
data: OpenRouterModel;
|
|
233
561
|
}>;
|
|
234
562
|
getImageModelEndpoints: (model: string) => Promise<OpenRouterImageModelEndpoints>;
|
|
563
|
+
getPreset: (slug: string) => Promise<OpenRouterPresetResponse>;
|
|
564
|
+
getPresetVersion: (slug: string, version: number | string) => Promise<OpenRouterPresetVersionResponse>;
|
|
565
|
+
getTaskClassifications: (window?: "7d") => Promise<OpenRouterTaskClassifications>;
|
|
235
566
|
getVideo: (id: string) => Promise<OpenRouterVideoJob>;
|
|
567
|
+
getWorkspace: (id: string) => Promise<{
|
|
568
|
+
data: OpenRouterWorkspace;
|
|
569
|
+
}>;
|
|
236
570
|
listImageModels: () => Promise<OpenRouterModelList>;
|
|
237
571
|
listFiles: (query?: {
|
|
238
572
|
cursor?: string;
|
|
@@ -250,11 +584,11 @@ export declare const createOpenRouterClient: (config: OpenRouterClientConfig) =>
|
|
|
250
584
|
};
|
|
251
585
|
}>;
|
|
252
586
|
listPresets: (offset?: number, limit?: number) => Promise<{
|
|
253
|
-
data:
|
|
587
|
+
data: OpenRouterPreset[];
|
|
254
588
|
total_count: number;
|
|
255
589
|
}>;
|
|
256
590
|
listPresetVersions: (slug: string, offset?: number, limit?: number) => Promise<{
|
|
257
|
-
data:
|
|
591
|
+
data: OpenRouterPresetVersion[];
|
|
258
592
|
total_count: number;
|
|
259
593
|
}>;
|
|
260
594
|
listProviders: () => Promise<{
|
|
@@ -262,15 +596,38 @@ export declare const createOpenRouterClient: (config: OpenRouterClientConfig) =>
|
|
|
262
596
|
}>;
|
|
263
597
|
listRerankModels: () => Promise<OpenRouterModelList>;
|
|
264
598
|
listVideoModels: () => Promise<OpenRouterModelList>;
|
|
599
|
+
listWorkspaceBudgets: (id: string) => Promise<{
|
|
600
|
+
data: OpenRouterWorkspaceBudget[];
|
|
601
|
+
}>;
|
|
602
|
+
listWorkspaces: (offset?: number, limit?: number) => Promise<{
|
|
603
|
+
data: OpenRouterWorkspace[];
|
|
604
|
+
total_count: number;
|
|
605
|
+
}>;
|
|
606
|
+
queryAnalytics: (body: OpenRouterAnalyticsQuery) => Promise<OpenRouterAnalyticsResponse>;
|
|
607
|
+
removeWorkspaceMembers: (id: string, userIds: readonly string[]) => Promise<{
|
|
608
|
+
data: OpenRouterWorkspaceMember[];
|
|
609
|
+
removed_count: number;
|
|
610
|
+
}>;
|
|
265
611
|
request: <T>(path: string, options?: OpenRouterHttpRequestOptions) => Promise<T>;
|
|
266
612
|
requestRaw: (path: string, options?: OpenRouterHttpRequestOptions) => Promise<Response>;
|
|
267
613
|
streamImage: (body: Omit<OpenRouterImageRequest, "stream">, options?: Omit<OpenRouterHttpRequestOptions, "body" | "method">) => AsyncGenerator<OpenRouterImageStreamEvent, void, any>;
|
|
268
614
|
respond: (body: OpenRouterResponsesRequest) => Promise<Response> | Promise<Record<string, unknown>>;
|
|
269
615
|
rerank: (body: OpenRouterRerankRequest) => Promise<OpenRouterRerankResponse>;
|
|
270
616
|
speak: (body: OpenRouterSpeechRequest) => Promise<Response>;
|
|
271
|
-
transcribe: (body: OpenRouterTranscriptionRequest | FormData) => Promise<
|
|
617
|
+
transcribe: (body: OpenRouterTranscriptionRequest | FormData) => Promise<OpenRouterTranscriptionResponse>;
|
|
272
618
|
uploadFile: (file: Blob, options?: {
|
|
273
619
|
filename?: string;
|
|
274
620
|
workspaceId?: string;
|
|
275
621
|
}) => Promise<OpenRouterFile>;
|
|
622
|
+
updateWorkspace: (id: string, body: OpenRouterWorkspaceOptions) => Promise<{
|
|
623
|
+
data: OpenRouterWorkspace;
|
|
624
|
+
}>;
|
|
625
|
+
upsertWorkspaceBudget: (id: string, interval: OpenRouterWorkspaceBudgetInterval, limitUsd: number) => Promise<{
|
|
626
|
+
data: OpenRouterWorkspaceBudget;
|
|
627
|
+
}>;
|
|
628
|
+
waitForBatch: (id: string, options?: {
|
|
629
|
+
intervalMs?: number;
|
|
630
|
+
signal?: AbortSignal;
|
|
631
|
+
timeoutMs?: number;
|
|
632
|
+
}) => Promise<OpenRouterBatch>;
|
|
276
633
|
};
|