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.
@@ -1,1043 +0,0 @@
1
- // src/provider-core.ts
2
- function hasOwn(object, key) {
3
- return Object.prototype.hasOwnProperty.call(object, key);
4
- }
5
- var HOST_ALIASES = {
6
- openai: "api.openai.com",
7
- azure: "models.inference.ai.azure.com",
8
- anthropic: "api.anthropic.com",
9
- google: "generativelanguage.googleapis.com",
10
- "google-vertex": "aiplatform.googleapis.com",
11
- aistudio: "generativelanguage.googleapis.com",
12
- mistral: "api.mistral.ai",
13
- cohere: "api.cohere.com",
14
- bedrock: "bedrock-runtime.us-east-1.amazonaws.com",
15
- openrouter: "openrouter.ai",
16
- vercel: "gateway.ai.vercel.app",
17
- alibaba: "dashscope-intl.aliyuncs.com",
18
- alibabacloud: "dashscope-intl.aliyuncs.com",
19
- dashscope: "dashscope-intl.aliyuncs.com",
20
- groq: "api.groq.com",
21
- fal: "fal.run",
22
- fireworks: "api.fireworks.ai",
23
- fireworksai: "api.fireworks.ai",
24
- "black-forest-labs": "api.bfl.ai",
25
- bfl: "api.bfl.ai",
26
- deepseek: "api.deepseek.com",
27
- moonshotai: "api.moonshot.ai",
28
- moonshot: "api.moonshot.ai",
29
- perplexity: "api.perplexity.ai",
30
- venice: "api.venice.ai",
31
- parasail: "api.parasail.io",
32
- deepinfra: "api.deepinfra.com",
33
- atlascloud: "api.atlascloud.ai",
34
- novita: "api.novita.ai",
35
- novitaai: "api.novita.ai",
36
- grok: "api.x.ai",
37
- xai: "api.x.ai",
38
- together: "api.together.xyz",
39
- togetherai: "api.together.xyz",
40
- cerebras: "api.cerebras.ai",
41
- replicate: "api.replicate.com",
42
- prodia: "api.prodia.com",
43
- luma: "api.lumalabs.ai",
44
- bytedance: "ark.cn-beijing.volces.com",
45
- kling: "api.klingai.com",
46
- elevenlabs: "api.elevenlabs.io",
47
- assemblyai: "api.assemblyai.com",
48
- deepgram: "api.deepgram.com",
49
- gladia: "api.gladia.io",
50
- lmnt: "api.lmnt.com",
51
- hume: "api.hume.ai",
52
- revai: "api.rev.ai",
53
- baseten: "api.baseten.co",
54
- huggingface: "api-inference.huggingface.co",
55
- wandb: "api.inference.wandb.ai",
56
- weightsandbiases: "api.inference.wandb.ai",
57
- baidu: "qianfan.baidubce.com",
58
- qianfan: "qianfan.baidubce.com",
59
- vertex: "aiplatform.googleapis.com",
60
- xiaomi: "api.xiaomimimo.com",
61
- minimax: "api.minimax.io"
62
- };
63
- var HOST_ALIAS_PROVIDERS = {
64
- aistudio: "google",
65
- vertex: "google-vertex",
66
- grok: "xai",
67
- bfl: "black-forest-labs",
68
- moonshot: "moonshotai",
69
- alibaba: "alibaba",
70
- alibabacloud: "alibaba",
71
- dashscope: "alibaba",
72
- togetherai: "together",
73
- fireworksai: "fireworks"
74
- };
75
- function readProcessEnv() {
76
- return typeof process !== "undefined" && process.env ? process.env : {};
77
- }
78
- function normalizeHostValue(value) {
79
- const trimmed = value.trim();
80
- if (!trimmed) return trimmed;
81
- try {
82
- if (trimmed.includes("://")) {
83
- return new URL(trimmed).host;
84
- }
85
- } catch {
86
- }
87
- return trimmed.replace(/^\/\//, "").split("/")[0] ?? trimmed;
88
- }
89
- function envHostOverride(alias, env) {
90
- const upper = alias.toUpperCase();
91
- const override = env[`LLM_STRINGS_${upper}_HOST`] ?? env[`LLM_STRINGS_HOST_${upper}`];
92
- return override?.trim() ? override : void 0;
93
- }
94
- function resolveHostAlias(host, env = readProcessEnv()) {
95
- const normalizedHost = host.toLowerCase();
96
- if (!hasOwn(HOST_ALIASES, normalizedHost)) {
97
- return { host };
98
- }
99
- const alias = normalizedHost;
100
- const override = envHostOverride(alias, env);
101
- return {
102
- host: normalizeHostValue(override ?? HOST_ALIASES[alias]),
103
- alias
104
- };
105
- }
106
- function providerFromHostAlias(alias) {
107
- const normalizedAlias = alias.toLowerCase();
108
- if (hasOwn(PROVIDER_PARAMS, normalizedAlias)) {
109
- return normalizedAlias;
110
- }
111
- if (hasOwn(HOST_ALIAS_PROVIDERS, normalizedAlias)) {
112
- return HOST_ALIAS_PROVIDERS[normalizedAlias];
113
- }
114
- return void 0;
115
- }
116
- function detectProvider(host) {
117
- host = host.toLowerCase();
118
- if (host.includes("openrouter")) return "openrouter";
119
- if (host.includes("gateway.ai.vercel")) return "vercel";
120
- if (host.includes("amazonaws") || host.includes("bedrock")) return "bedrock";
121
- if (host.includes("aiplatform.googleapis")) return "google-vertex";
122
- if (host.includes("api.x.ai")) return "xai";
123
- if (host.includes("groq")) return "groq";
124
- if (host.includes("fal.run") || host.includes("fal.ai")) return "fal";
125
- if (host.includes("deepinfra")) return "deepinfra";
126
- if (host.includes("bfl.ai")) return "black-forest-labs";
127
- if (host.includes("together")) return "together";
128
- if (host.includes("fireworks")) return "fireworks";
129
- if (host.includes("deepseek")) return "deepseek";
130
- if (host.includes("moonshot")) return "moonshotai";
131
- if (host.includes("perplexity")) return "perplexity";
132
- if (host.includes("dashscope") || host.includes("aliyuncs")) return "alibaba";
133
- if (host.includes("cerebras")) return "cerebras";
134
- if (host.includes("replicate")) return "replicate";
135
- if (host.includes("prodia")) return "prodia";
136
- if (host.includes("lumalabs") || host.includes("luma")) return "luma";
137
- if (host.includes("volces") || host.includes("bytedance")) return "bytedance";
138
- if (host.includes("kling")) return "kling";
139
- if (host.includes("elevenlabs")) return "elevenlabs";
140
- if (host.includes("assemblyai")) return "assemblyai";
141
- if (host.includes("deepgram")) return "deepgram";
142
- if (host.includes("gladia")) return "gladia";
143
- if (host.includes("lmnt")) return "lmnt";
144
- if (host.includes("hume")) return "hume";
145
- if (host.includes("rev.ai")) return "revai";
146
- if (host.includes("baseten")) return "baseten";
147
- if (host.includes("huggingface")) return "huggingface";
148
- if (host.includes("azure")) return "azure";
149
- if (host.includes("openai")) return "openai";
150
- if (host.includes("anthropic") || host.includes("claude")) return "anthropic";
151
- if (host.includes("googleapis") || host.includes("google")) return "google";
152
- if (host.includes("mistral")) return "mistral";
153
- if (host.includes("cohere")) return "cohere";
154
- return void 0;
155
- }
156
- var ALIASES = {
157
- // temperature
158
- temp: "temperature",
159
- // max_tokens
160
- max: "max_tokens",
161
- max_out: "max_tokens",
162
- max_output: "max_tokens",
163
- max_output_tokens: "max_tokens",
164
- max_completion_tokens: "max_tokens",
165
- maxOutputTokens: "max_tokens",
166
- maxTokens: "max_tokens",
167
- // top_p
168
- topp: "top_p",
169
- topP: "top_p",
170
- nucleus: "top_p",
171
- // top_k
172
- topk: "top_k",
173
- topK: "top_k",
174
- // frequency_penalty
175
- freq: "frequency_penalty",
176
- freq_penalty: "frequency_penalty",
177
- frequencyPenalty: "frequency_penalty",
178
- repetition_penalty: "frequency_penalty",
179
- // presence_penalty
180
- pres: "presence_penalty",
181
- pres_penalty: "presence_penalty",
182
- presencePenalty: "presence_penalty",
183
- // stop
184
- stop_sequences: "stop",
185
- stopSequences: "stop",
186
- stop_sequence: "stop",
187
- // seed
188
- random_seed: "seed",
189
- randomSeed: "seed",
190
- // n (completions count)
191
- candidateCount: "n",
192
- candidate_count: "n",
193
- num_completions: "n",
194
- // effort / reasoning
195
- reasoning_effort: "effort",
196
- reasoning: "effort",
197
- // cache
198
- cache_control: "cache",
199
- cacheControl: "cache",
200
- cachePoint: "cache",
201
- cache_point: "cache"
202
- };
203
- var OPENAI_COMPATIBLE_PARAMS = {
204
- temperature: "temperature",
205
- max_tokens: "max_tokens",
206
- top_p: "top_p",
207
- top_k: "top_k",
208
- frequency_penalty: "frequency_penalty",
209
- presence_penalty: "presence_penalty",
210
- stop: "stop",
211
- n: "n",
212
- seed: "seed",
213
- stream: "stream",
214
- effort: "reasoning_effort"
215
- };
216
- var GOOGLE_COMPATIBLE_PARAMS = {
217
- temperature: "temperature",
218
- max_tokens: "maxOutputTokens",
219
- top_p: "topP",
220
- top_k: "topK",
221
- frequency_penalty: "frequencyPenalty",
222
- presence_penalty: "presencePenalty",
223
- stop: "stopSequences",
224
- n: "candidateCount",
225
- stream: "stream",
226
- seed: "seed",
227
- responseMimeType: "responseMimeType",
228
- responseSchema: "responseSchema"
229
- };
230
- var PROVIDER_PARAMS = {
231
- openai: {
232
- temperature: "temperature",
233
- max_tokens: "max_tokens",
234
- top_p: "top_p",
235
- frequency_penalty: "frequency_penalty",
236
- presence_penalty: "presence_penalty",
237
- stop: "stop",
238
- n: "n",
239
- seed: "seed",
240
- stream: "stream",
241
- effort: "reasoning_effort"
242
- },
243
- azure: OPENAI_COMPATIBLE_PARAMS,
244
- anthropic: {
245
- temperature: "temperature",
246
- max_tokens: "max_tokens",
247
- top_p: "top_p",
248
- top_k: "top_k",
249
- stop: "stop_sequences",
250
- stream: "stream",
251
- effort: "effort",
252
- cache: "cache_control",
253
- cache_ttl: "cache_ttl"
254
- },
255
- google: {
256
- temperature: "temperature",
257
- max_tokens: "maxOutputTokens",
258
- top_p: "topP",
259
- top_k: "topK",
260
- frequency_penalty: "frequencyPenalty",
261
- presence_penalty: "presencePenalty",
262
- stop: "stopSequences",
263
- n: "candidateCount",
264
- stream: "stream",
265
- seed: "seed",
266
- responseMimeType: "responseMimeType",
267
- responseSchema: "responseSchema"
268
- },
269
- "google-vertex": GOOGLE_COMPATIBLE_PARAMS,
270
- mistral: {
271
- temperature: "temperature",
272
- max_tokens: "max_tokens",
273
- top_p: "top_p",
274
- frequency_penalty: "frequency_penalty",
275
- presence_penalty: "presence_penalty",
276
- stop: "stop",
277
- n: "n",
278
- seed: "random_seed",
279
- stream: "stream",
280
- safe_prompt: "safe_prompt",
281
- min_tokens: "min_tokens"
282
- },
283
- cohere: {
284
- temperature: "temperature",
285
- max_tokens: "max_tokens",
286
- top_p: "p",
287
- top_k: "k",
288
- frequency_penalty: "frequency_penalty",
289
- presence_penalty: "presence_penalty",
290
- stop: "stop_sequences",
291
- stream: "stream",
292
- seed: "seed"
293
- },
294
- bedrock: {
295
- // Bedrock Converse API uses camelCase
296
- temperature: "temperature",
297
- max_tokens: "maxTokens",
298
- top_p: "topP",
299
- top_k: "topK",
300
- // Claude models via additionalModelRequestFields
301
- stop: "stopSequences",
302
- stream: "stream",
303
- cache: "cache_control",
304
- cache_ttl: "cache_ttl"
305
- },
306
- openrouter: {
307
- // OpenAI-compatible API with extra routing params
308
- temperature: "temperature",
309
- max_tokens: "max_tokens",
310
- top_p: "top_p",
311
- top_k: "top_k",
312
- frequency_penalty: "frequency_penalty",
313
- presence_penalty: "presence_penalty",
314
- stop: "stop",
315
- n: "n",
316
- seed: "seed",
317
- stream: "stream",
318
- effort: "reasoning_effort"
319
- },
320
- vercel: {
321
- // OpenAI-compatible gateway
322
- temperature: "temperature",
323
- max_tokens: "max_tokens",
324
- top_p: "top_p",
325
- top_k: "top_k",
326
- frequency_penalty: "frequency_penalty",
327
- presence_penalty: "presence_penalty",
328
- stop: "stop",
329
- n: "n",
330
- seed: "seed",
331
- stream: "stream",
332
- effort: "reasoning_effort"
333
- },
334
- xai: OPENAI_COMPATIBLE_PARAMS,
335
- groq: OPENAI_COMPATIBLE_PARAMS,
336
- fal: {},
337
- deepinfra: OPENAI_COMPATIBLE_PARAMS,
338
- "black-forest-labs": {},
339
- together: OPENAI_COMPATIBLE_PARAMS,
340
- fireworks: OPENAI_COMPATIBLE_PARAMS,
341
- deepseek: OPENAI_COMPATIBLE_PARAMS,
342
- moonshotai: OPENAI_COMPATIBLE_PARAMS,
343
- perplexity: OPENAI_COMPATIBLE_PARAMS,
344
- alibaba: OPENAI_COMPATIBLE_PARAMS,
345
- cerebras: OPENAI_COMPATIBLE_PARAMS,
346
- replicate: {},
347
- prodia: {},
348
- luma: {},
349
- bytedance: {},
350
- kling: {},
351
- elevenlabs: {},
352
- assemblyai: {},
353
- deepgram: {},
354
- gladia: {},
355
- lmnt: {},
356
- hume: {},
357
- revai: {},
358
- baseten: OPENAI_COMPATIBLE_PARAMS,
359
- huggingface: OPENAI_COMPATIBLE_PARAMS
360
- };
361
- var OPENAI_COMPATIBLE_PARAM_SPECS = {
362
- temperature: {
363
- type: "number",
364
- min: 0,
365
- max: 2,
366
- default: 0.7,
367
- description: "Controls randomness"
368
- },
369
- max_tokens: {
370
- type: "number",
371
- min: 1,
372
- default: 4096,
373
- description: "Maximum output tokens"
374
- },
375
- top_p: {
376
- type: "number",
377
- min: 0,
378
- max: 1,
379
- default: 1,
380
- description: "Nucleus sampling"
381
- },
382
- top_k: {
383
- type: "number",
384
- min: 0,
385
- default: 40,
386
- description: "Top-K sampling"
387
- },
388
- frequency_penalty: {
389
- type: "number",
390
- min: -2,
391
- max: 2,
392
- default: 0,
393
- description: "Penalize frequent tokens"
394
- },
395
- presence_penalty: {
396
- type: "number",
397
- min: -2,
398
- max: 2,
399
- default: 0,
400
- description: "Penalize repeated topics"
401
- },
402
- stop: { type: "string", description: "Stop sequences" },
403
- n: { type: "number", min: 1, default: 1, description: "Completions count" },
404
- seed: { type: "number", description: "Random seed" },
405
- stream: { type: "boolean", default: false, description: "Stream response" },
406
- reasoning_effort: {
407
- type: "string",
408
- values: ["none", "minimal", "low", "medium", "high", "xhigh"],
409
- default: "medium",
410
- description: "Reasoning effort"
411
- }
412
- };
413
- var GOOGLE_COMPATIBLE_PARAM_SPECS = {
414
- temperature: {
415
- type: "number",
416
- min: 0,
417
- max: 2,
418
- default: 0.7,
419
- description: "Controls randomness"
420
- },
421
- maxOutputTokens: {
422
- type: "number",
423
- min: 1,
424
- default: 4096,
425
- description: "Maximum output tokens"
426
- },
427
- topP: {
428
- type: "number",
429
- min: 0,
430
- max: 1,
431
- default: 1,
432
- description: "Nucleus sampling"
433
- },
434
- topK: {
435
- type: "number",
436
- min: 0,
437
- default: 40,
438
- description: "Top-K sampling"
439
- },
440
- frequencyPenalty: {
441
- type: "number",
442
- min: -2,
443
- max: 2,
444
- default: 0,
445
- description: "Penalize frequent tokens"
446
- },
447
- presencePenalty: {
448
- type: "number",
449
- min: -2,
450
- max: 2,
451
- default: 0,
452
- description: "Penalize repeated topics"
453
- },
454
- stopSequences: { type: "string", description: "Stop sequences" },
455
- candidateCount: {
456
- type: "number",
457
- min: 1,
458
- default: 1,
459
- description: "Candidate count"
460
- },
461
- stream: { type: "boolean", default: false, description: "Stream response" },
462
- seed: { type: "number", description: "Random seed" },
463
- responseMimeType: { type: "string", description: "Response MIME type" },
464
- responseSchema: { type: "string", description: "Response schema" }
465
- };
466
- var PARAM_SPECS = {
467
- openai: {
468
- temperature: {
469
- type: "number",
470
- min: 0,
471
- max: 2,
472
- default: 0.7,
473
- description: "Controls randomness"
474
- },
475
- max_tokens: {
476
- type: "number",
477
- min: 1,
478
- default: 4096,
479
- description: "Maximum output tokens"
480
- },
481
- top_p: {
482
- type: "number",
483
- min: 0,
484
- max: 1,
485
- default: 1,
486
- description: "Nucleus sampling"
487
- },
488
- frequency_penalty: {
489
- type: "number",
490
- min: -2,
491
- max: 2,
492
- default: 0,
493
- description: "Penalize frequent tokens"
494
- },
495
- presence_penalty: {
496
- type: "number",
497
- min: -2,
498
- max: 2,
499
- default: 0,
500
- description: "Penalize repeated topics"
501
- },
502
- stop: { type: "string", description: "Stop sequences" },
503
- n: { type: "number", min: 1, default: 1, description: "Completions count" },
504
- seed: { type: "number", description: "Random seed" },
505
- stream: { type: "boolean", default: false, description: "Stream response" },
506
- reasoning_effort: {
507
- type: "string",
508
- values: ["none", "minimal", "low", "medium", "high", "xhigh"],
509
- default: "medium",
510
- description: "Reasoning effort"
511
- }
512
- },
513
- azure: OPENAI_COMPATIBLE_PARAM_SPECS,
514
- anthropic: {
515
- temperature: {
516
- type: "number",
517
- min: 0,
518
- max: 1,
519
- default: 0.7,
520
- description: "Controls randomness"
521
- },
522
- max_tokens: {
523
- type: "number",
524
- min: 1,
525
- default: 4096,
526
- description: "Maximum output tokens"
527
- },
528
- top_p: {
529
- type: "number",
530
- min: 0,
531
- max: 1,
532
- default: 1,
533
- description: "Nucleus sampling"
534
- },
535
- top_k: {
536
- type: "number",
537
- min: 0,
538
- default: 40,
539
- description: "Top-K sampling"
540
- },
541
- stop_sequences: { type: "string", description: "Stop sequences" },
542
- stream: { type: "boolean", default: false, description: "Stream response" },
543
- effort: {
544
- type: "string",
545
- values: ["low", "medium", "high", "max"],
546
- default: "medium",
547
- description: "Thinking effort"
548
- },
549
- cache_control: {
550
- type: "string",
551
- values: ["ephemeral"],
552
- default: "ephemeral",
553
- description: "Cache control"
554
- },
555
- cache_ttl: {
556
- type: "string",
557
- values: ["5m", "1h"],
558
- default: "5m",
559
- description: "Cache TTL"
560
- }
561
- },
562
- google: {
563
- temperature: {
564
- type: "number",
565
- min: 0,
566
- max: 2,
567
- default: 0.7,
568
- description: "Controls randomness"
569
- },
570
- maxOutputTokens: {
571
- type: "number",
572
- min: 1,
573
- default: 4096,
574
- description: "Maximum output tokens"
575
- },
576
- topP: {
577
- type: "number",
578
- min: 0,
579
- max: 1,
580
- default: 1,
581
- description: "Nucleus sampling"
582
- },
583
- topK: {
584
- type: "number",
585
- min: 0,
586
- default: 40,
587
- description: "Top-K sampling"
588
- },
589
- frequencyPenalty: {
590
- type: "number",
591
- min: -2,
592
- max: 2,
593
- default: 0,
594
- description: "Penalize frequent tokens"
595
- },
596
- presencePenalty: {
597
- type: "number",
598
- min: -2,
599
- max: 2,
600
- default: 0,
601
- description: "Penalize repeated topics"
602
- },
603
- stopSequences: { type: "string", description: "Stop sequences" },
604
- candidateCount: {
605
- type: "number",
606
- min: 1,
607
- default: 1,
608
- description: "Candidate count"
609
- },
610
- stream: { type: "boolean", default: false, description: "Stream response" },
611
- seed: { type: "number", description: "Random seed" },
612
- responseMimeType: { type: "string", description: "Response MIME type" },
613
- responseSchema: { type: "string", description: "Response schema" }
614
- },
615
- "google-vertex": GOOGLE_COMPATIBLE_PARAM_SPECS,
616
- mistral: {
617
- temperature: {
618
- type: "number",
619
- min: 0,
620
- max: 1,
621
- default: 0.7,
622
- description: "Controls randomness"
623
- },
624
- max_tokens: {
625
- type: "number",
626
- min: 1,
627
- default: 4096,
628
- description: "Maximum output tokens"
629
- },
630
- top_p: {
631
- type: "number",
632
- min: 0,
633
- max: 1,
634
- default: 1,
635
- description: "Nucleus sampling"
636
- },
637
- frequency_penalty: {
638
- type: "number",
639
- min: -2,
640
- max: 2,
641
- default: 0,
642
- description: "Penalize frequent tokens"
643
- },
644
- presence_penalty: {
645
- type: "number",
646
- min: -2,
647
- max: 2,
648
- default: 0,
649
- description: "Penalize repeated topics"
650
- },
651
- stop: { type: "string", description: "Stop sequences" },
652
- n: { type: "number", min: 1, default: 1, description: "Completions count" },
653
- random_seed: { type: "number", description: "Random seed" },
654
- stream: { type: "boolean", default: false, description: "Stream response" },
655
- safe_prompt: {
656
- type: "boolean",
657
- default: false,
658
- description: "Enable safe prompt"
659
- },
660
- min_tokens: {
661
- type: "number",
662
- min: 0,
663
- default: 0,
664
- description: "Minimum tokens"
665
- }
666
- },
667
- cohere: {
668
- temperature: {
669
- type: "number",
670
- min: 0,
671
- max: 1,
672
- default: 0.7,
673
- description: "Controls randomness"
674
- },
675
- max_tokens: {
676
- type: "number",
677
- min: 1,
678
- default: 4096,
679
- description: "Maximum output tokens"
680
- },
681
- p: {
682
- type: "number",
683
- min: 0,
684
- max: 1,
685
- default: 1,
686
- description: "Nucleus sampling (p)"
687
- },
688
- k: {
689
- type: "number",
690
- min: 0,
691
- max: 500,
692
- default: 40,
693
- description: "Top-K sampling (k)"
694
- },
695
- frequency_penalty: {
696
- type: "number",
697
- min: 0,
698
- max: 1,
699
- default: 0,
700
- description: "Penalize frequent tokens"
701
- },
702
- presence_penalty: {
703
- type: "number",
704
- min: 0,
705
- max: 1,
706
- default: 0,
707
- description: "Penalize repeated topics"
708
- },
709
- stop_sequences: { type: "string", description: "Stop sequences" },
710
- stream: { type: "boolean", default: false, description: "Stream response" },
711
- seed: { type: "number", description: "Random seed" }
712
- },
713
- bedrock: {
714
- // Converse API inferenceConfig params
715
- temperature: {
716
- type: "number",
717
- min: 0,
718
- max: 1,
719
- default: 0.7,
720
- description: "Controls randomness"
721
- },
722
- maxTokens: {
723
- type: "number",
724
- min: 1,
725
- default: 4096,
726
- description: "Maximum output tokens"
727
- },
728
- topP: {
729
- type: "number",
730
- min: 0,
731
- max: 1,
732
- default: 1,
733
- description: "Nucleus sampling"
734
- },
735
- topK: {
736
- type: "number",
737
- min: 0,
738
- default: 40,
739
- description: "Top-K sampling"
740
- },
741
- stopSequences: { type: "string", description: "Stop sequences" },
742
- stream: { type: "boolean", default: false, description: "Stream response" },
743
- cache_control: {
744
- type: "string",
745
- values: ["ephemeral"],
746
- default: "ephemeral",
747
- description: "Cache control"
748
- },
749
- cache_ttl: {
750
- type: "string",
751
- values: ["5m", "1h"],
752
- default: "5m",
753
- description: "Cache TTL"
754
- }
755
- },
756
- openrouter: {
757
- // Loose validation — proxies to many providers with varying ranges
758
- temperature: {
759
- type: "number",
760
- min: 0,
761
- max: 2,
762
- default: 0.7,
763
- description: "Controls randomness"
764
- },
765
- max_tokens: {
766
- type: "number",
767
- min: 1,
768
- default: 4096,
769
- description: "Maximum output tokens"
770
- },
771
- top_p: {
772
- type: "number",
773
- min: 0,
774
- max: 1,
775
- default: 1,
776
- description: "Nucleus sampling"
777
- },
778
- top_k: {
779
- type: "number",
780
- min: 0,
781
- default: 40,
782
- description: "Top-K sampling"
783
- },
784
- frequency_penalty: {
785
- type: "number",
786
- min: -2,
787
- max: 2,
788
- default: 0,
789
- description: "Penalize frequent tokens"
790
- },
791
- presence_penalty: {
792
- type: "number",
793
- min: -2,
794
- max: 2,
795
- default: 0,
796
- description: "Penalize repeated topics"
797
- },
798
- stop: { type: "string", description: "Stop sequences" },
799
- n: { type: "number", min: 1, default: 1, description: "Completions count" },
800
- seed: { type: "number", description: "Random seed" },
801
- stream: { type: "boolean", default: false, description: "Stream response" },
802
- reasoning_effort: {
803
- type: "string",
804
- values: ["none", "minimal", "low", "medium", "high", "xhigh"],
805
- default: "medium",
806
- description: "Reasoning effort"
807
- }
808
- },
809
- vercel: {
810
- // Loose validation — proxies to many providers with varying ranges
811
- temperature: {
812
- type: "number",
813
- min: 0,
814
- max: 2,
815
- default: 0.7,
816
- description: "Controls randomness"
817
- },
818
- max_tokens: {
819
- type: "number",
820
- min: 1,
821
- default: 4096,
822
- description: "Maximum output tokens"
823
- },
824
- top_p: {
825
- type: "number",
826
- min: 0,
827
- max: 1,
828
- default: 1,
829
- description: "Nucleus sampling"
830
- },
831
- top_k: {
832
- type: "number",
833
- min: 0,
834
- default: 40,
835
- description: "Top-K sampling"
836
- },
837
- frequency_penalty: {
838
- type: "number",
839
- min: -2,
840
- max: 2,
841
- default: 0,
842
- description: "Penalize frequent tokens"
843
- },
844
- presence_penalty: {
845
- type: "number",
846
- min: -2,
847
- max: 2,
848
- default: 0,
849
- description: "Penalize repeated topics"
850
- },
851
- stop: { type: "string", description: "Stop sequences" },
852
- n: { type: "number", min: 1, default: 1, description: "Completions count" },
853
- seed: { type: "number", description: "Random seed" },
854
- stream: { type: "boolean", default: false, description: "Stream response" },
855
- reasoning_effort: {
856
- type: "string",
857
- values: ["none", "minimal", "low", "medium", "high", "xhigh"],
858
- default: "medium",
859
- description: "Reasoning effort"
860
- }
861
- },
862
- xai: OPENAI_COMPATIBLE_PARAM_SPECS,
863
- groq: OPENAI_COMPATIBLE_PARAM_SPECS,
864
- fal: {},
865
- deepinfra: OPENAI_COMPATIBLE_PARAM_SPECS,
866
- "black-forest-labs": {},
867
- together: OPENAI_COMPATIBLE_PARAM_SPECS,
868
- fireworks: OPENAI_COMPATIBLE_PARAM_SPECS,
869
- deepseek: OPENAI_COMPATIBLE_PARAM_SPECS,
870
- moonshotai: OPENAI_COMPATIBLE_PARAM_SPECS,
871
- perplexity: OPENAI_COMPATIBLE_PARAM_SPECS,
872
- alibaba: OPENAI_COMPATIBLE_PARAM_SPECS,
873
- cerebras: OPENAI_COMPATIBLE_PARAM_SPECS,
874
- replicate: {},
875
- prodia: {},
876
- luma: {},
877
- bytedance: {},
878
- kling: {},
879
- elevenlabs: {},
880
- assemblyai: {},
881
- deepgram: {},
882
- gladia: {},
883
- lmnt: {},
884
- hume: {},
885
- revai: {},
886
- baseten: OPENAI_COMPATIBLE_PARAM_SPECS,
887
- huggingface: OPENAI_COMPATIBLE_PARAM_SPECS
888
- };
889
- function isReasoningModel(model) {
890
- const name = model.includes("/") ? model.split("/").pop() : model;
891
- return /^o[134]/.test(name);
892
- }
893
- function canHostOpenAIModels(provider) {
894
- return provider === "openai" || provider === "openrouter" || provider === "vercel";
895
- }
896
- function isGatewayProvider(provider) {
897
- return provider === "openrouter" || provider === "vercel";
898
- }
899
- function detectGatewaySubProvider(model) {
900
- const slash = model.indexOf("/");
901
- if (slash < 1) return void 0;
902
- const prefix = model.slice(0, slash);
903
- const direct = [
904
- "openai",
905
- "anthropic",
906
- "google",
907
- "mistral",
908
- "cohere"
909
- ];
910
- return direct.find((p) => p === prefix);
911
- }
912
- var REASONING_MODEL_UNSUPPORTED = /* @__PURE__ */ new Set([
913
- "temperature",
914
- "top_p",
915
- "frequency_penalty",
916
- "presence_penalty",
917
- "n"
918
- ]);
919
- function detectBedrockModelFamily(model) {
920
- const parts = model.split(".");
921
- let prefix = parts[0];
922
- if (["us", "eu", "apac", "global"].includes(prefix) && parts.length > 1) {
923
- prefix = parts[1];
924
- }
925
- const families = [
926
- "anthropic",
927
- "meta",
928
- "amazon",
929
- "mistral",
930
- "cohere",
931
- "ai21"
932
- ];
933
- return families.find((f) => prefix === f);
934
- }
935
- function bedrockSupportsCaching(model) {
936
- const family = detectBedrockModelFamily(model);
937
- if (family === "anthropic") return true;
938
- if (family === "amazon" && model.includes("nova")) return true;
939
- return false;
940
- }
941
- var CACHE_VALUES = {
942
- openai: void 0,
943
- // OpenAI auto-caches; no explicit param
944
- azure: void 0,
945
- anthropic: "ephemeral",
946
- google: void 0,
947
- // Google uses explicit caching API, not a param
948
- "google-vertex": void 0,
949
- mistral: void 0,
950
- cohere: void 0,
951
- bedrock: "ephemeral",
952
- // Supported for Claude models on Bedrock
953
- openrouter: void 0,
954
- // Depends on underlying provider
955
- vercel: void 0,
956
- // Depends on underlying provider
957
- xai: void 0,
958
- groq: void 0,
959
- fal: void 0,
960
- deepinfra: void 0,
961
- "black-forest-labs": void 0,
962
- together: void 0,
963
- fireworks: void 0,
964
- deepseek: void 0,
965
- moonshotai: void 0,
966
- perplexity: void 0,
967
- alibaba: void 0,
968
- cerebras: void 0,
969
- replicate: void 0,
970
- prodia: void 0,
971
- luma: void 0,
972
- bytedance: void 0,
973
- kling: void 0,
974
- elevenlabs: void 0,
975
- assemblyai: void 0,
976
- deepgram: void 0,
977
- gladia: void 0,
978
- lmnt: void 0,
979
- hume: void 0,
980
- revai: void 0,
981
- baseten: void 0,
982
- huggingface: void 0
983
- };
984
- var CACHE_TTLS = {
985
- openai: void 0,
986
- azure: void 0,
987
- anthropic: ["5m", "1h"],
988
- google: void 0,
989
- "google-vertex": void 0,
990
- mistral: void 0,
991
- cohere: void 0,
992
- bedrock: ["5m", "1h"],
993
- // Claude on Bedrock uses same TTLs as direct Anthropic
994
- openrouter: void 0,
995
- vercel: void 0,
996
- xai: void 0,
997
- groq: void 0,
998
- fal: void 0,
999
- deepinfra: void 0,
1000
- "black-forest-labs": void 0,
1001
- together: void 0,
1002
- fireworks: void 0,
1003
- deepseek: void 0,
1004
- moonshotai: void 0,
1005
- perplexity: void 0,
1006
- alibaba: void 0,
1007
- cerebras: void 0,
1008
- replicate: void 0,
1009
- prodia: void 0,
1010
- luma: void 0,
1011
- bytedance: void 0,
1012
- kling: void 0,
1013
- elevenlabs: void 0,
1014
- assemblyai: void 0,
1015
- deepgram: void 0,
1016
- gladia: void 0,
1017
- lmnt: void 0,
1018
- hume: void 0,
1019
- revai: void 0,
1020
- baseten: void 0,
1021
- huggingface: void 0
1022
- };
1023
- var DURATION_RE = /^\d+[mh]$/;
1024
-
1025
- export {
1026
- HOST_ALIASES,
1027
- resolveHostAlias,
1028
- providerFromHostAlias,
1029
- detectProvider,
1030
- ALIASES,
1031
- PROVIDER_PARAMS,
1032
- PARAM_SPECS,
1033
- isReasoningModel,
1034
- canHostOpenAIModels,
1035
- isGatewayProvider,
1036
- detectGatewaySubProvider,
1037
- REASONING_MODEL_UNSUPPORTED,
1038
- detectBedrockModelFamily,
1039
- bedrockSupportsCaching,
1040
- CACHE_VALUES,
1041
- CACHE_TTLS,
1042
- DURATION_RE
1043
- };