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/index.cjs CHANGED
@@ -1,1351 +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/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- HOST_ALIASES: () => HOST_ALIASES,
24
- build: () => build,
25
- normalize: () => normalize,
26
- parse: () => parse,
27
- resolveHostAlias: () => resolveHostAlias,
28
- validate: () => validate
29
- });
30
- module.exports = __toCommonJS(index_exports);
31
-
32
- // src/provider-core.ts
33
- function hasOwn(object, key) {
34
- return Object.prototype.hasOwnProperty.call(object, key);
35
- }
36
- var HOST_ALIASES = {
37
- openai: "api.openai.com",
38
- azure: "models.inference.ai.azure.com",
39
- anthropic: "api.anthropic.com",
40
- google: "generativelanguage.googleapis.com",
41
- "google-vertex": "aiplatform.googleapis.com",
42
- aistudio: "generativelanguage.googleapis.com",
43
- mistral: "api.mistral.ai",
44
- cohere: "api.cohere.com",
45
- bedrock: "bedrock-runtime.us-east-1.amazonaws.com",
46
- openrouter: "openrouter.ai",
47
- vercel: "gateway.ai.vercel.app",
48
- alibaba: "dashscope-intl.aliyuncs.com",
49
- alibabacloud: "dashscope-intl.aliyuncs.com",
50
- dashscope: "dashscope-intl.aliyuncs.com",
51
- groq: "api.groq.com",
52
- fal: "fal.run",
53
- fireworks: "api.fireworks.ai",
54
- fireworksai: "api.fireworks.ai",
55
- "black-forest-labs": "api.bfl.ai",
56
- bfl: "api.bfl.ai",
57
- deepseek: "api.deepseek.com",
58
- moonshotai: "api.moonshot.ai",
59
- moonshot: "api.moonshot.ai",
60
- perplexity: "api.perplexity.ai",
61
- venice: "api.venice.ai",
62
- parasail: "api.parasail.io",
63
- deepinfra: "api.deepinfra.com",
64
- atlascloud: "api.atlascloud.ai",
65
- novita: "api.novita.ai",
66
- novitaai: "api.novita.ai",
67
- grok: "api.x.ai",
68
- xai: "api.x.ai",
69
- together: "api.together.xyz",
70
- togetherai: "api.together.xyz",
71
- cerebras: "api.cerebras.ai",
72
- replicate: "api.replicate.com",
73
- prodia: "api.prodia.com",
74
- luma: "api.lumalabs.ai",
75
- bytedance: "ark.cn-beijing.volces.com",
76
- kling: "api.klingai.com",
77
- elevenlabs: "api.elevenlabs.io",
78
- assemblyai: "api.assemblyai.com",
79
- deepgram: "api.deepgram.com",
80
- gladia: "api.gladia.io",
81
- lmnt: "api.lmnt.com",
82
- hume: "api.hume.ai",
83
- revai: "api.rev.ai",
84
- baseten: "api.baseten.co",
85
- huggingface: "api-inference.huggingface.co",
86
- wandb: "api.inference.wandb.ai",
87
- weightsandbiases: "api.inference.wandb.ai",
88
- baidu: "qianfan.baidubce.com",
89
- qianfan: "qianfan.baidubce.com",
90
- vertex: "aiplatform.googleapis.com",
91
- xiaomi: "api.xiaomimimo.com",
92
- minimax: "api.minimax.io"
93
- };
94
- var HOST_ALIAS_PROVIDERS = {
95
- aistudio: "google",
96
- vertex: "google-vertex",
97
- grok: "xai",
98
- bfl: "black-forest-labs",
99
- moonshot: "moonshotai",
100
- alibaba: "alibaba",
101
- alibabacloud: "alibaba",
102
- dashscope: "alibaba",
103
- togetherai: "together",
104
- fireworksai: "fireworks"
105
- };
106
- function readProcessEnv() {
107
- return typeof process !== "undefined" && process.env ? process.env : {};
108
- }
109
- function normalizeHostValue(value) {
110
- const trimmed = value.trim();
111
- if (!trimmed) return trimmed;
112
- try {
113
- if (trimmed.includes("://")) {
114
- return new URL(trimmed).host;
115
- }
116
- } catch {
117
- }
118
- return trimmed.replace(/^\/\//, "").split("/")[0] ?? trimmed;
119
- }
120
- function envHostOverride(alias, env) {
121
- const upper = alias.toUpperCase();
122
- const override = env[`LLM_STRINGS_${upper}_HOST`] ?? env[`LLM_STRINGS_HOST_${upper}`];
123
- return override?.trim() ? override : void 0;
124
- }
125
- function resolveHostAlias(host, env = readProcessEnv()) {
126
- const normalizedHost = host.toLowerCase();
127
- if (!hasOwn(HOST_ALIASES, normalizedHost)) {
128
- return { host };
129
- }
130
- const alias = normalizedHost;
131
- const override = envHostOverride(alias, env);
132
- return {
133
- host: normalizeHostValue(override ?? HOST_ALIASES[alias]),
134
- alias
135
- };
136
- }
137
- function providerFromHostAlias(alias) {
138
- const normalizedAlias = alias.toLowerCase();
139
- if (hasOwn(PROVIDER_PARAMS, normalizedAlias)) {
140
- return normalizedAlias;
141
- }
142
- if (hasOwn(HOST_ALIAS_PROVIDERS, normalizedAlias)) {
143
- return HOST_ALIAS_PROVIDERS[normalizedAlias];
144
- }
145
- return void 0;
146
- }
147
- function detectProvider(host) {
148
- host = host.toLowerCase();
149
- if (host.includes("openrouter")) return "openrouter";
150
- if (host.includes("gateway.ai.vercel")) return "vercel";
151
- if (host.includes("amazonaws") || host.includes("bedrock")) return "bedrock";
152
- if (host.includes("aiplatform.googleapis")) return "google-vertex";
153
- if (host.includes("api.x.ai")) return "xai";
154
- if (host.includes("groq")) return "groq";
155
- if (host.includes("fal.run") || host.includes("fal.ai")) return "fal";
156
- if (host.includes("deepinfra")) return "deepinfra";
157
- if (host.includes("bfl.ai")) return "black-forest-labs";
158
- if (host.includes("together")) return "together";
159
- if (host.includes("fireworks")) return "fireworks";
160
- if (host.includes("deepseek")) return "deepseek";
161
- if (host.includes("moonshot")) return "moonshotai";
162
- if (host.includes("perplexity")) return "perplexity";
163
- if (host.includes("dashscope") || host.includes("aliyuncs")) return "alibaba";
164
- if (host.includes("cerebras")) return "cerebras";
165
- if (host.includes("replicate")) return "replicate";
166
- if (host.includes("prodia")) return "prodia";
167
- if (host.includes("lumalabs") || host.includes("luma")) return "luma";
168
- if (host.includes("volces") || host.includes("bytedance")) return "bytedance";
169
- if (host.includes("kling")) return "kling";
170
- if (host.includes("elevenlabs")) return "elevenlabs";
171
- if (host.includes("assemblyai")) return "assemblyai";
172
- if (host.includes("deepgram")) return "deepgram";
173
- if (host.includes("gladia")) return "gladia";
174
- if (host.includes("lmnt")) return "lmnt";
175
- if (host.includes("hume")) return "hume";
176
- if (host.includes("rev.ai")) return "revai";
177
- if (host.includes("baseten")) return "baseten";
178
- if (host.includes("huggingface")) return "huggingface";
179
- if (host.includes("azure")) return "azure";
180
- if (host.includes("openai")) return "openai";
181
- if (host.includes("anthropic") || host.includes("claude")) return "anthropic";
182
- if (host.includes("googleapis") || host.includes("google")) return "google";
183
- if (host.includes("mistral")) return "mistral";
184
- if (host.includes("cohere")) return "cohere";
185
- return void 0;
186
- }
187
- var ALIASES = {
188
- // temperature
189
- temp: "temperature",
190
- // max_tokens
191
- max: "max_tokens",
192
- max_out: "max_tokens",
193
- max_output: "max_tokens",
194
- max_output_tokens: "max_tokens",
195
- max_completion_tokens: "max_tokens",
196
- maxOutputTokens: "max_tokens",
197
- maxTokens: "max_tokens",
198
- // top_p
199
- topp: "top_p",
200
- topP: "top_p",
201
- nucleus: "top_p",
202
- // top_k
203
- topk: "top_k",
204
- topK: "top_k",
205
- // frequency_penalty
206
- freq: "frequency_penalty",
207
- freq_penalty: "frequency_penalty",
208
- frequencyPenalty: "frequency_penalty",
209
- repetition_penalty: "frequency_penalty",
210
- // presence_penalty
211
- pres: "presence_penalty",
212
- pres_penalty: "presence_penalty",
213
- presencePenalty: "presence_penalty",
214
- // stop
215
- stop_sequences: "stop",
216
- stopSequences: "stop",
217
- stop_sequence: "stop",
218
- // seed
219
- random_seed: "seed",
220
- randomSeed: "seed",
221
- // n (completions count)
222
- candidateCount: "n",
223
- candidate_count: "n",
224
- num_completions: "n",
225
- // effort / reasoning
226
- reasoning_effort: "effort",
227
- reasoning: "effort",
228
- // cache
229
- cache_control: "cache",
230
- cacheControl: "cache",
231
- cachePoint: "cache",
232
- cache_point: "cache"
233
- };
234
- var OPENAI_COMPATIBLE_PARAMS = {
235
- temperature: "temperature",
236
- max_tokens: "max_tokens",
237
- top_p: "top_p",
238
- top_k: "top_k",
239
- frequency_penalty: "frequency_penalty",
240
- presence_penalty: "presence_penalty",
241
- stop: "stop",
242
- n: "n",
243
- seed: "seed",
244
- stream: "stream",
245
- effort: "reasoning_effort"
246
- };
247
- var GOOGLE_COMPATIBLE_PARAMS = {
248
- temperature: "temperature",
249
- max_tokens: "maxOutputTokens",
250
- top_p: "topP",
251
- top_k: "topK",
252
- frequency_penalty: "frequencyPenalty",
253
- presence_penalty: "presencePenalty",
254
- stop: "stopSequences",
255
- n: "candidateCount",
256
- stream: "stream",
257
- seed: "seed",
258
- responseMimeType: "responseMimeType",
259
- responseSchema: "responseSchema"
260
- };
261
- var PROVIDER_PARAMS = {
262
- openai: {
263
- temperature: "temperature",
264
- max_tokens: "max_tokens",
265
- top_p: "top_p",
266
- frequency_penalty: "frequency_penalty",
267
- presence_penalty: "presence_penalty",
268
- stop: "stop",
269
- n: "n",
270
- seed: "seed",
271
- stream: "stream",
272
- effort: "reasoning_effort"
273
- },
274
- azure: OPENAI_COMPATIBLE_PARAMS,
275
- anthropic: {
276
- temperature: "temperature",
277
- max_tokens: "max_tokens",
278
- top_p: "top_p",
279
- top_k: "top_k",
280
- stop: "stop_sequences",
281
- stream: "stream",
282
- effort: "effort",
283
- cache: "cache_control",
284
- cache_ttl: "cache_ttl"
285
- },
286
- google: {
287
- temperature: "temperature",
288
- max_tokens: "maxOutputTokens",
289
- top_p: "topP",
290
- top_k: "topK",
291
- frequency_penalty: "frequencyPenalty",
292
- presence_penalty: "presencePenalty",
293
- stop: "stopSequences",
294
- n: "candidateCount",
295
- stream: "stream",
296
- seed: "seed",
297
- responseMimeType: "responseMimeType",
298
- responseSchema: "responseSchema"
299
- },
300
- "google-vertex": GOOGLE_COMPATIBLE_PARAMS,
301
- mistral: {
302
- temperature: "temperature",
303
- max_tokens: "max_tokens",
304
- top_p: "top_p",
305
- frequency_penalty: "frequency_penalty",
306
- presence_penalty: "presence_penalty",
307
- stop: "stop",
308
- n: "n",
309
- seed: "random_seed",
310
- stream: "stream",
311
- safe_prompt: "safe_prompt",
312
- min_tokens: "min_tokens"
313
- },
314
- cohere: {
315
- temperature: "temperature",
316
- max_tokens: "max_tokens",
317
- top_p: "p",
318
- top_k: "k",
319
- frequency_penalty: "frequency_penalty",
320
- presence_penalty: "presence_penalty",
321
- stop: "stop_sequences",
322
- stream: "stream",
323
- seed: "seed"
324
- },
325
- bedrock: {
326
- // Bedrock Converse API uses camelCase
327
- temperature: "temperature",
328
- max_tokens: "maxTokens",
329
- top_p: "topP",
330
- top_k: "topK",
331
- // Claude models via additionalModelRequestFields
332
- stop: "stopSequences",
333
- stream: "stream",
334
- cache: "cache_control",
335
- cache_ttl: "cache_ttl"
336
- },
337
- openrouter: {
338
- // OpenAI-compatible API with extra routing params
339
- temperature: "temperature",
340
- max_tokens: "max_tokens",
341
- top_p: "top_p",
342
- top_k: "top_k",
343
- frequency_penalty: "frequency_penalty",
344
- presence_penalty: "presence_penalty",
345
- stop: "stop",
346
- n: "n",
347
- seed: "seed",
348
- stream: "stream",
349
- effort: "reasoning_effort"
350
- },
351
- vercel: {
352
- // OpenAI-compatible gateway
353
- temperature: "temperature",
354
- max_tokens: "max_tokens",
355
- top_p: "top_p",
356
- top_k: "top_k",
357
- frequency_penalty: "frequency_penalty",
358
- presence_penalty: "presence_penalty",
359
- stop: "stop",
360
- n: "n",
361
- seed: "seed",
362
- stream: "stream",
363
- effort: "reasoning_effort"
364
- },
365
- xai: OPENAI_COMPATIBLE_PARAMS,
366
- groq: OPENAI_COMPATIBLE_PARAMS,
367
- fal: {},
368
- deepinfra: OPENAI_COMPATIBLE_PARAMS,
369
- "black-forest-labs": {},
370
- together: OPENAI_COMPATIBLE_PARAMS,
371
- fireworks: OPENAI_COMPATIBLE_PARAMS,
372
- deepseek: OPENAI_COMPATIBLE_PARAMS,
373
- moonshotai: OPENAI_COMPATIBLE_PARAMS,
374
- perplexity: OPENAI_COMPATIBLE_PARAMS,
375
- alibaba: OPENAI_COMPATIBLE_PARAMS,
376
- cerebras: OPENAI_COMPATIBLE_PARAMS,
377
- replicate: {},
378
- prodia: {},
379
- luma: {},
380
- bytedance: {},
381
- kling: {},
382
- elevenlabs: {},
383
- assemblyai: {},
384
- deepgram: {},
385
- gladia: {},
386
- lmnt: {},
387
- hume: {},
388
- revai: {},
389
- baseten: OPENAI_COMPATIBLE_PARAMS,
390
- huggingface: OPENAI_COMPATIBLE_PARAMS
391
- };
392
- var OPENAI_COMPATIBLE_PARAM_SPECS = {
393
- temperature: {
394
- type: "number",
395
- min: 0,
396
- max: 2,
397
- default: 0.7,
398
- description: "Controls randomness"
399
- },
400
- max_tokens: {
401
- type: "number",
402
- min: 1,
403
- default: 4096,
404
- description: "Maximum output tokens"
405
- },
406
- top_p: {
407
- type: "number",
408
- min: 0,
409
- max: 1,
410
- default: 1,
411
- description: "Nucleus sampling"
412
- },
413
- top_k: {
414
- type: "number",
415
- min: 0,
416
- default: 40,
417
- description: "Top-K sampling"
418
- },
419
- frequency_penalty: {
420
- type: "number",
421
- min: -2,
422
- max: 2,
423
- default: 0,
424
- description: "Penalize frequent tokens"
425
- },
426
- presence_penalty: {
427
- type: "number",
428
- min: -2,
429
- max: 2,
430
- default: 0,
431
- description: "Penalize repeated topics"
432
- },
433
- stop: { type: "string", description: "Stop sequences" },
434
- n: { type: "number", min: 1, default: 1, description: "Completions count" },
435
- seed: { type: "number", description: "Random seed" },
436
- stream: { type: "boolean", default: false, description: "Stream response" },
437
- reasoning_effort: {
438
- type: "string",
439
- values: ["none", "minimal", "low", "medium", "high", "xhigh"],
440
- default: "medium",
441
- description: "Reasoning effort"
442
- }
443
- };
444
- var GOOGLE_COMPATIBLE_PARAM_SPECS = {
445
- temperature: {
446
- type: "number",
447
- min: 0,
448
- max: 2,
449
- default: 0.7,
450
- description: "Controls randomness"
451
- },
452
- maxOutputTokens: {
453
- type: "number",
454
- min: 1,
455
- default: 4096,
456
- description: "Maximum output tokens"
457
- },
458
- topP: {
459
- type: "number",
460
- min: 0,
461
- max: 1,
462
- default: 1,
463
- description: "Nucleus sampling"
464
- },
465
- topK: {
466
- type: "number",
467
- min: 0,
468
- default: 40,
469
- description: "Top-K sampling"
470
- },
471
- frequencyPenalty: {
472
- type: "number",
473
- min: -2,
474
- max: 2,
475
- default: 0,
476
- description: "Penalize frequent tokens"
477
- },
478
- presencePenalty: {
479
- type: "number",
480
- min: -2,
481
- max: 2,
482
- default: 0,
483
- description: "Penalize repeated topics"
484
- },
485
- stopSequences: { type: "string", description: "Stop sequences" },
486
- candidateCount: {
487
- type: "number",
488
- min: 1,
489
- default: 1,
490
- description: "Candidate count"
491
- },
492
- stream: { type: "boolean", default: false, description: "Stream response" },
493
- seed: { type: "number", description: "Random seed" },
494
- responseMimeType: { type: "string", description: "Response MIME type" },
495
- responseSchema: { type: "string", description: "Response schema" }
496
- };
497
- var PARAM_SPECS = {
498
- openai: {
499
- temperature: {
500
- type: "number",
501
- min: 0,
502
- max: 2,
503
- default: 0.7,
504
- description: "Controls randomness"
505
- },
506
- max_tokens: {
507
- type: "number",
508
- min: 1,
509
- default: 4096,
510
- description: "Maximum output tokens"
511
- },
512
- top_p: {
513
- type: "number",
514
- min: 0,
515
- max: 1,
516
- default: 1,
517
- description: "Nucleus sampling"
518
- },
519
- frequency_penalty: {
520
- type: "number",
521
- min: -2,
522
- max: 2,
523
- default: 0,
524
- description: "Penalize frequent tokens"
525
- },
526
- presence_penalty: {
527
- type: "number",
528
- min: -2,
529
- max: 2,
530
- default: 0,
531
- description: "Penalize repeated topics"
532
- },
533
- stop: { type: "string", description: "Stop sequences" },
534
- n: { type: "number", min: 1, default: 1, description: "Completions count" },
535
- seed: { type: "number", description: "Random seed" },
536
- stream: { type: "boolean", default: false, description: "Stream response" },
537
- reasoning_effort: {
538
- type: "string",
539
- values: ["none", "minimal", "low", "medium", "high", "xhigh"],
540
- default: "medium",
541
- description: "Reasoning effort"
542
- }
543
- },
544
- azure: OPENAI_COMPATIBLE_PARAM_SPECS,
545
- anthropic: {
546
- temperature: {
547
- type: "number",
548
- min: 0,
549
- max: 1,
550
- default: 0.7,
551
- description: "Controls randomness"
552
- },
553
- max_tokens: {
554
- type: "number",
555
- min: 1,
556
- default: 4096,
557
- description: "Maximum output tokens"
558
- },
559
- top_p: {
560
- type: "number",
561
- min: 0,
562
- max: 1,
563
- default: 1,
564
- description: "Nucleus sampling"
565
- },
566
- top_k: {
567
- type: "number",
568
- min: 0,
569
- default: 40,
570
- description: "Top-K sampling"
571
- },
572
- stop_sequences: { type: "string", description: "Stop sequences" },
573
- stream: { type: "boolean", default: false, description: "Stream response" },
574
- effort: {
575
- type: "string",
576
- values: ["low", "medium", "high", "max"],
577
- default: "medium",
578
- description: "Thinking effort"
579
- },
580
- cache_control: {
581
- type: "string",
582
- values: ["ephemeral"],
583
- default: "ephemeral",
584
- description: "Cache control"
585
- },
586
- cache_ttl: {
587
- type: "string",
588
- values: ["5m", "1h"],
589
- default: "5m",
590
- description: "Cache TTL"
591
- }
592
- },
593
- google: {
594
- temperature: {
595
- type: "number",
596
- min: 0,
597
- max: 2,
598
- default: 0.7,
599
- description: "Controls randomness"
600
- },
601
- maxOutputTokens: {
602
- type: "number",
603
- min: 1,
604
- default: 4096,
605
- description: "Maximum output tokens"
606
- },
607
- topP: {
608
- type: "number",
609
- min: 0,
610
- max: 1,
611
- default: 1,
612
- description: "Nucleus sampling"
613
- },
614
- topK: {
615
- type: "number",
616
- min: 0,
617
- default: 40,
618
- description: "Top-K sampling"
619
- },
620
- frequencyPenalty: {
621
- type: "number",
622
- min: -2,
623
- max: 2,
624
- default: 0,
625
- description: "Penalize frequent tokens"
626
- },
627
- presencePenalty: {
628
- type: "number",
629
- min: -2,
630
- max: 2,
631
- default: 0,
632
- description: "Penalize repeated topics"
633
- },
634
- stopSequences: { type: "string", description: "Stop sequences" },
635
- candidateCount: {
636
- type: "number",
637
- min: 1,
638
- default: 1,
639
- description: "Candidate count"
640
- },
641
- stream: { type: "boolean", default: false, description: "Stream response" },
642
- seed: { type: "number", description: "Random seed" },
643
- responseMimeType: { type: "string", description: "Response MIME type" },
644
- responseSchema: { type: "string", description: "Response schema" }
645
- },
646
- "google-vertex": GOOGLE_COMPATIBLE_PARAM_SPECS,
647
- mistral: {
648
- temperature: {
649
- type: "number",
650
- min: 0,
651
- max: 1,
652
- default: 0.7,
653
- description: "Controls randomness"
654
- },
655
- max_tokens: {
656
- type: "number",
657
- min: 1,
658
- default: 4096,
659
- description: "Maximum output tokens"
660
- },
661
- top_p: {
662
- type: "number",
663
- min: 0,
664
- max: 1,
665
- default: 1,
666
- description: "Nucleus sampling"
667
- },
668
- frequency_penalty: {
669
- type: "number",
670
- min: -2,
671
- max: 2,
672
- default: 0,
673
- description: "Penalize frequent tokens"
674
- },
675
- presence_penalty: {
676
- type: "number",
677
- min: -2,
678
- max: 2,
679
- default: 0,
680
- description: "Penalize repeated topics"
681
- },
682
- stop: { type: "string", description: "Stop sequences" },
683
- n: { type: "number", min: 1, default: 1, description: "Completions count" },
684
- random_seed: { type: "number", description: "Random seed" },
685
- stream: { type: "boolean", default: false, description: "Stream response" },
686
- safe_prompt: {
687
- type: "boolean",
688
- default: false,
689
- description: "Enable safe prompt"
690
- },
691
- min_tokens: {
692
- type: "number",
693
- min: 0,
694
- default: 0,
695
- description: "Minimum tokens"
696
- }
697
- },
698
- cohere: {
699
- temperature: {
700
- type: "number",
701
- min: 0,
702
- max: 1,
703
- default: 0.7,
704
- description: "Controls randomness"
705
- },
706
- max_tokens: {
707
- type: "number",
708
- min: 1,
709
- default: 4096,
710
- description: "Maximum output tokens"
711
- },
712
- p: {
713
- type: "number",
714
- min: 0,
715
- max: 1,
716
- default: 1,
717
- description: "Nucleus sampling (p)"
718
- },
719
- k: {
720
- type: "number",
721
- min: 0,
722
- max: 500,
723
- default: 40,
724
- description: "Top-K sampling (k)"
725
- },
726
- frequency_penalty: {
727
- type: "number",
728
- min: 0,
729
- max: 1,
730
- default: 0,
731
- description: "Penalize frequent tokens"
732
- },
733
- presence_penalty: {
734
- type: "number",
735
- min: 0,
736
- max: 1,
737
- default: 0,
738
- description: "Penalize repeated topics"
739
- },
740
- stop_sequences: { type: "string", description: "Stop sequences" },
741
- stream: { type: "boolean", default: false, description: "Stream response" },
742
- seed: { type: "number", description: "Random seed" }
743
- },
744
- bedrock: {
745
- // Converse API inferenceConfig params
746
- temperature: {
747
- type: "number",
748
- min: 0,
749
- max: 1,
750
- default: 0.7,
751
- description: "Controls randomness"
752
- },
753
- maxTokens: {
754
- type: "number",
755
- min: 1,
756
- default: 4096,
757
- description: "Maximum output tokens"
758
- },
759
- topP: {
760
- type: "number",
761
- min: 0,
762
- max: 1,
763
- default: 1,
764
- description: "Nucleus sampling"
765
- },
766
- topK: {
767
- type: "number",
768
- min: 0,
769
- default: 40,
770
- description: "Top-K sampling"
771
- },
772
- stopSequences: { type: "string", description: "Stop sequences" },
773
- stream: { type: "boolean", default: false, description: "Stream response" },
774
- cache_control: {
775
- type: "string",
776
- values: ["ephemeral"],
777
- default: "ephemeral",
778
- description: "Cache control"
779
- },
780
- cache_ttl: {
781
- type: "string",
782
- values: ["5m", "1h"],
783
- default: "5m",
784
- description: "Cache TTL"
785
- }
786
- },
787
- openrouter: {
788
- // Loose validation — proxies to many providers with varying ranges
789
- temperature: {
790
- type: "number",
791
- min: 0,
792
- max: 2,
793
- default: 0.7,
794
- description: "Controls randomness"
795
- },
796
- max_tokens: {
797
- type: "number",
798
- min: 1,
799
- default: 4096,
800
- description: "Maximum output tokens"
801
- },
802
- top_p: {
803
- type: "number",
804
- min: 0,
805
- max: 1,
806
- default: 1,
807
- description: "Nucleus sampling"
808
- },
809
- top_k: {
810
- type: "number",
811
- min: 0,
812
- default: 40,
813
- description: "Top-K sampling"
814
- },
815
- frequency_penalty: {
816
- type: "number",
817
- min: -2,
818
- max: 2,
819
- default: 0,
820
- description: "Penalize frequent tokens"
821
- },
822
- presence_penalty: {
823
- type: "number",
824
- min: -2,
825
- max: 2,
826
- default: 0,
827
- description: "Penalize repeated topics"
828
- },
829
- stop: { type: "string", description: "Stop sequences" },
830
- n: { type: "number", min: 1, default: 1, description: "Completions count" },
831
- seed: { type: "number", description: "Random seed" },
832
- stream: { type: "boolean", default: false, description: "Stream response" },
833
- reasoning_effort: {
834
- type: "string",
835
- values: ["none", "minimal", "low", "medium", "high", "xhigh"],
836
- default: "medium",
837
- description: "Reasoning effort"
838
- }
839
- },
840
- vercel: {
841
- // Loose validation — proxies to many providers with varying ranges
842
- temperature: {
843
- type: "number",
844
- min: 0,
845
- max: 2,
846
- default: 0.7,
847
- description: "Controls randomness"
848
- },
849
- max_tokens: {
850
- type: "number",
851
- min: 1,
852
- default: 4096,
853
- description: "Maximum output tokens"
854
- },
855
- top_p: {
856
- type: "number",
857
- min: 0,
858
- max: 1,
859
- default: 1,
860
- description: "Nucleus sampling"
861
- },
862
- top_k: {
863
- type: "number",
864
- min: 0,
865
- default: 40,
866
- description: "Top-K sampling"
867
- },
868
- frequency_penalty: {
869
- type: "number",
870
- min: -2,
871
- max: 2,
872
- default: 0,
873
- description: "Penalize frequent tokens"
874
- },
875
- presence_penalty: {
876
- type: "number",
877
- min: -2,
878
- max: 2,
879
- default: 0,
880
- description: "Penalize repeated topics"
881
- },
882
- stop: { type: "string", description: "Stop sequences" },
883
- n: { type: "number", min: 1, default: 1, description: "Completions count" },
884
- seed: { type: "number", description: "Random seed" },
885
- stream: { type: "boolean", default: false, description: "Stream response" },
886
- reasoning_effort: {
887
- type: "string",
888
- values: ["none", "minimal", "low", "medium", "high", "xhigh"],
889
- default: "medium",
890
- description: "Reasoning effort"
891
- }
892
- },
893
- xai: OPENAI_COMPATIBLE_PARAM_SPECS,
894
- groq: OPENAI_COMPATIBLE_PARAM_SPECS,
895
- fal: {},
896
- deepinfra: OPENAI_COMPATIBLE_PARAM_SPECS,
897
- "black-forest-labs": {},
898
- together: OPENAI_COMPATIBLE_PARAM_SPECS,
899
- fireworks: OPENAI_COMPATIBLE_PARAM_SPECS,
900
- deepseek: OPENAI_COMPATIBLE_PARAM_SPECS,
901
- moonshotai: OPENAI_COMPATIBLE_PARAM_SPECS,
902
- perplexity: OPENAI_COMPATIBLE_PARAM_SPECS,
903
- alibaba: OPENAI_COMPATIBLE_PARAM_SPECS,
904
- cerebras: OPENAI_COMPATIBLE_PARAM_SPECS,
905
- replicate: {},
906
- prodia: {},
907
- luma: {},
908
- bytedance: {},
909
- kling: {},
910
- elevenlabs: {},
911
- assemblyai: {},
912
- deepgram: {},
913
- gladia: {},
914
- lmnt: {},
915
- hume: {},
916
- revai: {},
917
- baseten: OPENAI_COMPATIBLE_PARAM_SPECS,
918
- huggingface: OPENAI_COMPATIBLE_PARAM_SPECS
919
- };
920
- function isReasoningModel(model) {
921
- const name = model.includes("/") ? model.split("/").pop() : model;
922
- return /^o[134]/.test(name);
923
- }
924
- function canHostOpenAIModels(provider) {
925
- return provider === "openai" || provider === "openrouter" || provider === "vercel";
926
- }
927
- function isGatewayProvider(provider) {
928
- return provider === "openrouter" || provider === "vercel";
929
- }
930
- function detectGatewaySubProvider(model) {
931
- const slash = model.indexOf("/");
932
- if (slash < 1) return void 0;
933
- const prefix = model.slice(0, slash);
934
- const direct = [
935
- "openai",
936
- "anthropic",
937
- "google",
938
- "mistral",
939
- "cohere"
940
- ];
941
- return direct.find((p) => p === prefix);
942
- }
943
- var REASONING_MODEL_UNSUPPORTED = /* @__PURE__ */ new Set([
944
- "temperature",
945
- "top_p",
946
- "frequency_penalty",
947
- "presence_penalty",
948
- "n"
949
- ]);
950
- function detectBedrockModelFamily(model) {
951
- const parts = model.split(".");
952
- let prefix = parts[0];
953
- if (["us", "eu", "apac", "global"].includes(prefix) && parts.length > 1) {
954
- prefix = parts[1];
955
- }
956
- const families = [
957
- "anthropic",
958
- "meta",
959
- "amazon",
960
- "mistral",
961
- "cohere",
962
- "ai21"
963
- ];
964
- return families.find((f) => prefix === f);
965
- }
966
- function bedrockSupportsCaching(model) {
967
- const family = detectBedrockModelFamily(model);
968
- if (family === "anthropic") return true;
969
- if (family === "amazon" && model.includes("nova")) return true;
970
- return false;
971
- }
972
- var CACHE_VALUES = {
973
- openai: void 0,
974
- // OpenAI auto-caches; no explicit param
975
- azure: void 0,
976
- anthropic: "ephemeral",
977
- google: void 0,
978
- // Google uses explicit caching API, not a param
979
- "google-vertex": void 0,
980
- mistral: void 0,
981
- cohere: void 0,
982
- bedrock: "ephemeral",
983
- // Supported for Claude models on Bedrock
984
- openrouter: void 0,
985
- // Depends on underlying provider
986
- vercel: void 0,
987
- // Depends on underlying provider
988
- xai: void 0,
989
- groq: void 0,
990
- fal: void 0,
991
- deepinfra: void 0,
992
- "black-forest-labs": void 0,
993
- together: void 0,
994
- fireworks: void 0,
995
- deepseek: void 0,
996
- moonshotai: void 0,
997
- perplexity: void 0,
998
- alibaba: void 0,
999
- cerebras: void 0,
1000
- replicate: void 0,
1001
- prodia: void 0,
1002
- luma: void 0,
1003
- bytedance: void 0,
1004
- kling: void 0,
1005
- elevenlabs: void 0,
1006
- assemblyai: void 0,
1007
- deepgram: void 0,
1008
- gladia: void 0,
1009
- lmnt: void 0,
1010
- hume: void 0,
1011
- revai: void 0,
1012
- baseten: void 0,
1013
- huggingface: void 0
1014
- };
1015
- var CACHE_TTLS = {
1016
- openai: void 0,
1017
- azure: void 0,
1018
- anthropic: ["5m", "1h"],
1019
- google: void 0,
1020
- "google-vertex": void 0,
1021
- mistral: void 0,
1022
- cohere: void 0,
1023
- bedrock: ["5m", "1h"],
1024
- // Claude on Bedrock uses same TTLs as direct Anthropic
1025
- openrouter: void 0,
1026
- vercel: void 0,
1027
- xai: void 0,
1028
- groq: void 0,
1029
- fal: void 0,
1030
- deepinfra: void 0,
1031
- "black-forest-labs": void 0,
1032
- together: void 0,
1033
- fireworks: void 0,
1034
- deepseek: void 0,
1035
- moonshotai: void 0,
1036
- perplexity: void 0,
1037
- alibaba: void 0,
1038
- cerebras: void 0,
1039
- replicate: void 0,
1040
- prodia: void 0,
1041
- luma: void 0,
1042
- bytedance: void 0,
1043
- kling: void 0,
1044
- elevenlabs: void 0,
1045
- assemblyai: void 0,
1046
- deepgram: void 0,
1047
- gladia: void 0,
1048
- lmnt: void 0,
1049
- hume: void 0,
1050
- revai: void 0,
1051
- baseten: void 0,
1052
- huggingface: void 0
1053
- };
1054
- var DURATION_RE = /^\d+[mh]$/;
1055
-
1056
- // src/parse.ts
1057
- function parse(connectionString) {
1058
- const url = new URL(connectionString);
1059
- if (url.protocol !== "llm:") {
1060
- throw new Error(
1061
- `Invalid scheme: expected "llm://", got "${url.protocol}//"`
1062
- );
1063
- }
1064
- const { host, alias: hostAlias } = resolveHostAlias(url.host);
1065
- const model = url.pathname.replace(/^\//, "");
1066
- const label = url.username || void 0;
1067
- const apiKey = url.password || void 0;
1068
- const params = {};
1069
- for (const [key, value] of url.searchParams) {
1070
- params[key] = value;
1071
- }
1072
- return {
1073
- raw: connectionString,
1074
- host,
1075
- hostAlias,
1076
- model,
1077
- label,
1078
- apiKey,
1079
- params
1080
- };
1081
- }
1082
- function build(config) {
1083
- const { host } = resolveHostAlias(config.host);
1084
- const auth = config.label || config.apiKey ? `${config.label ?? ""}${config.apiKey ? `:${config.apiKey}` : ""}@` : "";
1085
- const query = new URLSearchParams(config.params).toString();
1086
- const qs = query ? `?${query}` : "";
1087
- return `llm://${auth}${host}/${config.model}${qs}`;
1088
- }
1089
-
1090
- // src/normalize.ts
1091
- function normalize(config, options = {}) {
1092
- const provider = (config.hostAlias ? providerFromHostAlias(config.hostAlias) : void 0) ?? detectProvider(config.host);
1093
- const subProvider = provider && isGatewayProvider(provider) ? detectGatewaySubProvider(config.model) : void 0;
1094
- const changes = [];
1095
- const params = {};
1096
- for (const [rawKey, value] of Object.entries(config.params)) {
1097
- let key = rawKey;
1098
- if (ALIASES[key]) {
1099
- const canonical = ALIASES[key];
1100
- if (options.verbose) {
1101
- changes.push({
1102
- from: key,
1103
- to: canonical,
1104
- value,
1105
- reason: `alias: "${key}" \u2192 "${canonical}"`
1106
- });
1107
- }
1108
- key = canonical;
1109
- }
1110
- if (key === "cache" && provider) {
1111
- let cacheValue = CACHE_VALUES[provider];
1112
- if (provider === "bedrock" && !bedrockSupportsCaching(config.model)) {
1113
- cacheValue = void 0;
1114
- }
1115
- if (!cacheValue) {
1116
- if (options.verbose) {
1117
- changes.push({
1118
- from: "cache",
1119
- to: "(dropped)",
1120
- value,
1121
- reason: `${provider} does not use a cache param for this model (caching is automatic or unsupported)`
1122
- });
1123
- }
1124
- continue;
1125
- }
1126
- const isBool = value === "true" || value === "1" || value === "yes";
1127
- const isDuration = DURATION_RE.test(value);
1128
- if (isBool || isDuration) {
1129
- const providerKey = PROVIDER_PARAMS[provider]?.["cache"] ?? "cache";
1130
- if (options.verbose) {
1131
- changes.push({
1132
- from: "cache",
1133
- to: providerKey,
1134
- value: cacheValue,
1135
- reason: `cache=${value} \u2192 ${providerKey}=${cacheValue} for ${provider}`
1136
- });
1137
- }
1138
- params[providerKey] = cacheValue;
1139
- if (isDuration && CACHE_TTLS[provider]) {
1140
- if (options.verbose) {
1141
- changes.push({
1142
- from: "cache",
1143
- to: "cache_ttl",
1144
- value,
1145
- reason: `cache=${value} \u2192 cache_ttl=${value} for ${provider}`
1146
- });
1147
- }
1148
- params["cache_ttl"] = value;
1149
- }
1150
- continue;
1151
- }
1152
- }
1153
- if (provider && PROVIDER_PARAMS[provider]) {
1154
- const providerKey = PROVIDER_PARAMS[provider][key];
1155
- if (providerKey && providerKey !== key) {
1156
- if (options.verbose) {
1157
- changes.push({
1158
- from: key,
1159
- to: providerKey,
1160
- value,
1161
- reason: `${provider} uses "${providerKey}" instead of "${key}"`
1162
- });
1163
- }
1164
- key = providerKey;
1165
- }
1166
- }
1167
- if (provider && canHostOpenAIModels(provider) && isReasoningModel(config.model) && key === "max_tokens") {
1168
- if (options.verbose) {
1169
- changes.push({
1170
- from: "max_tokens",
1171
- to: "max_completion_tokens",
1172
- value,
1173
- reason: "OpenAI reasoning models use max_completion_tokens instead of max_tokens"
1174
- });
1175
- }
1176
- key = "max_completion_tokens";
1177
- }
1178
- params[key] = value;
1179
- }
1180
- return {
1181
- config: { ...config, params },
1182
- provider,
1183
- subProvider,
1184
- changes
1185
- };
1186
- }
1187
-
1188
- // src/validate.ts
1189
- function buildReverseParamMap(provider) {
1190
- const map = {};
1191
- for (const [canonical, specific] of Object.entries(
1192
- PROVIDER_PARAMS[provider]
1193
- )) {
1194
- map[specific] = canonical;
1195
- }
1196
- return map;
1197
- }
1198
- function lookupSubProviderSpec(gatewayParamName, gatewayReverseMap, subProvider) {
1199
- const canonical = gatewayReverseMap[gatewayParamName] ?? gatewayParamName;
1200
- const subProviderKey = PROVIDER_PARAMS[subProvider]?.[canonical];
1201
- if (!subProviderKey) return { spec: void 0, canonical };
1202
- return { spec: PARAM_SPECS[subProvider]?.[subProviderKey], canonical };
1203
- }
1204
- function buildSubProviderKnownParams(gateway, subProvider) {
1205
- const known = /* @__PURE__ */ new Set();
1206
- const subProviderCanonicals = new Set(
1207
- Object.keys(PROVIDER_PARAMS[subProvider])
1208
- );
1209
- for (const [canonical, gatewaySpecific] of Object.entries(
1210
- PROVIDER_PARAMS[gateway]
1211
- )) {
1212
- if (subProviderCanonicals.has(canonical)) {
1213
- known.add(gatewaySpecific);
1214
- }
1215
- }
1216
- return known;
1217
- }
1218
- function validate(connectionString, options = {}) {
1219
- const parsed = parse(connectionString);
1220
- const { config, provider, subProvider } = normalize(parsed);
1221
- const issues = [];
1222
- if (!provider) {
1223
- issues.push({
1224
- param: "host",
1225
- value: config.host,
1226
- message: `Unknown provider for host "${config.host}". Validation skipped.`,
1227
- severity: options.strict ? "error" : "warning"
1228
- });
1229
- return issues;
1230
- }
1231
- const effectiveProvider = subProvider ?? provider;
1232
- const specs = PARAM_SPECS[effectiveProvider];
1233
- const gatewayReverseMap = subProvider ? buildReverseParamMap(provider) : void 0;
1234
- const knownParams = subProvider ? buildSubProviderKnownParams(provider, subProvider) : new Set(Object.values(PROVIDER_PARAMS[provider]));
1235
- for (const [key, value] of Object.entries(config.params)) {
1236
- if (canHostOpenAIModels(provider) && isReasoningModel(config.model) && REASONING_MODEL_UNSUPPORTED.has(key)) {
1237
- issues.push({
1238
- param: key,
1239
- value,
1240
- message: `"${key}" is not supported by OpenAI reasoning model "${config.model}". Use "reasoning_effort" instead of temperature for controlling output.`,
1241
- severity: "error"
1242
- });
1243
- continue;
1244
- }
1245
- if (provider === "bedrock") {
1246
- const family = detectBedrockModelFamily(config.model);
1247
- if (key === "topK" && family && family !== "anthropic" && family !== "cohere" && family !== "mistral") {
1248
- issues.push({
1249
- param: key,
1250
- value,
1251
- message: `"topK" is not supported by ${family} models on Bedrock.`,
1252
- severity: "error"
1253
- });
1254
- continue;
1255
- }
1256
- if (key === "cache_control" && !bedrockSupportsCaching(config.model)) {
1257
- issues.push({
1258
- param: key,
1259
- value,
1260
- message: `Prompt caching is only supported for Anthropic Claude and Amazon Nova models on Bedrock, not ${family ?? "unknown"} models.`,
1261
- severity: "error"
1262
- });
1263
- continue;
1264
- }
1265
- }
1266
- if (!knownParams.has(key) && !specs[key]) {
1267
- issues.push({
1268
- param: key,
1269
- value,
1270
- message: `Unknown param "${key}" for ${effectiveProvider}.`,
1271
- severity: options.strict ? "error" : "warning"
1272
- });
1273
- continue;
1274
- }
1275
- let spec = specs[key];
1276
- if (subProvider && gatewayReverseMap && !spec) {
1277
- const result = lookupSubProviderSpec(key, gatewayReverseMap, subProvider);
1278
- spec = result.spec;
1279
- }
1280
- if (!spec) continue;
1281
- if ((effectiveProvider === "anthropic" || provider === "bedrock" && detectBedrockModelFamily(config.model) === "anthropic") && (key === "temperature" || key === "top_p" || key === "topP")) {
1282
- const otherKey = key === "temperature" ? provider === "bedrock" ? "topP" : "top_p" : "temperature";
1283
- if (key === "temperature" && config.params[otherKey] !== void 0) {
1284
- issues.push({
1285
- param: key,
1286
- value,
1287
- message: `Cannot specify both "temperature" and "${otherKey}" for Anthropic models.`,
1288
- severity: "error"
1289
- });
1290
- }
1291
- }
1292
- if (spec.type === "number") {
1293
- const num = Number(value);
1294
- if (isNaN(num)) {
1295
- issues.push({
1296
- param: key,
1297
- value,
1298
- message: `"${key}" should be a number, got "${value}".`,
1299
- severity: "error"
1300
- });
1301
- continue;
1302
- }
1303
- if (spec.min !== void 0 && num < spec.min) {
1304
- issues.push({
1305
- param: key,
1306
- value,
1307
- message: `"${key}" must be >= ${spec.min}, got ${num}.`,
1308
- severity: "error"
1309
- });
1310
- }
1311
- if (spec.max !== void 0 && num > spec.max) {
1312
- issues.push({
1313
- param: key,
1314
- value,
1315
- message: `"${key}" must be <= ${spec.max}, got ${num}.`,
1316
- severity: "error"
1317
- });
1318
- }
1319
- }
1320
- if (spec.type === "boolean") {
1321
- if (!["true", "false", "0", "1"].includes(value)) {
1322
- issues.push({
1323
- param: key,
1324
- value,
1325
- message: `"${key}" should be a boolean (true/false), got "${value}".`,
1326
- severity: "error"
1327
- });
1328
- }
1329
- }
1330
- if (spec.type === "string" && spec.values) {
1331
- if (!spec.values.includes(value)) {
1332
- issues.push({
1333
- param: key,
1334
- value,
1335
- message: `"${key}" must be one of [${spec.values.join(", ")}], got "${value}".`,
1336
- severity: "error"
1337
- });
1338
- }
1339
- }
1340
- }
1341
- return issues;
1342
- }
1343
- // Annotate the CommonJS export names for ESM import in node:
1344
- 0 && (module.exports = {
1345
- HOST_ALIASES,
1346
- build,
1347
- normalize,
1348
- parse,
1349
- resolveHostAlias,
1350
- validate
1351
- });
1
+ "use strict";var e,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,n={};function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}((e,o)=>{for(var r in o)t(e,r,{get:o[r],enumerable:!0})})(n,{HOST_ALIASES:()=>s,build:()=>E,normalize:()=>A,parse:()=>K,resolveHostAlias:()=>m,validate:()=>V}),module.exports=(e=n,((e,n,i,s)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let p of r(n))a.call(e,p)||p===i||t(e,p,{get:()=>n[p],enumerable:!(s=o(n,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 m(e,t=function(){return"undefined"!=typeof process&&process.env?process.env:{}}()){const o=e.toLowerCase();if(!i(s,o))return{host:e};const r=o,a=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(a??s[r]),alias:r}}function l(e,...t){return t.some(t=>{const o=t.toLowerCase();return e===o||e.endsWith(`.${o}`)})}function u(e,...t){const o=e.split(".");return t.some(e=>o.some(t=>t.startsWith(e.toLowerCase())))}var d=new Set(["-","."]);function f(e){return e.trim().toLowerCase()}function y(e){const t=f(e),o=t.lastIndexOf("/");return o>=0?t.slice(o+1):t}function g(e,t){const o=y(e),r=f(t);if(!o||!r)return!1;if(o===r)return!0;const a=o[r.length];return o.startsWith(r)&&void 0!==a&&d.has(a)}function _(e){return l(e=function(e){return c(e).toLowerCase().split(":")[0]??e}(e),"openrouter","openrouter.ai")?"openrouter":l(e,"vercel","gateway.ai.vercel.app","gateway.ai.vercel.sh")?"vercel":l(e,"bedrock","amazonaws.com")||u(e,"bedrock")?"bedrock":l(e,"aiplatform.googleapis.com")?"google-vertex":l(e,"xai","x.ai","api.x.ai")?"xai":l(e,"groq","groq.com","api.groq.com")?"groq":l(e,"fal","fal.run","fal.ai")?"fal":l(e,"deepinfra","deepinfra.com")?"deepinfra":l(e,"bfl","bfl.ai","api.bfl.ai")?"black-forest-labs":l(e,"together","together.xyz")?"together":l(e,"fireworks","fireworks.ai")?"fireworks":l(e,"deepseek","deepseek.com")?"deepseek":l(e,"moonshot","moonshot.ai")?"moonshotai":l(e,"perplexity","perplexity.ai")?"perplexity":l(e,"alibaba","aliyuncs.com")||u(e,"dashscope")?"alibaba":l(e,"cerebras","cerebras.ai")?"cerebras":l(e,"replicate","replicate.com")?"replicate":l(e,"prodia","prodia.com")?"prodia":l(e,"luma","lumalabs.ai")?"luma":l(e,"bytedance","volces.com")||function(e,...t){const o=e.split(".");return t.some(e=>o.includes(e.toLowerCase()))}(e,"bytedance")?"bytedance":l(e,"kling","klingai.com")?"kling":l(e,"elevenlabs","elevenlabs.io")?"elevenlabs":l(e,"assemblyai","assemblyai.com")?"assemblyai":l(e,"deepgram","deepgram.com")?"deepgram":l(e,"gladia","gladia.io")?"gladia":l(e,"lmnt","lmnt.com")?"lmnt":l(e,"hume","hume.ai")?"hume":l(e,"revai","rev.ai")?"revai":l(e,"baseten","baseten.co")?"baseten":l(e,"huggingface","huggingface.co")?"huggingface":l(e,"azure","azure.com")?"azure":l(e,"openai","openai.com")?"openai":l(e,"anthropic","anthropic.com","claude.ai")?"anthropic":l(e,"google","googleapis.com")?"google":l(e,"mistral","mistral.ai")?"mistral":l(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"}}},$={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"}}},z={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:$,"google-vertex":$,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},O=Object.fromEntries(Object.entries(z).map(([e,t])=>[e,t.params])),S=Object.fromEntries(Object.entries(z).map(([e,t])=>[e,t.specs])),C=Object.fromEntries(Object.entries(z).filter(([,e])=>void 0!==e.cacheValue).map(([e,t])=>[e,t.cacheValue])),T=Object.fromEntries(Object.entries(z).filter(([,e])=>void 0!==e.cacheTtls).map(([e,t])=>[e,t.cacheTtls])),j=[];function M(e){const t=y(e),o=t.match(/^o\d+/)?.[0],r=t.match(/^gpt-[5-9]/)?.[0];return void 0!==o&&g(t,o)||void 0!==r&&g(t,r)||j.some(e=>g(t,e))}function G(e){return"openai"===e||"azure"===e||"openrouter"===e||"vercel"===e}var R=new Set(["temperature","top_p","top_k","frequency_penalty","presence_penalty","n"]);function L(e){const t=y(e).split(".");return["anthropic","meta","amazon","mistral","cohere","ai21"].find(e=>t.includes(e))}function N(e){const t=L(e);if("anthropic"===t)return!0;if("amazon"===t){const t=y(e).split("."),o=t.indexOf("amazon"),r=o>=0?t[o+1]:void 0;return!!r&&g(r,"nova")}return!1}function K(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}=m(t.host),a=t.pathname.replace(/^\//,""),n=t.username||void 0,i=t.password||void 0,s={};for(const[e,o]of t.searchParams)s[e]=o;return{raw:e,host:o,hostAlias:r,model:a,label:n,apiKey:i,params:s}}function E(e){const{host:t}=m(e.host),o=e.label||e.apiKey?`${e.label??""}${e.apiKey?`:${e.apiKey}`:""}@`:"",r=new URLSearchParams(e.params).toString(),a=r?`?${r}`:"";return`llm://${o}${t}/${e.model}${a}`}var I=/^\d+[mh]$/;function A(e,t={}){const o=(e.hostAlias?function(e){const t=e.toLowerCase();return i(O,t)?t:i(p,t)?p[t]:void 0}(e.hostAlias):void 0)??_(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,a=[],n={};for(const[r,i]of Object.entries(e.params)){let s=r;if(b[s]){const e=b[s];t.verbose&&a.push({from:s,to:e,value:i,reason:`alias: "${s}" → "${e}"`}),s=e}if("cache"===s&&o){let r=C[o];if("bedrock"!==o||N(e.model)||(r=void 0),!r){t.verbose&&a.push({from:"cache",to:"(dropped)",value:i,reason:`${o} does not use a cache param for this model (caching is automatic or unsupported)`});continue}const s="true"===i||"1"===i||"yes"===i,p=I.test(i);if(s||p){const e=O[o]?.cache??"cache";t.verbose&&a.push({from:"cache",to:e,value:r,reason:`cache=${i} → ${e}=${r} for ${o}`}),n[e]=r,p&&T[o]&&(t.verbose&&a.push({from:"cache",to:"cache_ttl",value:i,reason:`cache=${i} → cache_ttl=${i} for ${o}`}),n.cache_ttl=i);continue}}if(o&&O[o]){const e=O[o][s];e&&e!==s&&(t.verbose&&a.push({from:s,to:e,value:i,reason:`${o} uses "${e}" instead of "${s}"`}),s=e)}o&&G(o)&&M(e.model)&&"max_tokens"===s&&(t.verbose&&a.push({from:"max_tokens",to:"max_completion_tokens",value:i,reason:"OpenAI reasoning models use max_completion_tokens instead of max_tokens"}),s="max_completion_tokens"),o&&G(o)&&M(e.model)&&R.has(s)?t.verbose&&a.push({from:s,to:"(dropped)",value:i,reason:`${o} reasoning model "${e.model}" does not support "${s}"`}):n[s]=i}return{config:{...e,params:n},provider:o,subProvider:r,changes:a}}function U(e,t,o){const r=t[e]??e,a=O[o]?.[r];return a?{spec:S[o]?.[a],canonical:r}:{spec:void 0,canonical:r}}function V(e,t={}){const o=K(e),{config:r,provider:a,subProvider:n}=A(o),i=[];if(!a)return i.push({param:"host",value:r.host,message:`Unknown provider for host "${r.host}". Validation skipped.`,severity:t.strict?"error":"warning"}),i;const s=n??a,p=S[s],c=n?function(e){const t={};for(const[o,r]of Object.entries(O[e]))t[r]=o;return t}(a):void 0,m=n?function(e,t){const o=new Set,r=new Set(Object.keys(O[t]));for(const[t,a]of Object.entries(O[e]))r.has(t)&&o.add(a);return o}(a,n):new Set(Object.values(O[a]));for(const[e,o]of Object.entries(r.params)){const l=n&&c?U(e,c,n):void 0,u=n&&!l?.spec?S[a]?.[e]:void 0;if("bedrock"===a){const t=L(r.model);if("topK"===e&&t&&"anthropic"!==t&&"cohere"!==t&&"mistral"!==t){i.push({param:e,value:o,message:`"topK" is not supported by ${t} models on Bedrock.`,severity:"error"});continue}if("cache_control"===e&&!N(r.model)){i.push({param:e,value:o,message:`Prompt caching is only supported for Anthropic Claude and Amazon Nova models on Bedrock, not ${t??"unknown"} models.`,severity:"error"});continue}}if(!m.has(e)&&!p[e]&&!u){t.strict&&i.push({param:e,value:o,message:`Unknown param "${e}" for ${s}.`,severity:"error"});continue}const d=l?.spec??u??p[e];if(d){if(("anthropic"===s||"bedrock"===a&&"anthropic"===L(r.model))&&("temperature"===e||"top_p"===e||"topP"===e)){const t="temperature"===e?"bedrock"===a?"topP":"top_p":"temperature";"temperature"===e&&void 0!==r.params[t]&&i.push({param:e,value:o,message:`Cannot specify both "temperature" and "${t}" for Anthropic models.`,severity:"error"})}if("number"===d.type){const t=Number(o);if(isNaN(t)){i.push({param:e,value:o,message:`"${e}" should be a number, got "${o}".`,severity:"error"});continue}void 0!==d.min&&t<d.min&&i.push({param:e,value:o,message:`"${e}" must be >= ${d.min}, got ${t}.`,severity:"error"}),void 0!==d.max&&t>d.max&&i.push({param:e,value:o,message:`"${e}" must be <= ${d.max}, got ${t}.`,severity:"error"})}"boolean"===d.type&&(["true","false","0","1"].includes(o)||i.push({param:e,value:o,message:`"${e}" should be a boolean (true/false), got "${o}".`,severity:"error"})),"string"===d.type&&d.values&&(d.values.includes(o)||i.push({param:e,value:o,message:`"${e}" must be one of [${d.values.join(", ")}], got "${o}".`,severity:"error"}))}}return i}