llm-strings 1.4.0 → 1.5.1

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/ai-sdk.cjs CHANGED
@@ -1,1176 +1 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/ai-sdk.ts
21
- var ai_sdk_exports = {};
22
- __export(ai_sdk_exports, {
23
- createAiSdkProviderOptions: () => createAiSdkProviderOptions
24
- });
25
- module.exports = __toCommonJS(ai_sdk_exports);
26
-
27
- // src/provider-core.ts
28
- function hasOwn(object, key) {
29
- return Object.prototype.hasOwnProperty.call(object, key);
30
- }
31
- var HOST_ALIASES = {
32
- openai: "api.openai.com",
33
- azure: "models.inference.ai.azure.com",
34
- anthropic: "api.anthropic.com",
35
- google: "generativelanguage.googleapis.com",
36
- "google-vertex": "aiplatform.googleapis.com",
37
- aistudio: "generativelanguage.googleapis.com",
38
- mistral: "api.mistral.ai",
39
- cohere: "api.cohere.com",
40
- bedrock: "bedrock-runtime.us-east-1.amazonaws.com",
41
- openrouter: "openrouter.ai",
42
- vercel: "gateway.ai.vercel.app",
43
- alibaba: "dashscope-intl.aliyuncs.com",
44
- alibabacloud: "dashscope-intl.aliyuncs.com",
45
- dashscope: "dashscope-intl.aliyuncs.com",
46
- groq: "api.groq.com",
47
- fal: "fal.run",
48
- fireworks: "api.fireworks.ai",
49
- fireworksai: "api.fireworks.ai",
50
- "black-forest-labs": "api.bfl.ai",
51
- bfl: "api.bfl.ai",
52
- deepseek: "api.deepseek.com",
53
- moonshotai: "api.moonshot.ai",
54
- moonshot: "api.moonshot.ai",
55
- perplexity: "api.perplexity.ai",
56
- venice: "api.venice.ai",
57
- parasail: "api.parasail.io",
58
- deepinfra: "api.deepinfra.com",
59
- atlascloud: "api.atlascloud.ai",
60
- novita: "api.novita.ai",
61
- novitaai: "api.novita.ai",
62
- grok: "api.x.ai",
63
- xai: "api.x.ai",
64
- together: "api.together.xyz",
65
- togetherai: "api.together.xyz",
66
- cerebras: "api.cerebras.ai",
67
- replicate: "api.replicate.com",
68
- prodia: "api.prodia.com",
69
- luma: "api.lumalabs.ai",
70
- bytedance: "ark.cn-beijing.volces.com",
71
- kling: "api.klingai.com",
72
- elevenlabs: "api.elevenlabs.io",
73
- assemblyai: "api.assemblyai.com",
74
- deepgram: "api.deepgram.com",
75
- gladia: "api.gladia.io",
76
- lmnt: "api.lmnt.com",
77
- hume: "api.hume.ai",
78
- revai: "api.rev.ai",
79
- baseten: "api.baseten.co",
80
- huggingface: "api-inference.huggingface.co",
81
- wandb: "api.inference.wandb.ai",
82
- weightsandbiases: "api.inference.wandb.ai",
83
- baidu: "qianfan.baidubce.com",
84
- qianfan: "qianfan.baidubce.com",
85
- vertex: "aiplatform.googleapis.com",
86
- xiaomi: "api.xiaomimimo.com",
87
- minimax: "api.minimax.io"
88
- };
89
- var HOST_ALIAS_PROVIDERS = {
90
- aistudio: "google",
91
- vertex: "google-vertex",
92
- grok: "xai",
93
- bfl: "black-forest-labs",
94
- moonshot: "moonshotai",
95
- alibaba: "alibaba",
96
- alibabacloud: "alibaba",
97
- dashscope: "alibaba",
98
- togetherai: "together",
99
- fireworksai: "fireworks"
100
- };
101
- function readProcessEnv() {
102
- return typeof process !== "undefined" && process.env ? process.env : {};
103
- }
104
- function normalizeHostValue(value) {
105
- const trimmed = value.trim();
106
- if (!trimmed) return trimmed;
107
- try {
108
- if (trimmed.includes("://")) {
109
- return new URL(trimmed).host;
110
- }
111
- } catch {
112
- }
113
- return trimmed.replace(/^\/\//, "").split("/")[0] ?? trimmed;
114
- }
115
- function envHostOverride(alias, env) {
116
- const upper = alias.toUpperCase();
117
- const override = env[`LLM_STRINGS_${upper}_HOST`] ?? env[`LLM_STRINGS_HOST_${upper}`];
118
- return override?.trim() ? override : void 0;
119
- }
120
- function resolveHostAlias(host, env = readProcessEnv()) {
121
- const normalizedHost = host.toLowerCase();
122
- if (!hasOwn(HOST_ALIASES, normalizedHost)) {
123
- return { host };
124
- }
125
- const alias = normalizedHost;
126
- const override = envHostOverride(alias, env);
127
- return {
128
- host: normalizeHostValue(override ?? HOST_ALIASES[alias]),
129
- alias
130
- };
131
- }
132
- function providerFromHostAlias(alias) {
133
- const normalizedAlias = alias.toLowerCase();
134
- if (hasOwn(PROVIDER_PARAMS, normalizedAlias)) {
135
- return normalizedAlias;
136
- }
137
- if (hasOwn(HOST_ALIAS_PROVIDERS, normalizedAlias)) {
138
- return HOST_ALIAS_PROVIDERS[normalizedAlias];
139
- }
140
- return void 0;
141
- }
142
- function detectProvider(host) {
143
- host = host.toLowerCase();
144
- if (host.includes("openrouter")) return "openrouter";
145
- if (host.includes("gateway.ai.vercel")) return "vercel";
146
- if (host.includes("amazonaws") || host.includes("bedrock")) return "bedrock";
147
- if (host.includes("aiplatform.googleapis")) return "google-vertex";
148
- if (host.includes("api.x.ai")) return "xai";
149
- if (host.includes("groq")) return "groq";
150
- if (host.includes("fal.run") || host.includes("fal.ai")) return "fal";
151
- if (host.includes("deepinfra")) return "deepinfra";
152
- if (host.includes("bfl.ai")) return "black-forest-labs";
153
- if (host.includes("together")) return "together";
154
- if (host.includes("fireworks")) return "fireworks";
155
- if (host.includes("deepseek")) return "deepseek";
156
- if (host.includes("moonshot")) return "moonshotai";
157
- if (host.includes("perplexity")) return "perplexity";
158
- if (host.includes("dashscope") || host.includes("aliyuncs")) return "alibaba";
159
- if (host.includes("cerebras")) return "cerebras";
160
- if (host.includes("replicate")) return "replicate";
161
- if (host.includes("prodia")) return "prodia";
162
- if (host.includes("lumalabs") || host.includes("luma")) return "luma";
163
- if (host.includes("volces") || host.includes("bytedance")) return "bytedance";
164
- if (host.includes("kling")) return "kling";
165
- if (host.includes("elevenlabs")) return "elevenlabs";
166
- if (host.includes("assemblyai")) return "assemblyai";
167
- if (host.includes("deepgram")) return "deepgram";
168
- if (host.includes("gladia")) return "gladia";
169
- if (host.includes("lmnt")) return "lmnt";
170
- if (host.includes("hume")) return "hume";
171
- if (host.includes("rev.ai")) return "revai";
172
- if (host.includes("baseten")) return "baseten";
173
- if (host.includes("huggingface")) return "huggingface";
174
- if (host.includes("azure")) return "azure";
175
- if (host.includes("openai")) return "openai";
176
- if (host.includes("anthropic") || host.includes("claude")) return "anthropic";
177
- if (host.includes("googleapis") || host.includes("google")) return "google";
178
- if (host.includes("mistral")) return "mistral";
179
- if (host.includes("cohere")) return "cohere";
180
- return void 0;
181
- }
182
- var ALIASES = {
183
- // temperature
184
- temp: "temperature",
185
- // max_tokens
186
- max: "max_tokens",
187
- max_out: "max_tokens",
188
- max_output: "max_tokens",
189
- max_output_tokens: "max_tokens",
190
- max_completion_tokens: "max_tokens",
191
- maxOutputTokens: "max_tokens",
192
- maxTokens: "max_tokens",
193
- // top_p
194
- topp: "top_p",
195
- topP: "top_p",
196
- nucleus: "top_p",
197
- // top_k
198
- topk: "top_k",
199
- topK: "top_k",
200
- // frequency_penalty
201
- freq: "frequency_penalty",
202
- freq_penalty: "frequency_penalty",
203
- frequencyPenalty: "frequency_penalty",
204
- repetition_penalty: "frequency_penalty",
205
- // presence_penalty
206
- pres: "presence_penalty",
207
- pres_penalty: "presence_penalty",
208
- presencePenalty: "presence_penalty",
209
- // stop
210
- stop_sequences: "stop",
211
- stopSequences: "stop",
212
- stop_sequence: "stop",
213
- // seed
214
- random_seed: "seed",
215
- randomSeed: "seed",
216
- // n (completions count)
217
- candidateCount: "n",
218
- candidate_count: "n",
219
- num_completions: "n",
220
- // effort / reasoning
221
- reasoning_effort: "effort",
222
- reasoning: "effort",
223
- // cache
224
- cache_control: "cache",
225
- cacheControl: "cache",
226
- cachePoint: "cache",
227
- cache_point: "cache"
228
- };
229
- var OPENAI_COMPATIBLE_PARAMS = {
230
- temperature: "temperature",
231
- max_tokens: "max_tokens",
232
- top_p: "top_p",
233
- top_k: "top_k",
234
- frequency_penalty: "frequency_penalty",
235
- presence_penalty: "presence_penalty",
236
- stop: "stop",
237
- n: "n",
238
- seed: "seed",
239
- stream: "stream",
240
- effort: "reasoning_effort"
241
- };
242
- var GOOGLE_COMPATIBLE_PARAMS = {
243
- temperature: "temperature",
244
- max_tokens: "maxOutputTokens",
245
- top_p: "topP",
246
- top_k: "topK",
247
- frequency_penalty: "frequencyPenalty",
248
- presence_penalty: "presencePenalty",
249
- stop: "stopSequences",
250
- n: "candidateCount",
251
- stream: "stream",
252
- seed: "seed",
253
- responseMimeType: "responseMimeType",
254
- responseSchema: "responseSchema"
255
- };
256
- var PROVIDER_PARAMS = {
257
- openai: {
258
- temperature: "temperature",
259
- max_tokens: "max_tokens",
260
- top_p: "top_p",
261
- frequency_penalty: "frequency_penalty",
262
- presence_penalty: "presence_penalty",
263
- stop: "stop",
264
- n: "n",
265
- seed: "seed",
266
- stream: "stream",
267
- effort: "reasoning_effort"
268
- },
269
- azure: OPENAI_COMPATIBLE_PARAMS,
270
- anthropic: {
271
- temperature: "temperature",
272
- max_tokens: "max_tokens",
273
- top_p: "top_p",
274
- top_k: "top_k",
275
- stop: "stop_sequences",
276
- stream: "stream",
277
- effort: "effort",
278
- cache: "cache_control",
279
- cache_ttl: "cache_ttl"
280
- },
281
- google: {
282
- temperature: "temperature",
283
- max_tokens: "maxOutputTokens",
284
- top_p: "topP",
285
- top_k: "topK",
286
- frequency_penalty: "frequencyPenalty",
287
- presence_penalty: "presencePenalty",
288
- stop: "stopSequences",
289
- n: "candidateCount",
290
- stream: "stream",
291
- seed: "seed",
292
- responseMimeType: "responseMimeType",
293
- responseSchema: "responseSchema"
294
- },
295
- "google-vertex": GOOGLE_COMPATIBLE_PARAMS,
296
- mistral: {
297
- temperature: "temperature",
298
- max_tokens: "max_tokens",
299
- top_p: "top_p",
300
- frequency_penalty: "frequency_penalty",
301
- presence_penalty: "presence_penalty",
302
- stop: "stop",
303
- n: "n",
304
- seed: "random_seed",
305
- stream: "stream",
306
- safe_prompt: "safe_prompt",
307
- min_tokens: "min_tokens"
308
- },
309
- cohere: {
310
- temperature: "temperature",
311
- max_tokens: "max_tokens",
312
- top_p: "p",
313
- top_k: "k",
314
- frequency_penalty: "frequency_penalty",
315
- presence_penalty: "presence_penalty",
316
- stop: "stop_sequences",
317
- stream: "stream",
318
- seed: "seed"
319
- },
320
- bedrock: {
321
- // Bedrock Converse API uses camelCase
322
- temperature: "temperature",
323
- max_tokens: "maxTokens",
324
- top_p: "topP",
325
- top_k: "topK",
326
- // Claude models via additionalModelRequestFields
327
- stop: "stopSequences",
328
- stream: "stream",
329
- cache: "cache_control",
330
- cache_ttl: "cache_ttl"
331
- },
332
- openrouter: {
333
- // OpenAI-compatible API with extra routing params
334
- temperature: "temperature",
335
- max_tokens: "max_tokens",
336
- top_p: "top_p",
337
- top_k: "top_k",
338
- frequency_penalty: "frequency_penalty",
339
- presence_penalty: "presence_penalty",
340
- stop: "stop",
341
- n: "n",
342
- seed: "seed",
343
- stream: "stream",
344
- effort: "reasoning_effort"
345
- },
346
- vercel: {
347
- // OpenAI-compatible gateway
348
- temperature: "temperature",
349
- max_tokens: "max_tokens",
350
- top_p: "top_p",
351
- top_k: "top_k",
352
- frequency_penalty: "frequency_penalty",
353
- presence_penalty: "presence_penalty",
354
- stop: "stop",
355
- n: "n",
356
- seed: "seed",
357
- stream: "stream",
358
- effort: "reasoning_effort"
359
- },
360
- xai: OPENAI_COMPATIBLE_PARAMS,
361
- groq: OPENAI_COMPATIBLE_PARAMS,
362
- fal: {},
363
- deepinfra: OPENAI_COMPATIBLE_PARAMS,
364
- "black-forest-labs": {},
365
- together: OPENAI_COMPATIBLE_PARAMS,
366
- fireworks: OPENAI_COMPATIBLE_PARAMS,
367
- deepseek: OPENAI_COMPATIBLE_PARAMS,
368
- moonshotai: OPENAI_COMPATIBLE_PARAMS,
369
- perplexity: OPENAI_COMPATIBLE_PARAMS,
370
- alibaba: OPENAI_COMPATIBLE_PARAMS,
371
- cerebras: OPENAI_COMPATIBLE_PARAMS,
372
- replicate: {},
373
- prodia: {},
374
- luma: {},
375
- bytedance: {},
376
- kling: {},
377
- elevenlabs: {},
378
- assemblyai: {},
379
- deepgram: {},
380
- gladia: {},
381
- lmnt: {},
382
- hume: {},
383
- revai: {},
384
- baseten: OPENAI_COMPATIBLE_PARAMS,
385
- huggingface: OPENAI_COMPATIBLE_PARAMS
386
- };
387
- function isReasoningModel(model) {
388
- const name = model.includes("/") ? model.split("/").pop() : model;
389
- return /^o[134]/.test(name);
390
- }
391
- function canHostOpenAIModels(provider) {
392
- return provider === "openai" || provider === "openrouter" || provider === "vercel";
393
- }
394
- function isGatewayProvider(provider) {
395
- return provider === "openrouter" || provider === "vercel";
396
- }
397
- function detectGatewaySubProvider(model) {
398
- const slash = model.indexOf("/");
399
- if (slash < 1) return void 0;
400
- const prefix = model.slice(0, slash);
401
- const direct = [
402
- "openai",
403
- "anthropic",
404
- "google",
405
- "mistral",
406
- "cohere"
407
- ];
408
- return direct.find((p) => p === prefix);
409
- }
410
- function detectBedrockModelFamily(model) {
411
- const parts = model.split(".");
412
- let prefix = parts[0];
413
- if (["us", "eu", "apac", "global"].includes(prefix) && parts.length > 1) {
414
- prefix = parts[1];
415
- }
416
- const families = [
417
- "anthropic",
418
- "meta",
419
- "amazon",
420
- "mistral",
421
- "cohere",
422
- "ai21"
423
- ];
424
- return families.find((f) => prefix === f);
425
- }
426
- function bedrockSupportsCaching(model) {
427
- const family = detectBedrockModelFamily(model);
428
- if (family === "anthropic") return true;
429
- if (family === "amazon" && model.includes("nova")) return true;
430
- return false;
431
- }
432
- var CACHE_VALUES = {
433
- openai: void 0,
434
- // OpenAI auto-caches; no explicit param
435
- azure: void 0,
436
- anthropic: "ephemeral",
437
- google: void 0,
438
- // Google uses explicit caching API, not a param
439
- "google-vertex": void 0,
440
- mistral: void 0,
441
- cohere: void 0,
442
- bedrock: "ephemeral",
443
- // Supported for Claude models on Bedrock
444
- openrouter: void 0,
445
- // Depends on underlying provider
446
- vercel: void 0,
447
- // Depends on underlying provider
448
- xai: void 0,
449
- groq: void 0,
450
- fal: void 0,
451
- deepinfra: void 0,
452
- "black-forest-labs": void 0,
453
- together: void 0,
454
- fireworks: void 0,
455
- deepseek: void 0,
456
- moonshotai: void 0,
457
- perplexity: void 0,
458
- alibaba: void 0,
459
- cerebras: void 0,
460
- replicate: void 0,
461
- prodia: void 0,
462
- luma: void 0,
463
- bytedance: void 0,
464
- kling: void 0,
465
- elevenlabs: void 0,
466
- assemblyai: void 0,
467
- deepgram: void 0,
468
- gladia: void 0,
469
- lmnt: void 0,
470
- hume: void 0,
471
- revai: void 0,
472
- baseten: void 0,
473
- huggingface: void 0
474
- };
475
- var CACHE_TTLS = {
476
- openai: void 0,
477
- azure: void 0,
478
- anthropic: ["5m", "1h"],
479
- google: void 0,
480
- "google-vertex": void 0,
481
- mistral: void 0,
482
- cohere: void 0,
483
- bedrock: ["5m", "1h"],
484
- // Claude on Bedrock uses same TTLs as direct Anthropic
485
- openrouter: void 0,
486
- vercel: void 0,
487
- xai: void 0,
488
- groq: void 0,
489
- fal: void 0,
490
- deepinfra: void 0,
491
- "black-forest-labs": void 0,
492
- together: void 0,
493
- fireworks: void 0,
494
- deepseek: void 0,
495
- moonshotai: void 0,
496
- perplexity: void 0,
497
- alibaba: void 0,
498
- cerebras: void 0,
499
- replicate: void 0,
500
- prodia: void 0,
501
- luma: void 0,
502
- bytedance: void 0,
503
- kling: void 0,
504
- elevenlabs: void 0,
505
- assemblyai: void 0,
506
- deepgram: void 0,
507
- gladia: void 0,
508
- lmnt: void 0,
509
- hume: void 0,
510
- revai: void 0,
511
- baseten: void 0,
512
- huggingface: void 0
513
- };
514
- var DURATION_RE = /^\d+[mh]$/;
515
-
516
- // src/normalize.ts
517
- function normalize(config, options = {}) {
518
- const provider = (config.hostAlias ? providerFromHostAlias(config.hostAlias) : void 0) ?? detectProvider(config.host);
519
- const subProvider = provider && isGatewayProvider(provider) ? detectGatewaySubProvider(config.model) : void 0;
520
- const changes = [];
521
- const params = {};
522
- for (const [rawKey, value] of Object.entries(config.params)) {
523
- let key = rawKey;
524
- if (ALIASES[key]) {
525
- const canonical = ALIASES[key];
526
- if (options.verbose) {
527
- changes.push({
528
- from: key,
529
- to: canonical,
530
- value,
531
- reason: `alias: "${key}" \u2192 "${canonical}"`
532
- });
533
- }
534
- key = canonical;
535
- }
536
- if (key === "cache" && provider) {
537
- let cacheValue = CACHE_VALUES[provider];
538
- if (provider === "bedrock" && !bedrockSupportsCaching(config.model)) {
539
- cacheValue = void 0;
540
- }
541
- if (!cacheValue) {
542
- if (options.verbose) {
543
- changes.push({
544
- from: "cache",
545
- to: "(dropped)",
546
- value,
547
- reason: `${provider} does not use a cache param for this model (caching is automatic or unsupported)`
548
- });
549
- }
550
- continue;
551
- }
552
- const isBool = value === "true" || value === "1" || value === "yes";
553
- const isDuration = DURATION_RE.test(value);
554
- if (isBool || isDuration) {
555
- const providerKey = PROVIDER_PARAMS[provider]?.["cache"] ?? "cache";
556
- if (options.verbose) {
557
- changes.push({
558
- from: "cache",
559
- to: providerKey,
560
- value: cacheValue,
561
- reason: `cache=${value} \u2192 ${providerKey}=${cacheValue} for ${provider}`
562
- });
563
- }
564
- params[providerKey] = cacheValue;
565
- if (isDuration && CACHE_TTLS[provider]) {
566
- if (options.verbose) {
567
- changes.push({
568
- from: "cache",
569
- to: "cache_ttl",
570
- value,
571
- reason: `cache=${value} \u2192 cache_ttl=${value} for ${provider}`
572
- });
573
- }
574
- params["cache_ttl"] = value;
575
- }
576
- continue;
577
- }
578
- }
579
- if (provider && PROVIDER_PARAMS[provider]) {
580
- const providerKey = PROVIDER_PARAMS[provider][key];
581
- if (providerKey && providerKey !== key) {
582
- if (options.verbose) {
583
- changes.push({
584
- from: key,
585
- to: providerKey,
586
- value,
587
- reason: `${provider} uses "${providerKey}" instead of "${key}"`
588
- });
589
- }
590
- key = providerKey;
591
- }
592
- }
593
- if (provider && canHostOpenAIModels(provider) && isReasoningModel(config.model) && key === "max_tokens") {
594
- if (options.verbose) {
595
- changes.push({
596
- from: "max_tokens",
597
- to: "max_completion_tokens",
598
- value,
599
- reason: "OpenAI reasoning models use max_completion_tokens instead of max_tokens"
600
- });
601
- }
602
- key = "max_completion_tokens";
603
- }
604
- params[key] = value;
605
- }
606
- return {
607
- config: { ...config, params },
608
- provider,
609
- subProvider,
610
- changes
611
- };
612
- }
613
-
614
- // src/parse.ts
615
- function parse(connectionString) {
616
- const url = new URL(connectionString);
617
- if (url.protocol !== "llm:") {
618
- throw new Error(
619
- `Invalid scheme: expected "llm://", got "${url.protocol}//"`
620
- );
621
- }
622
- const { host, alias: hostAlias } = resolveHostAlias(url.host);
623
- const model = url.pathname.replace(/^\//, "");
624
- const label = url.username || void 0;
625
- const apiKey = url.password || void 0;
626
- const params = {};
627
- for (const [key, value] of url.searchParams) {
628
- params[key] = value;
629
- }
630
- return {
631
- raw: connectionString,
632
- host,
633
- hostAlias,
634
- model,
635
- label,
636
- apiKey,
637
- params
638
- };
639
- }
640
-
641
- // src/ai-sdk.ts
642
- var PROVIDER_OPTION_KEYS = {
643
- openai: "openai",
644
- azure: "azure",
645
- anthropic: "anthropic",
646
- google: "google",
647
- "google-vertex": "vertex",
648
- mistral: "mistral",
649
- cohere: "cohere",
650
- bedrock: "bedrock",
651
- openrouter: "openrouter",
652
- vercel: "gateway",
653
- xai: "xai",
654
- groq: "groq",
655
- fal: "fal",
656
- deepinfra: "deepinfra",
657
- "black-forest-labs": "blackForestLabs",
658
- together: "together",
659
- fireworks: "fireworks",
660
- deepseek: "deepseek",
661
- moonshotai: "moonshotai",
662
- perplexity: "perplexity",
663
- alibaba: "alibaba",
664
- cerebras: "cerebras",
665
- replicate: "replicate",
666
- prodia: "prodia",
667
- luma: "luma",
668
- bytedance: "bytedance",
669
- kling: "kling",
670
- elevenlabs: "elevenlabs",
671
- assemblyai: "assemblyai",
672
- deepgram: "deepgram",
673
- gladia: "gladia",
674
- lmnt: "lmnt",
675
- hume: "hume",
676
- revai: "revai",
677
- baseten: "baseten",
678
- huggingface: "huggingface"
679
- };
680
- var TRUE_VALUES = /* @__PURE__ */ new Set(["true", "1", "yes", "on"]);
681
- var FALSE_VALUES = /* @__PURE__ */ new Set(["false", "0", "no", "off"]);
682
- function providerOptionsKey(provider) {
683
- return PROVIDER_OPTION_KEYS[provider];
684
- }
685
- function setProviderOption(options, provider, key, value) {
686
- options[provider] ?? (options[provider] = {});
687
- options[provider][key] = value;
688
- }
689
- function parseBoolean(value) {
690
- const normalized = value.trim().toLowerCase();
691
- if (TRUE_VALUES.has(normalized)) return true;
692
- if (FALSE_VALUES.has(normalized)) return false;
693
- return void 0;
694
- }
695
- function parseNumber(value) {
696
- if (!value.trim()) return void 0;
697
- const parsed = Number(value);
698
- return Number.isFinite(parsed) ? parsed : void 0;
699
- }
700
- function parseJson(value) {
701
- try {
702
- return JSON.parse(value);
703
- } catch {
704
- return void 0;
705
- }
706
- }
707
- function parseStringList(value) {
708
- const json = parseJson(value);
709
- if (Array.isArray(json)) {
710
- return json.filter((item) => typeof item === "string");
711
- }
712
- return value.split(",").map((item) => item.trim()).filter(Boolean);
713
- }
714
- function typedValue(value) {
715
- const booleanValue = parseBoolean(value);
716
- if (booleanValue !== void 0) return booleanValue;
717
- const numberValue = parseNumber(value);
718
- if (numberValue !== void 0) return numberValue;
719
- const jsonValue = parseJson(value);
720
- if (jsonValue !== void 0) return jsonValue;
721
- return value;
722
- }
723
- function mergeObjectOption(options, provider, key, value) {
724
- const parsed = parseJson(value);
725
- if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
726
- setProviderOption(options, provider, key, parsed);
727
- }
728
- }
729
- function addOpenAiOption(options, key, value, target = "openai") {
730
- const mappings = {
731
- reasoning_effort: "reasoningEffort",
732
- max_completion_tokens: "maxCompletionTokens",
733
- parallel_tool_calls: "parallelToolCalls",
734
- service_tier: "serviceTier",
735
- strict_json_schema: "strictJsonSchema",
736
- text_verbosity: "textVerbosity",
737
- prompt_cache_key: "promptCacheKey",
738
- prompt_cache_retention: "promptCacheRetention",
739
- safety_identifier: "safetyIdentifier",
740
- system_message_mode: "systemMessageMode",
741
- force_reasoning: "forceReasoning",
742
- reasoning_summary: "reasoningSummary",
743
- previous_response_id: "previousResponseId",
744
- max_tool_calls: "maxToolCalls",
745
- allowed_tools: "allowedTools"
746
- };
747
- const directKeys = /* @__PURE__ */ new Set([
748
- "conversation",
749
- "instructions",
750
- "logprobs",
751
- "metadata",
752
- "prediction",
753
- "store",
754
- "truncation",
755
- "user"
756
- ]);
757
- if (!mappings[key] && !directKeys.has(key) && key !== "include") return;
758
- const optionKey = mappings[key] ?? key;
759
- if (key === "include") {
760
- setProviderOption(options, target, optionKey, parseStringList(value));
761
- return;
762
- }
763
- if (key === "metadata" || key === "prediction" || key === "allowed_tools") {
764
- mergeObjectOption(options, target, optionKey, value);
765
- return;
766
- }
767
- setProviderOption(options, target, optionKey, typedValue(value));
768
- }
769
- function addAnthropicOption(options, key, value) {
770
- const target = "anthropic";
771
- if (key === "cache_control" || key === "cacheControl") {
772
- const ttl = options[target]?.cacheControl;
773
- const ttlValue = ttl && typeof ttl === "object" && "ttl" in ttl ? ttl.ttl : void 0;
774
- setProviderOption(options, target, "cacheControl", {
775
- type: value === "ephemeral" ? "ephemeral" : value,
776
- ...ttlValue ? { ttl: ttlValue } : {}
777
- });
778
- return;
779
- }
780
- if (key === "cache_ttl") {
781
- const current = options[target]?.cacheControl;
782
- setProviderOption(options, target, "cacheControl", {
783
- ...current && typeof current === "object" ? current : {},
784
- type: "ephemeral",
785
- ttl: value
786
- });
787
- return;
788
- }
789
- if (key === "thinking") {
790
- mergeObjectOption(options, target, "thinking", value);
791
- return;
792
- }
793
- if (key === "thinking_budget" || key === "budget_tokens") {
794
- const budgetTokens = parseNumber(value);
795
- if (budgetTokens !== void 0) {
796
- setProviderOption(options, target, "thinking", {
797
- type: "enabled",
798
- budgetTokens
799
- });
800
- }
801
- return;
802
- }
803
- const mappings = {
804
- send_reasoning: "sendReasoning",
805
- structured_output_mode: "structuredOutputMode",
806
- disable_parallel_tool_use: "disableParallelToolUse",
807
- tool_streaming: "toolStreaming",
808
- inference_geo: "inferenceGeo",
809
- anthropic_beta: "anthropicBeta",
810
- mcp_servers: "mcpServers",
811
- task_budget: "taskBudget",
812
- context_management: "contextManagement"
813
- };
814
- const directKeys = /* @__PURE__ */ new Set([
815
- "effort",
816
- "speed",
817
- "sendReasoning",
818
- "structuredOutputMode",
819
- "disableParallelToolUse",
820
- "toolStreaming",
821
- "inferenceGeo",
822
- "anthropicBeta",
823
- "metadata",
824
- "mcpServers",
825
- "container",
826
- "taskBudget",
827
- "contextManagement"
828
- ]);
829
- if (!mappings[key] && !directKeys.has(key)) return;
830
- const optionKey = mappings[key] ?? key;
831
- if (key === "anthropic_beta") {
832
- setProviderOption(options, target, optionKey, parseStringList(value));
833
- return;
834
- }
835
- if (key === "metadata" || key === "mcp_servers" || key === "container" || key === "task_budget" || key === "context_management") {
836
- mergeObjectOption(options, target, optionKey, value);
837
- return;
838
- }
839
- setProviderOption(options, target, optionKey, typedValue(value));
840
- }
841
- function addGoogleOption(options, key, value, target = "google") {
842
- if (key === "thinking_budget" || key === "thinking_level" || key === "include_thoughts") {
843
- const current = options[target]?.thinkingConfig;
844
- const thinkingConfig = current && typeof current === "object" && !Array.isArray(current) ? { ...current } : {};
845
- if (key === "thinking_budget") {
846
- const parsed = parseNumber(value);
847
- if (parsed !== void 0) thinkingConfig.thinkingBudget = parsed;
848
- }
849
- if (key === "thinking_level") thinkingConfig.thinkingLevel = value;
850
- if (key === "include_thoughts") {
851
- const parsed = parseBoolean(value);
852
- if (parsed !== void 0) thinkingConfig.includeThoughts = parsed;
853
- }
854
- setProviderOption(options, target, "thinkingConfig", thinkingConfig);
855
- return;
856
- }
857
- const mappings = {
858
- cached_content: "cachedContent",
859
- structured_outputs: "structuredOutputs",
860
- safety_settings: "safetySettings",
861
- response_modalities: "responseModalities",
862
- audio_timestamp: "audioTimestamp",
863
- media_resolution: "mediaResolution",
864
- image_config: "imageConfig",
865
- retrieval_config: "retrievalConfig",
866
- stream_function_call_arguments: "streamFunctionCallArguments",
867
- service_tier: "serviceTier"
868
- };
869
- const directKeys = /* @__PURE__ */ new Set([
870
- "cachedContent",
871
- "structuredOutputs",
872
- "safetySettings",
873
- "threshold",
874
- "audioTimestamp",
875
- "labels",
876
- "mediaResolution",
877
- "imageConfig",
878
- "retrievalConfig",
879
- "responseModalities",
880
- "streamFunctionCallArguments",
881
- "serviceTier"
882
- ]);
883
- if (!mappings[key] && !directKeys.has(key)) return;
884
- const optionKey = mappings[key] ?? key;
885
- if (key === "response_modalities") {
886
- setProviderOption(options, target, optionKey, parseStringList(value));
887
- return;
888
- }
889
- if (key === "safety_settings" || key === "labels" || key === "image_config" || key === "retrieval_config") {
890
- mergeObjectOption(options, target, optionKey, value);
891
- return;
892
- }
893
- setProviderOption(options, target, optionKey, typedValue(value));
894
- }
895
- function addMistralOption(options, key, value) {
896
- const target = "mistral";
897
- const mappings = {
898
- safe_prompt: "safePrompt",
899
- document_image_limit: "documentImageLimit",
900
- document_page_limit: "documentPageLimit",
901
- structured_outputs: "structuredOutputs",
902
- strict_json_schema: "strictJsonSchema",
903
- parallel_tool_calls: "parallelToolCalls",
904
- reasoning_effort: "reasoningEffort"
905
- };
906
- const directKeys = /* @__PURE__ */ new Set([
907
- "safePrompt",
908
- "documentImageLimit",
909
- "documentPageLimit",
910
- "structuredOutputs",
911
- "strictJsonSchema",
912
- "parallelToolCalls",
913
- "reasoningEffort"
914
- ]);
915
- if (!mappings[key] && !directKeys.has(key)) return;
916
- const optionKey = mappings[key] ?? key;
917
- setProviderOption(options, target, optionKey, typedValue(value));
918
- }
919
- function addCohereOption(options, key, value) {
920
- const target = "cohere";
921
- if (key === "thinking") {
922
- mergeObjectOption(options, target, "thinking", value);
923
- return;
924
- }
925
- if (key === "thinking_token_budget" || key === "token_budget") {
926
- const tokenBudget = parseNumber(value);
927
- if (tokenBudget !== void 0) {
928
- setProviderOption(options, target, "thinking", {
929
- type: "enabled",
930
- tokenBudget
931
- });
932
- }
933
- return;
934
- }
935
- if (key === "thinking_type") {
936
- const current = options[target]?.thinking;
937
- setProviderOption(options, target, "thinking", {
938
- ...current && typeof current === "object" ? current : {},
939
- type: value
940
- });
941
- }
942
- }
943
- function addBedrockOption(options, key, value) {
944
- const target = "bedrock";
945
- if (key === "cache_control") {
946
- setProviderOption(options, target, "cachePoint", {
947
- type: value === "ephemeral" ? "default" : value
948
- });
949
- return;
950
- }
951
- if (key === "cache_ttl") {
952
- const current = options[target]?.cachePoint;
953
- setProviderOption(options, target, "cachePoint", {
954
- ...current && typeof current === "object" ? current : {},
955
- type: "default",
956
- ttl: value
957
- });
958
- return;
959
- }
960
- if (key === "reasoning_config") {
961
- mergeObjectOption(options, target, "reasoningConfig", value);
962
- return;
963
- }
964
- if (key === "budget_tokens" || key === "reasoning_effort") {
965
- const current = options[target]?.reasoningConfig;
966
- const reasoningConfig = current && typeof current === "object" && !Array.isArray(current) ? { ...current } : {};
967
- reasoningConfig.type = "enabled";
968
- if (key === "budget_tokens") {
969
- const budgetTokens = parseNumber(value);
970
- if (budgetTokens !== void 0)
971
- reasoningConfig.budgetTokens = budgetTokens;
972
- }
973
- if (key === "reasoning_effort") reasoningConfig.maxReasoningEffort = value;
974
- setProviderOption(options, target, "reasoningConfig", reasoningConfig);
975
- return;
976
- }
977
- const mappings = {
978
- additional_model_request_fields: "additionalModelRequestFields",
979
- anthropic_beta: "anthropicBeta",
980
- service_tier: "serviceTier"
981
- };
982
- const directKeys = /* @__PURE__ */ new Set([
983
- "additionalModelRequestFields",
984
- "anthropicBeta",
985
- "serviceTier"
986
- ]);
987
- if (!mappings[key] && !directKeys.has(key)) return;
988
- const optionKey = mappings[key] ?? key;
989
- if (key === "additional_model_request_fields") {
990
- mergeObjectOption(options, target, optionKey, value);
991
- return;
992
- }
993
- if (key === "anthropic_beta") {
994
- setProviderOption(options, target, optionKey, parseStringList(value));
995
- return;
996
- }
997
- setProviderOption(options, target, optionKey, typedValue(value));
998
- }
999
- function addGatewayOption(options, key, value) {
1000
- const target = "gateway";
1001
- const listKeys = /* @__PURE__ */ new Set(["only", "order", "tags", "models"]);
1002
- const objectKeys = /* @__PURE__ */ new Set(["byok", "provider_timeouts"]);
1003
- const mappings = {
1004
- zero_data_retention: "zeroDataRetention",
1005
- disallow_prompt_training: "disallowPromptTraining",
1006
- hipaa_compliant: "hipaaCompliant",
1007
- quota_entity_id: "quotaEntityId",
1008
- provider_timeouts: "providerTimeouts"
1009
- };
1010
- const directKeys = /* @__PURE__ */ new Set([
1011
- "sort",
1012
- "user",
1013
- "zeroDataRetention",
1014
- "disallowPromptTraining",
1015
- "hipaaCompliant",
1016
- "quotaEntityId",
1017
- "providerTimeouts"
1018
- ]);
1019
- if (!mappings[key] && !directKeys.has(key) && !listKeys.has(key) && !objectKeys.has(key)) {
1020
- return;
1021
- }
1022
- const optionKey = mappings[key] ?? key;
1023
- if (listKeys.has(key)) {
1024
- setProviderOption(options, target, optionKey, parseStringList(value));
1025
- return;
1026
- }
1027
- if (objectKeys.has(key)) {
1028
- mergeObjectOption(options, target, optionKey, value);
1029
- return;
1030
- }
1031
- setProviderOption(options, target, optionKey, typedValue(value));
1032
- }
1033
- function addOpenRouterOption(options, key, value) {
1034
- const target = "openrouter";
1035
- if (key === "models") {
1036
- setProviderOption(options, target, "models", parseStringList(value));
1037
- return;
1038
- }
1039
- if (key === "reasoning") {
1040
- mergeObjectOption(options, target, "reasoning", value);
1041
- return;
1042
- }
1043
- if (key === "reasoning_effort") {
1044
- const current = options[target]?.reasoning;
1045
- setProviderOption(options, target, "reasoning", {
1046
- ...current && typeof current === "object" ? current : {},
1047
- effort: value
1048
- });
1049
- return;
1050
- }
1051
- if (key === "reasoning_max_tokens" || key === "max_reasoning_tokens") {
1052
- const current = options[target]?.reasoning;
1053
- const maxTokens = parseNumber(value);
1054
- if (maxTokens !== void 0) {
1055
- setProviderOption(options, target, "reasoning", {
1056
- ...current && typeof current === "object" ? current : {},
1057
- max_tokens: maxTokens
1058
- });
1059
- }
1060
- return;
1061
- }
1062
- if (key === "reasoning_enabled" || key === "reasoning_exclude") {
1063
- const current = options[target]?.reasoning;
1064
- const parsed = parseBoolean(value);
1065
- if (parsed !== void 0) {
1066
- setProviderOption(options, target, "reasoning", {
1067
- ...current && typeof current === "object" ? current : {},
1068
- [key === "reasoning_enabled" ? "enabled" : "exclude"]: parsed
1069
- });
1070
- }
1071
- return;
1072
- }
1073
- if (key === "user") {
1074
- setProviderOption(options, target, "user", value);
1075
- }
1076
- }
1077
- function addFlexibleProviderOption(options, target, key, value) {
1078
- setProviderOption(options, target, key, typedValue(value));
1079
- }
1080
- function addProviderSpecificOption(options, provider, key, value, includeGatewayOptions) {
1081
- if (provider === "vercel") {
1082
- if (includeGatewayOptions) addGatewayOption(options, key, value);
1083
- return;
1084
- }
1085
- if (provider === "openai") addOpenAiOption(options, key, value);
1086
- if (provider === "azure") addOpenAiOption(options, key, value, "azure");
1087
- if (provider === "anthropic") addAnthropicOption(options, key, value);
1088
- if (provider === "google") addGoogleOption(options, key, value);
1089
- if (provider === "google-vertex")
1090
- addGoogleOption(options, key, value, "vertex");
1091
- if (provider === "mistral") addMistralOption(options, key, value);
1092
- if (provider === "cohere") addCohereOption(options, key, value);
1093
- if (provider === "bedrock") addBedrockOption(options, key, value);
1094
- if (provider === "openrouter") addOpenRouterOption(options, key, value);
1095
- if (provider === "xai") addOpenAiOption(options, key, value, "xai");
1096
- if (provider === "groq") addOpenAiOption(options, key, value, "groq");
1097
- if (provider === "fal") addFlexibleProviderOption(options, "fal", key, value);
1098
- if (provider === "deepinfra")
1099
- addOpenAiOption(options, key, value, "deepinfra");
1100
- if (provider === "black-forest-labs")
1101
- addFlexibleProviderOption(options, "blackForestLabs", key, value);
1102
- if (provider === "together") addOpenAiOption(options, key, value, "together");
1103
- if (provider === "fireworks")
1104
- addOpenAiOption(options, key, value, "fireworks");
1105
- if (provider === "deepseek") addOpenAiOption(options, key, value, "deepseek");
1106
- if (provider === "moonshotai")
1107
- addOpenAiOption(options, key, value, "moonshotai");
1108
- if (provider === "perplexity")
1109
- addOpenAiOption(options, key, value, "perplexity");
1110
- if (provider === "alibaba") addOpenAiOption(options, key, value, "alibaba");
1111
- if (provider === "cerebras") addOpenAiOption(options, key, value, "cerebras");
1112
- if (provider === "replicate")
1113
- addFlexibleProviderOption(options, "replicate", key, value);
1114
- if (provider === "prodia")
1115
- addFlexibleProviderOption(options, "prodia", key, value);
1116
- if (provider === "luma")
1117
- addFlexibleProviderOption(options, "luma", key, value);
1118
- if (provider === "bytedance")
1119
- addFlexibleProviderOption(options, "bytedance", key, value);
1120
- if (provider === "kling")
1121
- addFlexibleProviderOption(options, "kling", key, value);
1122
- if (provider === "elevenlabs")
1123
- addFlexibleProviderOption(options, "elevenlabs", key, value);
1124
- if (provider === "assemblyai")
1125
- addFlexibleProviderOption(options, "assemblyai", key, value);
1126
- if (provider === "deepgram")
1127
- addFlexibleProviderOption(options, "deepgram", key, value);
1128
- if (provider === "gladia")
1129
- addFlexibleProviderOption(options, "gladia", key, value);
1130
- if (provider === "lmnt")
1131
- addFlexibleProviderOption(options, "lmnt", key, value);
1132
- if (provider === "hume")
1133
- addFlexibleProviderOption(options, "hume", key, value);
1134
- if (provider === "revai")
1135
- addFlexibleProviderOption(options, "revai", key, value);
1136
- if (provider === "baseten") addOpenAiOption(options, key, value, "baseten");
1137
- if (provider === "huggingface")
1138
- addOpenAiOption(options, key, value, "huggingface");
1139
- }
1140
- function createAiSdkProviderOptions(configOrResult, options = {}) {
1141
- const normalized = typeof configOrResult === "string" ? normalize(parse(configOrResult), options) : "changes" in configOrResult && "subProvider" in configOrResult ? configOrResult : normalize(configOrResult, options);
1142
- const providerOptions = {};
1143
- if (!normalized.provider) {
1144
- return {
1145
- provider: normalized.provider,
1146
- subProvider: normalized.subProvider,
1147
- providerOptions
1148
- };
1149
- }
1150
- const includeGatewayOptions = options.includeGatewayOptions ?? normalized.provider === "vercel";
1151
- for (const [key, value] of Object.entries(normalized.config.params)) {
1152
- addProviderSpecificOption(
1153
- providerOptions,
1154
- normalized.provider,
1155
- key,
1156
- value,
1157
- includeGatewayOptions
1158
- );
1159
- }
1160
- if (normalized.provider !== "vercel" && !providerOptions[providerOptionsKey(normalized.provider)]) {
1161
- return {
1162
- provider: normalized.provider,
1163
- subProvider: normalized.subProvider,
1164
- providerOptions: {}
1165
- };
1166
- }
1167
- return {
1168
- provider: normalized.provider,
1169
- subProvider: normalized.subProvider,
1170
- providerOptions
1171
- };
1172
- }
1173
- // Annotate the CommonJS export names for ESM import in node:
1174
- 0 && (module.exports = {
1175
- createAiSdkProviderOptions
1176
- });
1
+ "use strict";var e,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,i={};function a(e,t){return Object.prototype.hasOwnProperty.call(e,t)}((e,o)=>{for(var r in o)t(e,r,{get:o[r],enumerable:!0})})(i,{createAiSdkProviderOptions:()=>Z}),module.exports=(e=i,((e,i,a,s)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let p of r(i))n.call(e,p)||p===a||t(e,p,{get:()=>i[p],enumerable:!(s=o(i,p))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var s={openai:"api.openai.com",azure:"models.inference.ai.azure.com",anthropic:"api.anthropic.com",google:"generativelanguage.googleapis.com","google-vertex":"aiplatform.googleapis.com",aistudio:"generativelanguage.googleapis.com",mistral:"api.mistral.ai",cohere:"api.cohere.com",bedrock:"bedrock-runtime.us-east-1.amazonaws.com",openrouter:"openrouter.ai",vercel:"gateway.ai.vercel.app",alibaba:"dashscope-intl.aliyuncs.com",alibabacloud:"dashscope-intl.aliyuncs.com",dashscope:"dashscope-intl.aliyuncs.com",groq:"api.groq.com",fal:"fal.run",fireworks:"api.fireworks.ai",fireworksai:"api.fireworks.ai","black-forest-labs":"api.bfl.ai",bfl:"api.bfl.ai",deepseek:"api.deepseek.com",moonshotai:"api.moonshot.ai",moonshot:"api.moonshot.ai",perplexity:"api.perplexity.ai",venice:"api.venice.ai",parasail:"api.parasail.io",deepinfra:"api.deepinfra.com",atlascloud:"api.atlascloud.ai",novita:"api.novita.ai",novitaai:"api.novita.ai",grok:"api.x.ai",xai:"api.x.ai",together:"api.together.xyz",togetherai:"api.together.xyz",cerebras:"api.cerebras.ai",replicate:"api.replicate.com",prodia:"api.prodia.com",luma:"api.lumalabs.ai",bytedance:"ark.cn-beijing.volces.com",kling:"api.klingai.com",elevenlabs:"api.elevenlabs.io",assemblyai:"api.assemblyai.com",deepgram:"api.deepgram.com",gladia:"api.gladia.io",lmnt:"api.lmnt.com",hume:"api.hume.ai",revai:"api.rev.ai",baseten:"api.baseten.co",huggingface:"api-inference.huggingface.co",wandb:"api.inference.wandb.ai",weightsandbiases:"api.inference.wandb.ai",baidu:"qianfan.baidubce.com",qianfan:"qianfan.baidubce.com",vertex:"aiplatform.googleapis.com",xiaomi:"api.xiaomimimo.com",minimax:"api.minimax.io"},p={aistudio:"google",vertex:"google-vertex",grok:"xai",bfl:"black-forest-labs",moonshot:"moonshotai",alibaba:"alibaba",alibabacloud:"alibaba",dashscope:"alibaba",togetherai:"together",fireworksai:"fireworks"};function c(e){const t=e.trim();if(!t)return t;try{if(t.includes("://"))return new URL(t).host}catch{}return t.replace(/^\/\//,"").split("/")[0]??t}function l(e,t=function(){return"undefined"!=typeof process&&process.env?process.env:{}}()){const o=e.toLowerCase();if(!a(s,o))return{host:e};const r=o,n=function(e,t){const o=e.toUpperCase(),r=t[`LLM_STRINGS_${o}_HOST`]??t[`LLM_STRINGS_HOST_${o}`];return r?.trim()?r:void 0}(r,t);return{host:c(n??s[r]),alias:r}}function m(e,...t){return t.some(t=>{const o=t.toLowerCase();return e===o||e.endsWith(`.${o}`)})}function d(e,...t){const o=e.split(".");return t.some(e=>o.some(t=>t.startsWith(e.toLowerCase())))}var u=new Set(["-","."]);function f(e){return e.trim().toLowerCase()}function g(e){const t=f(e),o=t.lastIndexOf("/");return o>=0?t.slice(o+1):t}function _(e,t){const o=g(e),r=f(t);if(!o||!r)return!1;if(o===r)return!0;const n=o[r.length];return o.startsWith(r)&&void 0!==n&&u.has(n)}function y(e){return m(e=function(e){return c(e).toLowerCase().split(":")[0]??e}(e),"openrouter","openrouter.ai")?"openrouter":m(e,"vercel","gateway.ai.vercel.app","gateway.ai.vercel.sh")?"vercel":m(e,"bedrock","amazonaws.com")||d(e,"bedrock")?"bedrock":m(e,"aiplatform.googleapis.com")?"google-vertex":m(e,"xai","x.ai","api.x.ai")?"xai":m(e,"groq","groq.com","api.groq.com")?"groq":m(e,"fal","fal.run","fal.ai")?"fal":m(e,"deepinfra","deepinfra.com")?"deepinfra":m(e,"bfl","bfl.ai","api.bfl.ai")?"black-forest-labs":m(e,"together","together.xyz")?"together":m(e,"fireworks","fireworks.ai")?"fireworks":m(e,"deepseek","deepseek.com")?"deepseek":m(e,"moonshot","moonshot.ai")?"moonshotai":m(e,"perplexity","perplexity.ai")?"perplexity":m(e,"alibaba","aliyuncs.com")||d(e,"dashscope")?"alibaba":m(e,"cerebras","cerebras.ai")?"cerebras":m(e,"replicate","replicate.com")?"replicate":m(e,"prodia","prodia.com")?"prodia":m(e,"luma","lumalabs.ai")?"luma":m(e,"bytedance","volces.com")||function(e,...t){const o=e.split(".");return t.some(e=>o.includes(e.toLowerCase()))}(e,"bytedance")?"bytedance":m(e,"kling","klingai.com")?"kling":m(e,"elevenlabs","elevenlabs.io")?"elevenlabs":m(e,"assemblyai","assemblyai.com")?"assemblyai":m(e,"deepgram","deepgram.com")?"deepgram":m(e,"gladia","gladia.io")?"gladia":m(e,"lmnt","lmnt.com")?"lmnt":m(e,"hume","hume.ai")?"hume":m(e,"revai","rev.ai")?"revai":m(e,"baseten","baseten.co")?"baseten":m(e,"huggingface","huggingface.co")?"huggingface":m(e,"azure","azure.com")?"azure":m(e,"openai","openai.com")?"openai":m(e,"anthropic","anthropic.com","claude.ai")?"anthropic":m(e,"google","googleapis.com")?"google":m(e,"mistral","mistral.ai")?"mistral":m(e,"cohere","cohere.com")?"cohere":void 0}var b={temp:"temperature",max:"max_tokens",max_out:"max_tokens",max_output:"max_tokens",max_output_tokens:"max_tokens",max_completion_tokens:"max_tokens",maxOutputTokens:"max_tokens",maxTokens:"max_tokens",topp:"top_p",topP:"top_p",nucleus:"top_p",topk:"top_k",topK:"top_k",freq:"frequency_penalty",freq_penalty:"frequency_penalty",frequencyPenalty:"frequency_penalty",repetition_penalty:"frequency_penalty",pres:"presence_penalty",pres_penalty:"presence_penalty",presencePenalty:"presence_penalty",stop_sequences:"stop",stopSequences:"stop",stop_sequence:"stop",random_seed:"seed",randomSeed:"seed",candidateCount:"n",candidate_count:"n",num_completions:"n",reasoning_effort:"effort",reasoningEffort:"effort",reasoning:"effort",thinking_effort:"effort",thinkingEffort:"effort",cache_control:"cache",cacheControl:"cache",cachePoint:"cache",cache_point:"cache",zeroDataRetention:"zero_data_retention",disallowPromptTraining:"disallow_prompt_training",hipaaCompliant:"hipaa_compliant",quotaEntityId:"quota_entity_id",providerTimeouts:"provider_timeouts"},h=["none","minimal","low","medium","high","xhigh","max"],v={params:{temperature:"temperature",max_tokens:"max_tokens",max_completion_tokens:"max_completion_tokens",top_p:"top_p",top_k:"top_k",frequency_penalty:"frequency_penalty",presence_penalty:"presence_penalty",stop:"stop",n:"n",seed:"seed",stream:"stream",effort:"reasoning_effort"},specs:{temperature:{type:"number",min:0,max:2,default:.7,description:"Controls randomness"},max_tokens:{type:"number",min:1,default:4096,description:"Maximum output tokens"},max_completion_tokens:{type:"number",min:1,default:4096,description:"Maximum completion tokens (reasoning models)"},top_p:{type:"number",min:0,max:1,default:1,description:"Nucleus sampling"},top_k:{type:"number",min:0,default:40,description:"Top-K sampling"},frequency_penalty:{type:"number",min:-2,max:2,default:0,description:"Penalize frequent tokens"},presence_penalty:{type:"number",min:-2,max:2,default:0,description:"Penalize repeated topics"},stop:{type:"string",description:"Stop sequences"},n:{type:"number",min:1,default:1,description:"Completions count"},seed:{type:"number",description:"Random seed"},stream:{type:"boolean",default:!1,description:"Stream response"},reasoning_effort:{type:"string",values:h,default:"medium",description:"Reasoning effort"}}},k={prompt:{type:"string",description:"Prompt"},negative_prompt:{type:"string",description:"Negative prompt"},seed:{type:"number",description:"Random seed"},image_size:{type:"string",description:"Output image size"},aspect_ratio:{type:"string",description:"Output aspect ratio"},output_format:{type:"string",description:"Output format"},width:{type:"number",min:1,description:"Image width"},height:{type:"number",min:1,description:"Image height"}},x={prompt:"prompt",negative_prompt:"negative_prompt",seed:"seed",image_size:"image_size",aspect_ratio:"aspect_ratio",output_format:"output_format",width:"width",height:"height"},w={params:{...x,num_images:"num_images",enable_safety_checker:"enable_safety_checker",enable_safety_checks:"enable_safety_checks",enable_prompt_expansion:"enable_prompt_expansion",expand_prompt:"expand_prompt"},specs:{...k,num_images:{type:"number",min:1,description:"Number of images to generate"},enable_safety_checker:{type:"boolean",description:"Enable safety checker"},enable_safety_checks:{type:"boolean",description:"Enable safety checker"},enable_prompt_expansion:{type:"boolean",description:"Enable prompt expansion"},expand_prompt:{type:"boolean",description:"Enable prompt expansion"},output_format:{type:"string",values:["jpeg","jpg","png","webp","gif"],description:"Output image format"}}},q={params:{...x,input:"input",version:"version",num_outputs:"num_outputs",num_inference_steps:"num_inference_steps",guidance_scale:"guidance_scale",stream:"stream",webhook:"webhook",webhook_events_filter:"webhook_events_filter"},specs:{...k,input:{type:"string",description:"Model input object"},version:{type:"string",description:"Model version"},num_outputs:{type:"number",min:1,description:"Number of outputs to generate"},num_inference_steps:{type:"number",min:1,description:"Number of inference steps"},guidance_scale:{type:"number",min:0,description:"Guidance scale"},stream:{type:"boolean",description:"Request streaming output"},webhook:{type:"string",description:"Webhook URL"},webhook_events_filter:{type:"string",description:"Webhook events filter"}}},P={params:{...x,model:"model",style_preset:"style_preset",steps:"steps",cfg_scale:"cfg_scale",upscale:"upscale",sampler:"sampler",type:"type",config:"config",price:"price"},specs:{...k,model:{type:"string",description:"Model name"},style_preset:{type:"string",description:"Style preset"},steps:{type:"number",min:1,description:"Generation steps"},cfg_scale:{type:"number",min:0,description:"CFG scale"},upscale:{type:"boolean",description:"Enable 2x upscale"},sampler:{type:"string",description:"Sampler"},width:{type:"number",min:1,max:1024,description:"Image width"},height:{type:"number",min:1,max:1024,description:"Image height"},type:{type:"string",description:"Prodia v2 job type"},config:{type:"string",description:"Prodia v2 job config"},price:{type:"boolean",description:"Include Prodia v2 job price"}}},S={params:{temperature:"temperature",max_tokens:"maxOutputTokens",top_p:"topP",top_k:"topK",frequency_penalty:"frequencyPenalty",presence_penalty:"presencePenalty",stop:"stopSequences",n:"candidateCount",stream:"stream",seed:"seed",responseMimeType:"responseMimeType",responseSchema:"responseSchema"},specs:{temperature:{type:"number",min:0,max:2,default:.7,description:"Controls randomness"},maxOutputTokens:{type:"number",min:1,default:4096,description:"Maximum output tokens"},topP:{type:"number",min:0,max:1,default:1,description:"Nucleus sampling"},topK:{type:"number",min:0,default:40,description:"Top-K sampling"},frequencyPenalty:{type:"number",min:-2,max:2,default:0,description:"Penalize frequent tokens"},presencePenalty:{type:"number",min:-2,max:2,default:0,description:"Penalize repeated topics"},stopSequences:{type:"string",description:"Stop sequences"},candidateCount:{type:"number",min:1,default:1,description:"Candidate count"},stream:{type:"boolean",default:!1,description:"Stream response"},seed:{type:"number",description:"Random seed"},responseMimeType:{type:"string",description:"Response MIME type"},responseSchema:{type:"string",description:"Response schema"}}},C={openai:{params:{temperature:"temperature",max_tokens:"max_tokens",max_completion_tokens:"max_completion_tokens",top_p:"top_p",frequency_penalty:"frequency_penalty",presence_penalty:"presence_penalty",stop:"stop",n:"n",seed:"seed",stream:"stream",effort:"reasoning_effort"},specs:{temperature:{type:"number",min:0,max:2,default:.7,description:"Controls randomness"},max_tokens:{type:"number",min:1,default:4096,description:"Maximum output tokens"},max_completion_tokens:{type:"number",min:1,default:4096,description:"Maximum completion tokens (reasoning models)"},top_p:{type:"number",min:0,max:1,default:1,description:"Nucleus sampling"},frequency_penalty:{type:"number",min:-2,max:2,default:0,description:"Penalize frequent tokens"},presence_penalty:{type:"number",min:-2,max:2,default:0,description:"Penalize repeated topics"},stop:{type:"string",description:"Stop sequences"},n:{type:"number",min:1,default:1,description:"Completions count"},seed:{type:"number",description:"Random seed"},stream:{type:"boolean",default:!1,description:"Stream response"},reasoning_effort:{type:"string",values:h,default:"medium",description:"Reasoning effort"}}},azure:v,anthropic:{params:{temperature:"temperature",max_tokens:"max_tokens",top_p:"top_p",top_k:"top_k",stop:"stop_sequences",stream:"stream",effort:"effort",cache:"cache_control",cache_ttl:"cache_ttl"},specs:{temperature:{type:"number",min:0,max:1,default:.7,description:"Controls randomness"},max_tokens:{type:"number",min:1,default:4096,description:"Maximum output tokens"},top_p:{type:"number",min:0,max:1,default:1,description:"Nucleus sampling"},top_k:{type:"number",min:0,default:40,description:"Top-K sampling"},stop_sequences:{type:"string",description:"Stop sequences"},stream:{type:"boolean",default:!1,description:"Stream response"},effort:{type:"string",values:h,default:"low",description:"Thinking effort"},cache_control:{type:"string",values:["ephemeral"],default:"ephemeral",description:"Cache control"},cache_ttl:{type:"string",values:["5m","1h"],default:"5m",description:"Cache TTL"}},cacheValue:"ephemeral",cacheTtls:["5m","1h"]},google:S,"google-vertex":S,mistral:{params:{temperature:"temperature",max_tokens:"max_tokens",top_p:"top_p",frequency_penalty:"frequency_penalty",presence_penalty:"presence_penalty",stop:"stop",n:"n",seed:"random_seed",stream:"stream",safe_prompt:"safe_prompt",min_tokens:"min_tokens"},specs:{temperature:{type:"number",min:0,max:1,default:.7,description:"Controls randomness"},max_tokens:{type:"number",min:1,default:4096,description:"Maximum output tokens"},top_p:{type:"number",min:0,max:1,default:1,description:"Nucleus sampling"},frequency_penalty:{type:"number",min:-2,max:2,default:0,description:"Penalize frequent tokens"},presence_penalty:{type:"number",min:-2,max:2,default:0,description:"Penalize repeated topics"},stop:{type:"string",description:"Stop sequences"},n:{type:"number",min:1,default:1,description:"Completions count"},random_seed:{type:"number",description:"Random seed"},stream:{type:"boolean",default:!1,description:"Stream response"},safe_prompt:{type:"boolean",default:!1,description:"Enable safe prompt"},min_tokens:{type:"number",min:0,default:0,description:"Minimum tokens"}}},cohere:{params:{temperature:"temperature",max_tokens:"max_tokens",top_p:"p",top_k:"k",frequency_penalty:"frequency_penalty",presence_penalty:"presence_penalty",stop:"stop_sequences",stream:"stream",seed:"seed"},specs:{temperature:{type:"number",min:0,max:1,default:.7,description:"Controls randomness"},max_tokens:{type:"number",min:1,default:4096,description:"Maximum output tokens"},p:{type:"number",min:0,max:1,default:1,description:"Nucleus sampling (p)"},k:{type:"number",min:0,max:500,default:40,description:"Top-K sampling (k)"},frequency_penalty:{type:"number",min:0,max:1,default:0,description:"Penalize frequent tokens"},presence_penalty:{type:"number",min:0,max:1,default:0,description:"Penalize repeated topics"},stop_sequences:{type:"string",description:"Stop sequences"},stream:{type:"boolean",default:!1,description:"Stream response"},seed:{type:"number",description:"Random seed"}}},bedrock:{params:{temperature:"temperature",max_tokens:"maxTokens",top_p:"topP",top_k:"topK",stop:"stopSequences",stream:"stream",cache:"cache_control",cache_ttl:"cache_ttl"},specs:{temperature:{type:"number",min:0,max:1,default:.7,description:"Controls randomness"},maxTokens:{type:"number",min:1,default:4096,description:"Maximum output tokens"},topP:{type:"number",min:0,max:1,default:1,description:"Nucleus sampling"},topK:{type:"number",min:0,default:40,description:"Top-K sampling"},stopSequences:{type:"string",description:"Stop sequences"},stream:{type:"boolean",default:!1,description:"Stream response"},cache_control:{type:"string",values:["ephemeral"],default:"ephemeral",description:"Cache control"},cache_ttl:{type:"string",values:["5m","1h"],default:"5m",description:"Cache TTL"}},cacheValue:"ephemeral",cacheTtls:["5m","1h"]},openrouter:{params:{...v.params,...{provider:"provider","provider.order":"provider.order","provider.only":"provider.only","provider.ignore":"provider.ignore","provider.allow_fallbacks":"provider.allow_fallbacks","provider.require_parameters":"provider.require_parameters","provider.data_collection":"provider.data_collection","provider.zdr":"provider.zdr","provider.enforce_distillable_text":"provider.enforce_distillable_text","provider.quantizations":"provider.quantizations","provider.sort":"provider.sort","provider.preferred_min_throughput":"provider.preferred_min_throughput","provider.preferred_max_latency":"provider.preferred_max_latency","provider.max_price":"provider.max_price",transforms:"transforms",plugins:"plugins"}},specs:{...v.specs,...{provider:{type:"string",description:"Provider routing preferences"},"provider.order":{type:"string",description:"Provider order"},"provider.only":{type:"string",description:"Provider allowlist"},"provider.ignore":{type:"string",description:"Provider blocklist"},"provider.allow_fallbacks":{type:"boolean",default:!0,description:"Allow fallback providers"},"provider.require_parameters":{type:"boolean",default:!1,description:"Only route to providers that support all request params"},"provider.data_collection":{type:"string",values:["allow","deny"],default:"allow",description:"Provider data collection policy"},"provider.zdr":{type:"boolean",description:"Require zero data retention providers"},"provider.enforce_distillable_text":{type:"boolean",description:"Require providers that allow text distillation"},"provider.quantizations":{type:"string",description:"Allowed provider quantization levels"},"provider.sort":{type:"string",values:["price","throughput","latency","cost","ttft","tps"],description:"Provider sort strategy"},"provider.preferred_min_throughput":{type:"number",min:0,description:"Preferred minimum provider throughput"},"provider.preferred_max_latency":{type:"number",min:0,description:"Preferred maximum provider latency"},"provider.max_price":{type:"string",description:"Maximum provider price filter"},transforms:{type:"string",description:"Legacy OpenRouter message transforms"},plugins:{type:"string",description:"OpenRouter request plugins"}}}},vercel:{params:{...v.params},specs:{...v.specs,order:{type:"string",description:"Gateway provider order"},only:{type:"string",description:"Gateway provider allowlist"},models:{type:"string",description:"Gateway fallback models"},tags:{type:"string",description:"Gateway usage tags"},sort:{type:"string",values:["cost","ttft","tps"],description:"Gateway provider sort strategy"},caching:{type:"string",values:["auto"],description:"Gateway automatic caching strategy"},user:{type:"string",description:"Gateway usage user identifier"},byok:{type:"string",description:"Gateway BYOK credentials"},zero_data_retention:{type:"boolean",description:"Gateway zero data retention routing"},disallow_prompt_training:{type:"boolean",description:"Gateway prompt training opt-out routing"},hipaa_compliant:{type:"boolean",description:"Gateway HIPAA-compliant routing"},quota_entity_id:{type:"string",description:"Gateway quota entity identifier"},provider_timeouts:{type:"string",description:"Gateway provider timeouts"}}},xai:v,groq:v,fal:w,deepinfra:v,"black-forest-labs":{params:{},specs:{}},together:v,fireworks:v,deepseek:v,moonshotai:v,perplexity:v,alibaba:v,cerebras:v,replicate:q,prodia:P,luma:{params:{prompt:"prompt",model:"model",aspect_ratio:"aspect_ratio",keyframes:"keyframes",loop:"loop",duration:"duration",type:"type",image_ref:"image_ref",video:"video",source:"source"},specs:{prompt:{type:"string",description:"Prompt"},model:{type:"string",description:"Model name"},aspect_ratio:{type:"string",description:"Output aspect ratio"},keyframes:{type:"string",description:"Generation keyframes"},loop:{type:"boolean",description:"Generate a looping video"},duration:{type:"string",description:"Generation duration"},type:{type:"string",description:"Generation type"},image_ref:{type:"string",description:"Image reference"},video:{type:"string",description:"Video options"},source:{type:"string",description:"Source generation or media"}}},bytedance:{params:{},specs:{}},kling:{params:{},specs:{}},elevenlabs:{params:{},specs:{}},assemblyai:{params:{},specs:{}},deepgram:{params:{},specs:{}},gladia:{params:{},specs:{}},lmnt:{params:{},specs:{}},hume:{params:{},specs:{}},revai:{params:{},specs:{}},baseten:v,huggingface:v},T=Object.fromEntries(Object.entries(C).map(([e,t])=>[e,t.params])),z=(Object.fromEntries(Object.entries(C).map(([e,t])=>[e,t.specs])),Object.fromEntries(Object.entries(C).filter(([,e])=>void 0!==e.cacheValue).map(([e,t])=>[e,t.cacheValue]))),O=Object.fromEntries(Object.entries(C).filter(([,e])=>void 0!==e.cacheTtls).map(([e,t])=>[e,t.cacheTtls])),j=[];function M(e){const t=g(e),o=t.match(/^o\d+/)?.[0],r=t.match(/^gpt-[5-9]/)?.[0];return void 0!==o&&_(t,o)||void 0!==r&&_(t,r)||j.some(e=>_(t,e))}function R(e){return"openai"===e||"azure"===e||"openrouter"===e||"vercel"===e}var G=new Set(["temperature","top_p","top_k","frequency_penalty","presence_penalty","n"]);function L(e){const t=function(e){const t=g(e).split(".");return["anthropic","meta","amazon","mistral","cohere","ai21"].find(e=>t.includes(e))}(e);if("anthropic"===t)return!0;if("amazon"===t){const t=g(e).split("."),o=t.indexOf("amazon"),r=o>=0?t[o+1]:void 0;return!!r&&_(r,"nova")}return!1}var A=/^\d+[mh]$/;function E(e,t={}){const o=(e.hostAlias?function(e){const t=e.toLowerCase();return a(T,t)?t:a(p,t)?p[t]:void 0}(e.hostAlias):void 0)??y(e.host),r=o&&function(e){return"openrouter"===e||"vercel"===e}(o)?function(e){const t=e.indexOf("/");if(t<1)return;return{openai:"openai",anthropic:"anthropic",google:"google",vertex:"google","google-vertex":"google",mistral:"mistral",cohere:"cohere"}[f(e.slice(0,t))]}(e.model):void 0,n=[],i={};for(const[r,a]of Object.entries(e.params)){let s=r;if(b[s]){const e=b[s];t.verbose&&n.push({from:s,to:e,value:a,reason:`alias: "${s}" → "${e}"`}),s=e}if("cache"===s&&o){let r=z[o];if("bedrock"!==o||L(e.model)||(r=void 0),!r){t.verbose&&n.push({from:"cache",to:"(dropped)",value:a,reason:`${o} does not use a cache param for this model (caching is automatic or unsupported)`});continue}const s="true"===a||"1"===a||"yes"===a,p=A.test(a);if(s||p){const e=T[o]?.cache??"cache";t.verbose&&n.push({from:"cache",to:e,value:r,reason:`cache=${a} → ${e}=${r} for ${o}`}),i[e]=r,p&&O[o]&&(t.verbose&&n.push({from:"cache",to:"cache_ttl",value:a,reason:`cache=${a} → cache_ttl=${a} for ${o}`}),i.cache_ttl=a);continue}}if(o&&T[o]){const e=T[o][s];e&&e!==s&&(t.verbose&&n.push({from:s,to:e,value:a,reason:`${o} uses "${e}" instead of "${s}"`}),s=e)}o&&R(o)&&M(e.model)&&"max_tokens"===s&&(t.verbose&&n.push({from:"max_tokens",to:"max_completion_tokens",value:a,reason:"OpenAI reasoning models use max_completion_tokens instead of max_tokens"}),s="max_completion_tokens"),o&&R(o)&&M(e.model)&&G.has(s)?t.verbose&&n.push({from:s,to:"(dropped)",value:a,reason:`${o} reasoning model "${e.model}" does not support "${s}"`}):i[s]=a}return{config:{...e,params:i},provider:o,subProvider:r,changes:n}}var $={openai:"openai",azure:"azure",anthropic:"anthropic",google:"google","google-vertex":"vertex",mistral:"mistral",cohere:"cohere",bedrock:"bedrock",openrouter:"openrouter",vercel:"gateway",xai:"xai",groq:"groq",fal:"fal",deepinfra:"deepinfra","black-forest-labs":"blackForestLabs",together:"together",fireworks:"fireworks",deepseek:"deepseek",moonshotai:"moonshotai",perplexity:"perplexity",alibaba:"alibaba",cerebras:"cerebras",replicate:"replicate",prodia:"prodia",luma:"luma",bytedance:"bytedance",kling:"kling",elevenlabs:"elevenlabs",assemblyai:"assemblyai",deepgram:"deepgram",gladia:"gladia",lmnt:"lmnt",hume:"hume",revai:"revai",baseten:"baseten",huggingface:"huggingface"},I=new Set(["true","1","yes","on"]),N=new Set(["false","0","no","off"]);function K(e,t,o,r){e[t]??(e[t]={}),e[t][o]=r}function B(e){const t=e.trim().toLowerCase();return!!I.has(t)||!N.has(t)&&void 0}function F(e){if(!e.trim())return;const t=Number(e);return Number.isFinite(t)?t:void 0}function W(e){try{return JSON.parse(e)}catch{return}}function U(e){const t=W(e);return Array.isArray(t)?t.filter(e=>"string"==typeof e):e.split(",").map(e=>e.trim()).filter(Boolean)}function V(e){const t=B(e);if(void 0!==t)return t;const o=F(e);if(void 0!==o)return o;const r=W(e);return void 0!==r?r:e}function D(e,t,o,r){const n=W(r);n&&"object"==typeof n&&!Array.isArray(n)&&K(e,t,o,n)}function J(e,t,o,r="openai"){const n={reasoning_effort:"reasoningEffort",max_completion_tokens:"maxCompletionTokens",parallel_tool_calls:"parallelToolCalls",service_tier:"serviceTier",strict_json_schema:"strictJsonSchema",text_verbosity:"textVerbosity",prompt_cache_key:"promptCacheKey",prompt_cache_retention:"promptCacheRetention",safety_identifier:"safetyIdentifier",system_message_mode:"systemMessageMode",force_reasoning:"forceReasoning",reasoning_summary:"reasoningSummary",previous_response_id:"previousResponseId",max_tool_calls:"maxToolCalls",allowed_tools:"allowedTools"};if(!n[t]&&!new Set(["conversation","instructions","logprobs","metadata","prediction","store","truncation","user"]).has(t)&&"include"!==t)return;const i=n[t]??t;"include"!==t?"metadata"!==t&&"prediction"!==t&&"allowed_tools"!==t?K(e,r,i,V(o)):D(e,r,i,o):K(e,r,i,U(o))}function H(e,t,o,r="google"){if("thinking_budget"===t||"thinking_level"===t||"include_thoughts"===t){const n=e[r]?.thinkingConfig,i=n&&"object"==typeof n&&!Array.isArray(n)?{...n}:{};if("thinking_budget"===t){const e=F(o);void 0!==e&&(i.thinkingBudget=e)}if("thinking_level"===t&&(i.thinkingLevel=o),"include_thoughts"===t){const e=B(o);void 0!==e&&(i.includeThoughts=e)}return void K(e,r,"thinkingConfig",i)}const n={cached_content:"cachedContent",structured_outputs:"structuredOutputs",safety_settings:"safetySettings",response_modalities:"responseModalities",audio_timestamp:"audioTimestamp",media_resolution:"mediaResolution",image_config:"imageConfig",retrieval_config:"retrievalConfig",stream_function_call_arguments:"streamFunctionCallArguments",service_tier:"serviceTier"};if(!n[t]&&!new Set(["cachedContent","structuredOutputs","safetySettings","threshold","audioTimestamp","labels","mediaResolution","imageConfig","retrievalConfig","responseModalities","streamFunctionCallArguments","serviceTier"]).has(t))return;const i=n[t]??t;"response_modalities"!==t?"safety_settings"!==t&&"labels"!==t&&"image_config"!==t&&"retrieval_config"!==t?K(e,r,i,V(o)):D(e,r,i,o):K(e,r,i,U(o))}function Y(e,t,o,r){K(e,t,o,V(r))}var Q={openai:J,azure:(e,t,o)=>J(e,t,o,"azure"),anthropic:function(e,t,o){const r="anthropic";if("cache_control"===t||"cacheControl"===t){const t=e[r]?.cacheControl,n=t&&"object"==typeof t&&"ttl"in t?t.ttl:void 0;return void K(e,r,"cacheControl",{type:"ephemeral"===o?"ephemeral":o,...n?{ttl:n}:{}})}if("cache_ttl"===t){const t=e[r]?.cacheControl;return void K(e,r,"cacheControl",{...t&&"object"==typeof t?t:{},type:"ephemeral",ttl:o})}if("thinking"===t)return void D(e,r,"thinking",o);if("thinking_budget"===t||"budget_tokens"===t){const t=F(o);return void(void 0!==t&&K(e,r,"thinking",{type:"enabled",budgetTokens:t}))}const n={send_reasoning:"sendReasoning",structured_output_mode:"structuredOutputMode",disable_parallel_tool_use:"disableParallelToolUse",tool_streaming:"toolStreaming",inference_geo:"inferenceGeo",anthropic_beta:"anthropicBeta",mcp_servers:"mcpServers",task_budget:"taskBudget",context_management:"contextManagement"};if(!n[t]&&!new Set(["effort","speed","sendReasoning","structuredOutputMode","disableParallelToolUse","toolStreaming","inferenceGeo","anthropicBeta","metadata","mcpServers","container","taskBudget","contextManagement"]).has(t))return;const i=n[t]??t;"anthropic_beta"!==t?"metadata"!==t&&"mcp_servers"!==t&&"container"!==t&&"task_budget"!==t&&"context_management"!==t?K(e,r,i,V(o)):D(e,r,i,o):K(e,r,i,U(o))},google:H,"google-vertex":(e,t,o)=>H(e,t,o,"vertex"),mistral:function(e,t,o){const r={safe_prompt:"safePrompt",document_image_limit:"documentImageLimit",document_page_limit:"documentPageLimit",structured_outputs:"structuredOutputs",strict_json_schema:"strictJsonSchema",parallel_tool_calls:"parallelToolCalls",reasoning_effort:"reasoningEffort"};if(!r[t]&&!new Set(["safePrompt","documentImageLimit","documentPageLimit","structuredOutputs","strictJsonSchema","parallelToolCalls","reasoningEffort"]).has(t))return;K(e,"mistral",r[t]??t,V(o))},cohere:function(e,t,o){const r="cohere";if("thinking"!==t){if("thinking_token_budget"===t||"token_budget"===t){const t=F(o);return void(void 0!==t&&K(e,r,"thinking",{type:"enabled",tokenBudget:t}))}if("thinking_type"===t){const t=e[r]?.thinking;K(e,r,"thinking",{...t&&"object"==typeof t?t:{},type:o})}}else D(e,r,"thinking",o)},bedrock:function(e,t,o){const r="bedrock";if("cache_control"===t)return void K(e,r,"cachePoint",{type:"ephemeral"===o?"default":o});if("cache_ttl"===t){const t=e[r]?.cachePoint;return void K(e,r,"cachePoint",{...t&&"object"==typeof t?t:{},type:"default",ttl:o})}if("reasoning_config"===t)return void D(e,r,"reasoningConfig",o);if("budget_tokens"===t||"reasoning_effort"===t){const n=e[r]?.reasoningConfig,i=n&&"object"==typeof n&&!Array.isArray(n)?{...n}:{};if(i.type="enabled","budget_tokens"===t){const e=F(o);void 0!==e&&(i.budgetTokens=e)}return"reasoning_effort"===t&&(i.maxReasoningEffort=o),void K(e,r,"reasoningConfig",i)}const n={additional_model_request_fields:"additionalModelRequestFields",anthropic_beta:"anthropicBeta",service_tier:"serviceTier"};if(!n[t]&&!new Set(["additionalModelRequestFields","anthropicBeta","serviceTier"]).has(t))return;const i=n[t]??t;"additional_model_request_fields"!==t?K(e,r,i,"anthropic_beta"!==t?V(o):U(o)):D(e,r,i,o)},openrouter:function(e,t,o){const r="openrouter",n=t.startsWith("provider.")?t.slice(9):t,i=new Set(["order","only","ignore","quantizations"]),a=new Set(["provider","sort","preferred_min_throughput","preferred_max_latency","max_price"]),s=new Set(["allow_fallbacks","require_parameters","data_collection","zdr","enforce_distillable_text"]);if("models"!==t)if("transforms"!==t){if("plugins"===t){const t=W(o);return void K(e,r,"plugins",Array.isArray(t)?t:U(o))}if(t.startsWith("provider.")||i.has(n)||s.has(n)||a.has(n)){if("provider"===n)return void D(e,r,"provider",o);const t=e[r]?.provider,s=t&&"object"==typeof t&&!Array.isArray(t)?{...t}:{};if(i.has(n))s[n]=U(o);else if(a.has(n)){const e=W(o);s[n]=void 0!==e?e:V(o)}else s[n]=V(o);return void K(e,r,"provider",s)}if("reasoning"!==t){if("reasoning_effort"===t){const t=e[r]?.reasoning;return void K(e,r,"reasoning",{...t&&"object"==typeof t?t:{},effort:o})}if("reasoning_max_tokens"===t||"max_reasoning_tokens"===t){const t=e[r]?.reasoning,n=F(o);return void(void 0!==n&&K(e,r,"reasoning",{...t&&"object"==typeof t?t:{},max_tokens:n}))}if("reasoning_enabled"===t||"reasoning_exclude"===t){const n=e[r]?.reasoning,i=B(o);return void(void 0!==i&&K(e,r,"reasoning",{...n&&"object"==typeof n?n:{},["reasoning_enabled"===t?"enabled":"exclude"]:i}))}"user"===t&&K(e,r,"user",o)}else D(e,r,"reasoning",o)}else K(e,r,"transforms",U(o));else K(e,r,"models",U(o))},xai:(e,t,o)=>J(e,t,o,"xai"),groq:(e,t,o)=>J(e,t,o,"groq"),fal:(e,t,o)=>Y(e,"fal",t,o),deepinfra:(e,t,o)=>J(e,t,o,"deepinfra"),"black-forest-labs":(e,t,o)=>Y(e,"blackForestLabs",t,o),together:(e,t,o)=>J(e,t,o,"together"),fireworks:(e,t,o)=>J(e,t,o,"fireworks"),deepseek:(e,t,o)=>J(e,t,o,"deepseek"),moonshotai:(e,t,o)=>J(e,t,o,"moonshotai"),perplexity:(e,t,o)=>J(e,t,o,"perplexity"),alibaba:(e,t,o)=>J(e,t,o,"alibaba"),cerebras:(e,t,o)=>J(e,t,o,"cerebras"),replicate:(e,t,o)=>Y(e,"replicate",t,o),prodia:(e,t,o)=>Y(e,"prodia",t,o),luma:(e,t,o)=>Y(e,"luma",t,o),bytedance:(e,t,o)=>Y(e,"bytedance",t,o),kling:(e,t,o)=>Y(e,"kling",t,o),elevenlabs:(e,t,o)=>Y(e,"elevenlabs",t,o),assemblyai:(e,t,o)=>Y(e,"assemblyai",t,o),deepgram:(e,t,o)=>Y(e,"deepgram",t,o),gladia:(e,t,o)=>Y(e,"gladia",t,o),lmnt:(e,t,o)=>Y(e,"lmnt",t,o),hume:(e,t,o)=>Y(e,"hume",t,o),revai:(e,t,o)=>Y(e,"revai",t,o),baseten:(e,t,o)=>J(e,t,o,"baseten"),huggingface:(e,t,o)=>J(e,t,o,"huggingface")};function X(e,t,o,r,n){"vercel"!==t?Q[t](e,o,r):n&&function(e,t,o){const r="gateway",n=new Set(["only","order","tags","models"]),i=new Set(["byok","provider_timeouts"]),a={zero_data_retention:"zeroDataRetention",disallow_prompt_training:"disallowPromptTraining",hipaa_compliant:"hipaaCompliant",quota_entity_id:"quotaEntityId",provider_timeouts:"providerTimeouts"};if(!(a[t]||new Set(["sort","caching","user","zeroDataRetention","disallowPromptTraining","hipaaCompliant","quotaEntityId","providerTimeouts"]).has(t)||n.has(t)||i.has(t)))return;const s=a[t]??t;n.has(t)?K(e,r,s,U(o)):i.has(t)?D(e,r,s,o):K(e,r,s,V(o))}(e,o,r)}function Z(e,t={}){const o="string"==typeof e?E(function(e){const t=new URL(e);if("llm:"!==t.protocol)throw new Error(`Invalid scheme: expected "llm://", got "${t.protocol}//"`);const{host:o,alias:r}=l(t.host),n=t.pathname.replace(/^\//,""),i=t.username||void 0,a=t.password||void 0,s={};for(const[e,o]of t.searchParams)s[e]=o;return{raw:e,host:o,hostAlias:r,model:n,label:i,apiKey:a,params:s}}(e),t):"changes"in e&&"subProvider"in e?e:E(e,t),r={};if(!o.provider)return{provider:o.provider,subProvider:o.subProvider,providerOptions:r};const n=t.includeGatewayOptions??"vercel"===o.provider;for(const[e,t]of Object.entries(o.config.params))X(r,o.provider,e,t,n);return"vercel"===o.provider||r[i=o.provider,$[i]]?{provider:o.provider,subProvider:o.subProvider,providerOptions:r}:{provider:o.provider,subProvider:o.subProvider,providerOptions:{}};var i}