llm-strings 1.1.2 → 1.3.0

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