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/LICENSE +21 -0
- package/README.md +341 -330
- package/dist/ai-sdk.cjs +1 -1176
- package/dist/ai-sdk.d.cts +1 -1
- package/dist/ai-sdk.d.ts +1 -1
- package/dist/ai-sdk.js +1 -543
- package/dist/chunk-CT44CYBU.js +1 -0
- package/dist/chunk-JURQSYOT.js +1 -0
- package/dist/chunk-LIYUWJME.js +1 -0
- package/dist/chunk-M5ENVTNI.js +1 -0
- package/dist/index.cjs +1 -1351
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -22
- package/dist/normalize.cjs +1 -527
- package/dist/normalize.d.cts +1 -1
- package/dist/normalize.d.ts +1 -1
- package/dist/normalize.js +1 -7
- package/dist/parse.cjs +1 -159
- package/dist/parse.d.cts +4 -4
- package/dist/parse.d.ts +4 -4
- package/dist/parse.js +1 -9
- package/dist/{provider-core-B934MuhJ.d.cts → provider-core-CjpJ4qyF.d.cts} +35 -15
- package/dist/{provider-core-B934MuhJ.d.ts → provider-core-CjpJ4qyF.d.ts} +35 -15
- package/dist/providers.cjs +1 -1267
- package/dist/providers.d.cts +2 -2
- package/dist/providers.d.ts +2 -2
- package/dist/providers.js +1 -218
- package/dist/validate.cjs +1 -1334
- package/dist/validate.d.cts +1 -1
- package/dist/validate.d.ts +1 -1
- package/dist/validate.js +1 -9
- package/package.json +17 -2
- package/dist/chunk-5YTG2NRX.js +0 -42
- package/dist/chunk-76EFNZCF.js +0 -1043
- package/dist/chunk-DPVT3FFP.js +0 -116
- package/dist/chunk-OBLFZFNR.js +0 -175
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { LlmConnectionConfig, build, parse } from './parse.cjs';
|
|
2
2
|
export { NormalizeChange, NormalizeOptions, NormalizeResult, normalize } from './normalize.cjs';
|
|
3
3
|
export { ValidateOptions, ValidationIssue, validate } from './validate.cjs';
|
|
4
|
-
export { H as HOST_ALIASES, a as HostAlias, b as HostResolution, r as resolveHostAlias } from './provider-core-
|
|
4
|
+
export { H as HOST_ALIASES, a as HostAlias, b as HostResolution, r as resolveHostAlias } from './provider-core-CjpJ4qyF.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { LlmConnectionConfig, build, parse } from './parse.js';
|
|
2
2
|
export { NormalizeChange, NormalizeOptions, NormalizeResult, normalize } from './normalize.js';
|
|
3
3
|
export { ValidateOptions, ValidationIssue, validate } from './validate.js';
|
|
4
|
-
export { H as HOST_ALIASES, a as HostAlias, b as HostResolution, r as resolveHostAlias } from './provider-core-
|
|
4
|
+
export { H as HOST_ALIASES, a as HostAlias, b as HostResolution, r as resolveHostAlias } from './provider-core-CjpJ4qyF.js';
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
validate
|
|
3
|
-
} from "./chunk-OBLFZFNR.js";
|
|
4
|
-
import {
|
|
5
|
-
normalize
|
|
6
|
-
} from "./chunk-DPVT3FFP.js";
|
|
7
|
-
import {
|
|
8
|
-
build,
|
|
9
|
-
parse
|
|
10
|
-
} from "./chunk-5YTG2NRX.js";
|
|
11
|
-
import {
|
|
12
|
-
HOST_ALIASES,
|
|
13
|
-
resolveHostAlias
|
|
14
|
-
} from "./chunk-76EFNZCF.js";
|
|
15
|
-
export {
|
|
16
|
-
HOST_ALIASES,
|
|
17
|
-
build,
|
|
18
|
-
normalize,
|
|
19
|
-
parse,
|
|
20
|
-
resolveHostAlias,
|
|
21
|
-
validate
|
|
22
|
-
};
|
|
1
|
+
import{validate as o}from"./chunk-CT44CYBU.js";import{normalize as r}from"./chunk-JURQSYOT.js";import{build as m,parse as p}from"./chunk-M5ENVTNI.js";import{HOST_ALIASES as t,resolveHostAlias as c}from"./chunk-LIYUWJME.js";export{t as HOST_ALIASES,m as build,r as normalize,p as parse,c as resolveHostAlias,o as validate};
|
package/dist/normalize.cjs
CHANGED
|
@@ -1,527 +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/normalize.ts
|
|
21
|
-
var normalize_exports = {};
|
|
22
|
-
__export(normalize_exports, {
|
|
23
|
-
normalize: () => normalize
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(normalize_exports);
|
|
26
|
-
|
|
27
|
-
// src/provider-core.ts
|
|
28
|
-
function hasOwn(object, key) {
|
|
29
|
-
return Object.prototype.hasOwnProperty.call(object, key);
|
|
30
|
-
}
|
|
31
|
-
var HOST_ALIAS_PROVIDERS = {
|
|
32
|
-
aistudio: "google",
|
|
33
|
-
vertex: "google-vertex",
|
|
34
|
-
grok: "xai",
|
|
35
|
-
bfl: "black-forest-labs",
|
|
36
|
-
moonshot: "moonshotai",
|
|
37
|
-
alibaba: "alibaba",
|
|
38
|
-
alibabacloud: "alibaba",
|
|
39
|
-
dashscope: "alibaba",
|
|
40
|
-
togetherai: "together",
|
|
41
|
-
fireworksai: "fireworks"
|
|
42
|
-
};
|
|
43
|
-
function providerFromHostAlias(alias) {
|
|
44
|
-
const normalizedAlias = alias.toLowerCase();
|
|
45
|
-
if (hasOwn(PROVIDER_PARAMS, normalizedAlias)) {
|
|
46
|
-
return normalizedAlias;
|
|
47
|
-
}
|
|
48
|
-
if (hasOwn(HOST_ALIAS_PROVIDERS, normalizedAlias)) {
|
|
49
|
-
return HOST_ALIAS_PROVIDERS[normalizedAlias];
|
|
50
|
-
}
|
|
51
|
-
return void 0;
|
|
52
|
-
}
|
|
53
|
-
function detectProvider(host) {
|
|
54
|
-
host = host.toLowerCase();
|
|
55
|
-
if (host.includes("openrouter")) return "openrouter";
|
|
56
|
-
if (host.includes("gateway.ai.vercel")) return "vercel";
|
|
57
|
-
if (host.includes("amazonaws") || host.includes("bedrock")) return "bedrock";
|
|
58
|
-
if (host.includes("aiplatform.googleapis")) return "google-vertex";
|
|
59
|
-
if (host.includes("api.x.ai")) return "xai";
|
|
60
|
-
if (host.includes("groq")) return "groq";
|
|
61
|
-
if (host.includes("fal.run") || host.includes("fal.ai")) return "fal";
|
|
62
|
-
if (host.includes("deepinfra")) return "deepinfra";
|
|
63
|
-
if (host.includes("bfl.ai")) return "black-forest-labs";
|
|
64
|
-
if (host.includes("together")) return "together";
|
|
65
|
-
if (host.includes("fireworks")) return "fireworks";
|
|
66
|
-
if (host.includes("deepseek")) return "deepseek";
|
|
67
|
-
if (host.includes("moonshot")) return "moonshotai";
|
|
68
|
-
if (host.includes("perplexity")) return "perplexity";
|
|
69
|
-
if (host.includes("dashscope") || host.includes("aliyuncs")) return "alibaba";
|
|
70
|
-
if (host.includes("cerebras")) return "cerebras";
|
|
71
|
-
if (host.includes("replicate")) return "replicate";
|
|
72
|
-
if (host.includes("prodia")) return "prodia";
|
|
73
|
-
if (host.includes("lumalabs") || host.includes("luma")) return "luma";
|
|
74
|
-
if (host.includes("volces") || host.includes("bytedance")) return "bytedance";
|
|
75
|
-
if (host.includes("kling")) return "kling";
|
|
76
|
-
if (host.includes("elevenlabs")) return "elevenlabs";
|
|
77
|
-
if (host.includes("assemblyai")) return "assemblyai";
|
|
78
|
-
if (host.includes("deepgram")) return "deepgram";
|
|
79
|
-
if (host.includes("gladia")) return "gladia";
|
|
80
|
-
if (host.includes("lmnt")) return "lmnt";
|
|
81
|
-
if (host.includes("hume")) return "hume";
|
|
82
|
-
if (host.includes("rev.ai")) return "revai";
|
|
83
|
-
if (host.includes("baseten")) return "baseten";
|
|
84
|
-
if (host.includes("huggingface")) return "huggingface";
|
|
85
|
-
if (host.includes("azure")) return "azure";
|
|
86
|
-
if (host.includes("openai")) return "openai";
|
|
87
|
-
if (host.includes("anthropic") || host.includes("claude")) return "anthropic";
|
|
88
|
-
if (host.includes("googleapis") || host.includes("google")) return "google";
|
|
89
|
-
if (host.includes("mistral")) return "mistral";
|
|
90
|
-
if (host.includes("cohere")) return "cohere";
|
|
91
|
-
return void 0;
|
|
92
|
-
}
|
|
93
|
-
var ALIASES = {
|
|
94
|
-
// temperature
|
|
95
|
-
temp: "temperature",
|
|
96
|
-
// max_tokens
|
|
97
|
-
max: "max_tokens",
|
|
98
|
-
max_out: "max_tokens",
|
|
99
|
-
max_output: "max_tokens",
|
|
100
|
-
max_output_tokens: "max_tokens",
|
|
101
|
-
max_completion_tokens: "max_tokens",
|
|
102
|
-
maxOutputTokens: "max_tokens",
|
|
103
|
-
maxTokens: "max_tokens",
|
|
104
|
-
// top_p
|
|
105
|
-
topp: "top_p",
|
|
106
|
-
topP: "top_p",
|
|
107
|
-
nucleus: "top_p",
|
|
108
|
-
// top_k
|
|
109
|
-
topk: "top_k",
|
|
110
|
-
topK: "top_k",
|
|
111
|
-
// frequency_penalty
|
|
112
|
-
freq: "frequency_penalty",
|
|
113
|
-
freq_penalty: "frequency_penalty",
|
|
114
|
-
frequencyPenalty: "frequency_penalty",
|
|
115
|
-
repetition_penalty: "frequency_penalty",
|
|
116
|
-
// presence_penalty
|
|
117
|
-
pres: "presence_penalty",
|
|
118
|
-
pres_penalty: "presence_penalty",
|
|
119
|
-
presencePenalty: "presence_penalty",
|
|
120
|
-
// stop
|
|
121
|
-
stop_sequences: "stop",
|
|
122
|
-
stopSequences: "stop",
|
|
123
|
-
stop_sequence: "stop",
|
|
124
|
-
// seed
|
|
125
|
-
random_seed: "seed",
|
|
126
|
-
randomSeed: "seed",
|
|
127
|
-
// n (completions count)
|
|
128
|
-
candidateCount: "n",
|
|
129
|
-
candidate_count: "n",
|
|
130
|
-
num_completions: "n",
|
|
131
|
-
// effort / reasoning
|
|
132
|
-
reasoning_effort: "effort",
|
|
133
|
-
reasoning: "effort",
|
|
134
|
-
// cache
|
|
135
|
-
cache_control: "cache",
|
|
136
|
-
cacheControl: "cache",
|
|
137
|
-
cachePoint: "cache",
|
|
138
|
-
cache_point: "cache"
|
|
139
|
-
};
|
|
140
|
-
var OPENAI_COMPATIBLE_PARAMS = {
|
|
141
|
-
temperature: "temperature",
|
|
142
|
-
max_tokens: "max_tokens",
|
|
143
|
-
top_p: "top_p",
|
|
144
|
-
top_k: "top_k",
|
|
145
|
-
frequency_penalty: "frequency_penalty",
|
|
146
|
-
presence_penalty: "presence_penalty",
|
|
147
|
-
stop: "stop",
|
|
148
|
-
n: "n",
|
|
149
|
-
seed: "seed",
|
|
150
|
-
stream: "stream",
|
|
151
|
-
effort: "reasoning_effort"
|
|
152
|
-
};
|
|
153
|
-
var GOOGLE_COMPATIBLE_PARAMS = {
|
|
154
|
-
temperature: "temperature",
|
|
155
|
-
max_tokens: "maxOutputTokens",
|
|
156
|
-
top_p: "topP",
|
|
157
|
-
top_k: "topK",
|
|
158
|
-
frequency_penalty: "frequencyPenalty",
|
|
159
|
-
presence_penalty: "presencePenalty",
|
|
160
|
-
stop: "stopSequences",
|
|
161
|
-
n: "candidateCount",
|
|
162
|
-
stream: "stream",
|
|
163
|
-
seed: "seed",
|
|
164
|
-
responseMimeType: "responseMimeType",
|
|
165
|
-
responseSchema: "responseSchema"
|
|
166
|
-
};
|
|
167
|
-
var PROVIDER_PARAMS = {
|
|
168
|
-
openai: {
|
|
169
|
-
temperature: "temperature",
|
|
170
|
-
max_tokens: "max_tokens",
|
|
171
|
-
top_p: "top_p",
|
|
172
|
-
frequency_penalty: "frequency_penalty",
|
|
173
|
-
presence_penalty: "presence_penalty",
|
|
174
|
-
stop: "stop",
|
|
175
|
-
n: "n",
|
|
176
|
-
seed: "seed",
|
|
177
|
-
stream: "stream",
|
|
178
|
-
effort: "reasoning_effort"
|
|
179
|
-
},
|
|
180
|
-
azure: OPENAI_COMPATIBLE_PARAMS,
|
|
181
|
-
anthropic: {
|
|
182
|
-
temperature: "temperature",
|
|
183
|
-
max_tokens: "max_tokens",
|
|
184
|
-
top_p: "top_p",
|
|
185
|
-
top_k: "top_k",
|
|
186
|
-
stop: "stop_sequences",
|
|
187
|
-
stream: "stream",
|
|
188
|
-
effort: "effort",
|
|
189
|
-
cache: "cache_control",
|
|
190
|
-
cache_ttl: "cache_ttl"
|
|
191
|
-
},
|
|
192
|
-
google: {
|
|
193
|
-
temperature: "temperature",
|
|
194
|
-
max_tokens: "maxOutputTokens",
|
|
195
|
-
top_p: "topP",
|
|
196
|
-
top_k: "topK",
|
|
197
|
-
frequency_penalty: "frequencyPenalty",
|
|
198
|
-
presence_penalty: "presencePenalty",
|
|
199
|
-
stop: "stopSequences",
|
|
200
|
-
n: "candidateCount",
|
|
201
|
-
stream: "stream",
|
|
202
|
-
seed: "seed",
|
|
203
|
-
responseMimeType: "responseMimeType",
|
|
204
|
-
responseSchema: "responseSchema"
|
|
205
|
-
},
|
|
206
|
-
"google-vertex": GOOGLE_COMPATIBLE_PARAMS,
|
|
207
|
-
mistral: {
|
|
208
|
-
temperature: "temperature",
|
|
209
|
-
max_tokens: "max_tokens",
|
|
210
|
-
top_p: "top_p",
|
|
211
|
-
frequency_penalty: "frequency_penalty",
|
|
212
|
-
presence_penalty: "presence_penalty",
|
|
213
|
-
stop: "stop",
|
|
214
|
-
n: "n",
|
|
215
|
-
seed: "random_seed",
|
|
216
|
-
stream: "stream",
|
|
217
|
-
safe_prompt: "safe_prompt",
|
|
218
|
-
min_tokens: "min_tokens"
|
|
219
|
-
},
|
|
220
|
-
cohere: {
|
|
221
|
-
temperature: "temperature",
|
|
222
|
-
max_tokens: "max_tokens",
|
|
223
|
-
top_p: "p",
|
|
224
|
-
top_k: "k",
|
|
225
|
-
frequency_penalty: "frequency_penalty",
|
|
226
|
-
presence_penalty: "presence_penalty",
|
|
227
|
-
stop: "stop_sequences",
|
|
228
|
-
stream: "stream",
|
|
229
|
-
seed: "seed"
|
|
230
|
-
},
|
|
231
|
-
bedrock: {
|
|
232
|
-
// Bedrock Converse API uses camelCase
|
|
233
|
-
temperature: "temperature",
|
|
234
|
-
max_tokens: "maxTokens",
|
|
235
|
-
top_p: "topP",
|
|
236
|
-
top_k: "topK",
|
|
237
|
-
// Claude models via additionalModelRequestFields
|
|
238
|
-
stop: "stopSequences",
|
|
239
|
-
stream: "stream",
|
|
240
|
-
cache: "cache_control",
|
|
241
|
-
cache_ttl: "cache_ttl"
|
|
242
|
-
},
|
|
243
|
-
openrouter: {
|
|
244
|
-
// OpenAI-compatible API with extra routing params
|
|
245
|
-
temperature: "temperature",
|
|
246
|
-
max_tokens: "max_tokens",
|
|
247
|
-
top_p: "top_p",
|
|
248
|
-
top_k: "top_k",
|
|
249
|
-
frequency_penalty: "frequency_penalty",
|
|
250
|
-
presence_penalty: "presence_penalty",
|
|
251
|
-
stop: "stop",
|
|
252
|
-
n: "n",
|
|
253
|
-
seed: "seed",
|
|
254
|
-
stream: "stream",
|
|
255
|
-
effort: "reasoning_effort"
|
|
256
|
-
},
|
|
257
|
-
vercel: {
|
|
258
|
-
// OpenAI-compatible gateway
|
|
259
|
-
temperature: "temperature",
|
|
260
|
-
max_tokens: "max_tokens",
|
|
261
|
-
top_p: "top_p",
|
|
262
|
-
top_k: "top_k",
|
|
263
|
-
frequency_penalty: "frequency_penalty",
|
|
264
|
-
presence_penalty: "presence_penalty",
|
|
265
|
-
stop: "stop",
|
|
266
|
-
n: "n",
|
|
267
|
-
seed: "seed",
|
|
268
|
-
stream: "stream",
|
|
269
|
-
effort: "reasoning_effort"
|
|
270
|
-
},
|
|
271
|
-
xai: OPENAI_COMPATIBLE_PARAMS,
|
|
272
|
-
groq: OPENAI_COMPATIBLE_PARAMS,
|
|
273
|
-
fal: {},
|
|
274
|
-
deepinfra: OPENAI_COMPATIBLE_PARAMS,
|
|
275
|
-
"black-forest-labs": {},
|
|
276
|
-
together: OPENAI_COMPATIBLE_PARAMS,
|
|
277
|
-
fireworks: OPENAI_COMPATIBLE_PARAMS,
|
|
278
|
-
deepseek: OPENAI_COMPATIBLE_PARAMS,
|
|
279
|
-
moonshotai: OPENAI_COMPATIBLE_PARAMS,
|
|
280
|
-
perplexity: OPENAI_COMPATIBLE_PARAMS,
|
|
281
|
-
alibaba: OPENAI_COMPATIBLE_PARAMS,
|
|
282
|
-
cerebras: OPENAI_COMPATIBLE_PARAMS,
|
|
283
|
-
replicate: {},
|
|
284
|
-
prodia: {},
|
|
285
|
-
luma: {},
|
|
286
|
-
bytedance: {},
|
|
287
|
-
kling: {},
|
|
288
|
-
elevenlabs: {},
|
|
289
|
-
assemblyai: {},
|
|
290
|
-
deepgram: {},
|
|
291
|
-
gladia: {},
|
|
292
|
-
lmnt: {},
|
|
293
|
-
hume: {},
|
|
294
|
-
revai: {},
|
|
295
|
-
baseten: OPENAI_COMPATIBLE_PARAMS,
|
|
296
|
-
huggingface: OPENAI_COMPATIBLE_PARAMS
|
|
297
|
-
};
|
|
298
|
-
function isReasoningModel(model) {
|
|
299
|
-
const name = model.includes("/") ? model.split("/").pop() : model;
|
|
300
|
-
return /^o[134]/.test(name);
|
|
301
|
-
}
|
|
302
|
-
function canHostOpenAIModels(provider) {
|
|
303
|
-
return provider === "openai" || provider === "openrouter" || provider === "vercel";
|
|
304
|
-
}
|
|
305
|
-
function isGatewayProvider(provider) {
|
|
306
|
-
return provider === "openrouter" || provider === "vercel";
|
|
307
|
-
}
|
|
308
|
-
function detectGatewaySubProvider(model) {
|
|
309
|
-
const slash = model.indexOf("/");
|
|
310
|
-
if (slash < 1) return void 0;
|
|
311
|
-
const prefix = model.slice(0, slash);
|
|
312
|
-
const direct = [
|
|
313
|
-
"openai",
|
|
314
|
-
"anthropic",
|
|
315
|
-
"google",
|
|
316
|
-
"mistral",
|
|
317
|
-
"cohere"
|
|
318
|
-
];
|
|
319
|
-
return direct.find((p) => p === prefix);
|
|
320
|
-
}
|
|
321
|
-
function detectBedrockModelFamily(model) {
|
|
322
|
-
const parts = model.split(".");
|
|
323
|
-
let prefix = parts[0];
|
|
324
|
-
if (["us", "eu", "apac", "global"].includes(prefix) && parts.length > 1) {
|
|
325
|
-
prefix = parts[1];
|
|
326
|
-
}
|
|
327
|
-
const families = [
|
|
328
|
-
"anthropic",
|
|
329
|
-
"meta",
|
|
330
|
-
"amazon",
|
|
331
|
-
"mistral",
|
|
332
|
-
"cohere",
|
|
333
|
-
"ai21"
|
|
334
|
-
];
|
|
335
|
-
return families.find((f) => prefix === f);
|
|
336
|
-
}
|
|
337
|
-
function bedrockSupportsCaching(model) {
|
|
338
|
-
const family = detectBedrockModelFamily(model);
|
|
339
|
-
if (family === "anthropic") return true;
|
|
340
|
-
if (family === "amazon" && model.includes("nova")) return true;
|
|
341
|
-
return false;
|
|
342
|
-
}
|
|
343
|
-
var CACHE_VALUES = {
|
|
344
|
-
openai: void 0,
|
|
345
|
-
// OpenAI auto-caches; no explicit param
|
|
346
|
-
azure: void 0,
|
|
347
|
-
anthropic: "ephemeral",
|
|
348
|
-
google: void 0,
|
|
349
|
-
// Google uses explicit caching API, not a param
|
|
350
|
-
"google-vertex": void 0,
|
|
351
|
-
mistral: void 0,
|
|
352
|
-
cohere: void 0,
|
|
353
|
-
bedrock: "ephemeral",
|
|
354
|
-
// Supported for Claude models on Bedrock
|
|
355
|
-
openrouter: void 0,
|
|
356
|
-
// Depends on underlying provider
|
|
357
|
-
vercel: void 0,
|
|
358
|
-
// Depends on underlying provider
|
|
359
|
-
xai: void 0,
|
|
360
|
-
groq: void 0,
|
|
361
|
-
fal: void 0,
|
|
362
|
-
deepinfra: void 0,
|
|
363
|
-
"black-forest-labs": void 0,
|
|
364
|
-
together: void 0,
|
|
365
|
-
fireworks: void 0,
|
|
366
|
-
deepseek: void 0,
|
|
367
|
-
moonshotai: void 0,
|
|
368
|
-
perplexity: void 0,
|
|
369
|
-
alibaba: void 0,
|
|
370
|
-
cerebras: void 0,
|
|
371
|
-
replicate: void 0,
|
|
372
|
-
prodia: void 0,
|
|
373
|
-
luma: void 0,
|
|
374
|
-
bytedance: void 0,
|
|
375
|
-
kling: void 0,
|
|
376
|
-
elevenlabs: void 0,
|
|
377
|
-
assemblyai: void 0,
|
|
378
|
-
deepgram: void 0,
|
|
379
|
-
gladia: void 0,
|
|
380
|
-
lmnt: void 0,
|
|
381
|
-
hume: void 0,
|
|
382
|
-
revai: void 0,
|
|
383
|
-
baseten: void 0,
|
|
384
|
-
huggingface: void 0
|
|
385
|
-
};
|
|
386
|
-
var CACHE_TTLS = {
|
|
387
|
-
openai: void 0,
|
|
388
|
-
azure: void 0,
|
|
389
|
-
anthropic: ["5m", "1h"],
|
|
390
|
-
google: void 0,
|
|
391
|
-
"google-vertex": void 0,
|
|
392
|
-
mistral: void 0,
|
|
393
|
-
cohere: void 0,
|
|
394
|
-
bedrock: ["5m", "1h"],
|
|
395
|
-
// Claude on Bedrock uses same TTLs as direct Anthropic
|
|
396
|
-
openrouter: void 0,
|
|
397
|
-
vercel: void 0,
|
|
398
|
-
xai: void 0,
|
|
399
|
-
groq: void 0,
|
|
400
|
-
fal: void 0,
|
|
401
|
-
deepinfra: void 0,
|
|
402
|
-
"black-forest-labs": void 0,
|
|
403
|
-
together: void 0,
|
|
404
|
-
fireworks: void 0,
|
|
405
|
-
deepseek: void 0,
|
|
406
|
-
moonshotai: void 0,
|
|
407
|
-
perplexity: void 0,
|
|
408
|
-
alibaba: void 0,
|
|
409
|
-
cerebras: void 0,
|
|
410
|
-
replicate: void 0,
|
|
411
|
-
prodia: void 0,
|
|
412
|
-
luma: void 0,
|
|
413
|
-
bytedance: void 0,
|
|
414
|
-
kling: void 0,
|
|
415
|
-
elevenlabs: void 0,
|
|
416
|
-
assemblyai: void 0,
|
|
417
|
-
deepgram: void 0,
|
|
418
|
-
gladia: void 0,
|
|
419
|
-
lmnt: void 0,
|
|
420
|
-
hume: void 0,
|
|
421
|
-
revai: void 0,
|
|
422
|
-
baseten: void 0,
|
|
423
|
-
huggingface: void 0
|
|
424
|
-
};
|
|
425
|
-
var DURATION_RE = /^\d+[mh]$/;
|
|
426
|
-
|
|
427
|
-
// src/normalize.ts
|
|
428
|
-
function normalize(config, options = {}) {
|
|
429
|
-
const provider = (config.hostAlias ? providerFromHostAlias(config.hostAlias) : void 0) ?? detectProvider(config.host);
|
|
430
|
-
const subProvider = provider && isGatewayProvider(provider) ? detectGatewaySubProvider(config.model) : void 0;
|
|
431
|
-
const changes = [];
|
|
432
|
-
const params = {};
|
|
433
|
-
for (const [rawKey, value] of Object.entries(config.params)) {
|
|
434
|
-
let key = rawKey;
|
|
435
|
-
if (ALIASES[key]) {
|
|
436
|
-
const canonical = ALIASES[key];
|
|
437
|
-
if (options.verbose) {
|
|
438
|
-
changes.push({
|
|
439
|
-
from: key,
|
|
440
|
-
to: canonical,
|
|
441
|
-
value,
|
|
442
|
-
reason: `alias: "${key}" \u2192 "${canonical}"`
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
key = canonical;
|
|
446
|
-
}
|
|
447
|
-
if (key === "cache" && provider) {
|
|
448
|
-
let cacheValue = CACHE_VALUES[provider];
|
|
449
|
-
if (provider === "bedrock" && !bedrockSupportsCaching(config.model)) {
|
|
450
|
-
cacheValue = void 0;
|
|
451
|
-
}
|
|
452
|
-
if (!cacheValue) {
|
|
453
|
-
if (options.verbose) {
|
|
454
|
-
changes.push({
|
|
455
|
-
from: "cache",
|
|
456
|
-
to: "(dropped)",
|
|
457
|
-
value,
|
|
458
|
-
reason: `${provider} does not use a cache param for this model (caching is automatic or unsupported)`
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
continue;
|
|
462
|
-
}
|
|
463
|
-
const isBool = value === "true" || value === "1" || value === "yes";
|
|
464
|
-
const isDuration = DURATION_RE.test(value);
|
|
465
|
-
if (isBool || isDuration) {
|
|
466
|
-
const providerKey = PROVIDER_PARAMS[provider]?.["cache"] ?? "cache";
|
|
467
|
-
if (options.verbose) {
|
|
468
|
-
changes.push({
|
|
469
|
-
from: "cache",
|
|
470
|
-
to: providerKey,
|
|
471
|
-
value: cacheValue,
|
|
472
|
-
reason: `cache=${value} \u2192 ${providerKey}=${cacheValue} for ${provider}`
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
params[providerKey] = cacheValue;
|
|
476
|
-
if (isDuration && CACHE_TTLS[provider]) {
|
|
477
|
-
if (options.verbose) {
|
|
478
|
-
changes.push({
|
|
479
|
-
from: "cache",
|
|
480
|
-
to: "cache_ttl",
|
|
481
|
-
value,
|
|
482
|
-
reason: `cache=${value} \u2192 cache_ttl=${value} for ${provider}`
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
params["cache_ttl"] = value;
|
|
486
|
-
}
|
|
487
|
-
continue;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
if (provider && PROVIDER_PARAMS[provider]) {
|
|
491
|
-
const providerKey = PROVIDER_PARAMS[provider][key];
|
|
492
|
-
if (providerKey && providerKey !== key) {
|
|
493
|
-
if (options.verbose) {
|
|
494
|
-
changes.push({
|
|
495
|
-
from: key,
|
|
496
|
-
to: providerKey,
|
|
497
|
-
value,
|
|
498
|
-
reason: `${provider} uses "${providerKey}" instead of "${key}"`
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
key = providerKey;
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
if (provider && canHostOpenAIModels(provider) && isReasoningModel(config.model) && key === "max_tokens") {
|
|
505
|
-
if (options.verbose) {
|
|
506
|
-
changes.push({
|
|
507
|
-
from: "max_tokens",
|
|
508
|
-
to: "max_completion_tokens",
|
|
509
|
-
value,
|
|
510
|
-
reason: "OpenAI reasoning models use max_completion_tokens instead of max_tokens"
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
key = "max_completion_tokens";
|
|
514
|
-
}
|
|
515
|
-
params[key] = value;
|
|
516
|
-
}
|
|
517
|
-
return {
|
|
518
|
-
config: { ...config, params },
|
|
519
|
-
provider,
|
|
520
|
-
subProvider,
|
|
521
|
-
changes
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
525
|
-
0 && (module.exports = {
|
|
526
|
-
normalize
|
|
527
|
-
});
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,a={};function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}((e,r)=>{for(var o in r)t(e,o,{get:r[o],enumerable:!0})})(a,{normalize:()=>R}),module.exports=(e=a,((e,a,i,p)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let s of o(a))n.call(e,s)||s===i||t(e,s,{get:()=>a[s],enumerable:!(p=r(a,s))||p.enumerable});return e})(t({},"__esModule",{value:!0}),e));var 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 s(e){return function(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}(e).toLowerCase().split(":")[0]??e}function c(e,...t){return t.some(t=>{const r=t.toLowerCase();return e===r||e.endsWith(`.${r}`)})}function m(e,...t){const r=e.split(".");return t.some(e=>r.some(t=>t.startsWith(e.toLowerCase())))}var l=new Set(["-","."]);function d(e){return e.trim().toLowerCase()}function u(e){const t=d(e),r=t.lastIndexOf("/");return r>=0?t.slice(r+1):t}function y(e,t){const r=u(e),o=d(t);if(!r||!o)return!1;if(r===o)return!0;const n=r[o.length];return r.startsWith(o)&&void 0!==n&&l.has(n)}var f={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"},_=["none","minimal","low","medium","high","xhigh","max"],g={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:_,default:"medium",description:"Reasoning effort"}}},b={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"}},h={prompt:"prompt",negative_prompt:"negative_prompt",seed:"seed",image_size:"image_size",aspect_ratio:"aspect_ratio",output_format:"output_format",width:"width",height:"height"},v={params:{...h,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:{...b,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"}}},k={params:{...h,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:{...b,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"}}},x={params:{...h,model:"model",style_preset:"style_preset",steps:"steps",cfg_scale:"cfg_scale",upscale:"upscale",sampler:"sampler",type:"type",config:"config",price:"price"},specs:{...b,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"}}},q={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"}}},w={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:_,default:"medium",description:"Reasoning effort"}}},azure:g,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:_,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:q,"google-vertex":q,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:{...g.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:{...g.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:{...g.params},specs:{...g.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:g,groq:g,fal:v,deepinfra:g,"black-forest-labs":{params:{},specs:{}},together:g,fireworks:g,deepseek:g,moonshotai:g,perplexity:g,alibaba:g,cerebras:g,replicate:k,prodia:x,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:g,huggingface:g},P=Object.fromEntries(Object.entries(w).map(([e,t])=>[e,t.params])),z=(Object.fromEntries(Object.entries(w).map(([e,t])=>[e,t.specs])),Object.fromEntries(Object.entries(w).filter(([,e])=>void 0!==e.cacheValue).map(([e,t])=>[e,t.cacheValue]))),O=Object.fromEntries(Object.entries(w).filter(([,e])=>void 0!==e.cacheTtls).map(([e,t])=>[e,t.cacheTtls])),S=[];function C(e){const t=u(e),r=t.match(/^o\d+/)?.[0],o=t.match(/^gpt-[5-9]/)?.[0];return void 0!==r&&y(t,r)||void 0!==o&&y(t,o)||S.some(e=>y(t,e))}function T(e){return"openai"===e||"azure"===e||"openrouter"===e||"vercel"===e}var j=new Set(["temperature","top_p","top_k","frequency_penalty","presence_penalty","n"]);function M(e){const t=function(e){const t=u(e).split(".");return["anthropic","meta","amazon","mistral","cohere","ai21"].find(e=>t.includes(e))}(e);if("anthropic"===t)return!0;if("amazon"===t){const t=u(e).split("."),r=t.indexOf("amazon"),o=r>=0?t[r+1]:void 0;return!!o&&y(o,"nova")}return!1}var G=/^\d+[mh]$/;function R(e,t={}){const r=(e.hostAlias?function(e){const t=e.toLowerCase();return i(P,t)?t:i(p,t)?p[t]:void 0}(e.hostAlias):void 0)??(c(o=s(o=e.host),"openrouter","openrouter.ai")?"openrouter":c(o,"vercel","gateway.ai.vercel.app","gateway.ai.vercel.sh")?"vercel":c(o,"bedrock","amazonaws.com")||m(o,"bedrock")?"bedrock":c(o,"aiplatform.googleapis.com")?"google-vertex":c(o,"xai","x.ai","api.x.ai")?"xai":c(o,"groq","groq.com","api.groq.com")?"groq":c(o,"fal","fal.run","fal.ai")?"fal":c(o,"deepinfra","deepinfra.com")?"deepinfra":c(o,"bfl","bfl.ai","api.bfl.ai")?"black-forest-labs":c(o,"together","together.xyz")?"together":c(o,"fireworks","fireworks.ai")?"fireworks":c(o,"deepseek","deepseek.com")?"deepseek":c(o,"moonshot","moonshot.ai")?"moonshotai":c(o,"perplexity","perplexity.ai")?"perplexity":c(o,"alibaba","aliyuncs.com")||m(o,"dashscope")?"alibaba":c(o,"cerebras","cerebras.ai")?"cerebras":c(o,"replicate","replicate.com")?"replicate":c(o,"prodia","prodia.com")?"prodia":c(o,"luma","lumalabs.ai")?"luma":c(o,"bytedance","volces.com")||function(e,...t){const r=e.split(".");return t.some(e=>r.includes(e.toLowerCase()))}(o,"bytedance")?"bytedance":c(o,"kling","klingai.com")?"kling":c(o,"elevenlabs","elevenlabs.io")?"elevenlabs":c(o,"assemblyai","assemblyai.com")?"assemblyai":c(o,"deepgram","deepgram.com")?"deepgram":c(o,"gladia","gladia.io")?"gladia":c(o,"lmnt","lmnt.com")?"lmnt":c(o,"hume","hume.ai")?"hume":c(o,"revai","rev.ai")?"revai":c(o,"baseten","baseten.co")?"baseten":c(o,"huggingface","huggingface.co")?"huggingface":c(o,"azure","azure.com")?"azure":c(o,"openai","openai.com")?"openai":c(o,"anthropic","anthropic.com","claude.ai")?"anthropic":c(o,"google","googleapis.com")?"google":c(o,"mistral","mistral.ai")?"mistral":c(o,"cohere","cohere.com")?"cohere":void 0);var o;const n=r&&function(e){return"openrouter"===e||"vercel"===e}(r)?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"}[d(e.slice(0,t))]}(e.model):void 0,a=[],l={};for(const[o,n]of Object.entries(e.params)){let i=o;if(f[i]){const e=f[i];t.verbose&&a.push({from:i,to:e,value:n,reason:`alias: "${i}" → "${e}"`}),i=e}if("cache"===i&&r){let o=z[r];if("bedrock"!==r||M(e.model)||(o=void 0),!o){t.verbose&&a.push({from:"cache",to:"(dropped)",value:n,reason:`${r} does not use a cache param for this model (caching is automatic or unsupported)`});continue}const i="true"===n||"1"===n||"yes"===n,p=G.test(n);if(i||p){const e=P[r]?.cache??"cache";t.verbose&&a.push({from:"cache",to:e,value:o,reason:`cache=${n} → ${e}=${o} for ${r}`}),l[e]=o,p&&O[r]&&(t.verbose&&a.push({from:"cache",to:"cache_ttl",value:n,reason:`cache=${n} → cache_ttl=${n} for ${r}`}),l.cache_ttl=n);continue}}if(r&&P[r]){const e=P[r][i];e&&e!==i&&(t.verbose&&a.push({from:i,to:e,value:n,reason:`${r} uses "${e}" instead of "${i}"`}),i=e)}r&&T(r)&&C(e.model)&&"max_tokens"===i&&(t.verbose&&a.push({from:"max_tokens",to:"max_completion_tokens",value:n,reason:"OpenAI reasoning models use max_completion_tokens instead of max_tokens"}),i="max_completion_tokens"),r&&T(r)&&C(e.model)&&j.has(i)?t.verbose&&a.push({from:i,to:"(dropped)",value:n,reason:`${r} reasoning model "${e.model}" does not support "${i}"`}):l[i]=n}return{config:{...e,params:l},provider:r,subProvider:n,changes:a}}
|
package/dist/normalize.d.cts
CHANGED
package/dist/normalize.d.ts
CHANGED