aieo 0.1.32 → 0.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +17 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -22889,7 +22889,7 @@ function getModelForProvider(provider, modelName) {
|
|
|
22889
22889
|
}
|
|
22890
22890
|
return model;
|
|
22891
22891
|
}
|
|
22892
|
-
function getModelDetails(modelName, apiKeyIn, baseUrl) {
|
|
22892
|
+
function getModelDetails(modelName, apiKeyIn, baseUrl, headers) {
|
|
22893
22893
|
const provider = getProviderForModel(modelName);
|
|
22894
22894
|
const apiKey = apiKeyIn || getApiKeyForProvider(provider);
|
|
22895
22895
|
console.log("===> getModelDetails", {
|
|
@@ -22897,12 +22897,14 @@ function getModelDetails(modelName, apiKeyIn, baseUrl) {
|
|
|
22897
22897
|
modelName: modelName || "(default)",
|
|
22898
22898
|
keySource: apiKeyIn ? "request body" : "env var",
|
|
22899
22899
|
apiKeyPrefix: apiKey ? apiKey.slice(0, 12) + "..." : "(missing)",
|
|
22900
|
-
baseUrl: baseUrl || "(default)"
|
|
22900
|
+
baseUrl: baseUrl || "(default)",
|
|
22901
|
+
headerKeys: headers ? Object.keys(headers) : []
|
|
22901
22902
|
});
|
|
22902
22903
|
const model = getModel(provider, {
|
|
22903
22904
|
modelName,
|
|
22904
22905
|
apiKey,
|
|
22905
|
-
baseUrl
|
|
22906
|
+
baseUrl,
|
|
22907
|
+
headers
|
|
22906
22908
|
});
|
|
22907
22909
|
let modelId;
|
|
22908
22910
|
if (modelName && modelName.includes("/")) {
|
|
@@ -22960,29 +22962,37 @@ function getModel(provider, opts) {
|
|
|
22960
22962
|
const source = opts?.baseUrl ? "caller" : "LLM_GATEWAY";
|
|
22961
22963
|
console.log(`[${source}] routing ${provider} via ${baseURL}`);
|
|
22962
22964
|
}
|
|
22965
|
+
const extraHeaders = opts?.headers && Object.keys(opts.headers).length > 0 ? opts.headers : void 0;
|
|
22966
|
+
if (extraHeaders) {
|
|
22967
|
+
console.log(`[headers] attaching ${Object.keys(extraHeaders).length} custom header(s) to ${provider} client`);
|
|
22968
|
+
}
|
|
22963
22969
|
switch (provider) {
|
|
22964
22970
|
case "anthropic":
|
|
22965
22971
|
const anthropic2 = createAnthropic({
|
|
22966
22972
|
apiKey,
|
|
22967
|
-
...baseURL && { baseURL }
|
|
22973
|
+
...baseURL && { baseURL },
|
|
22974
|
+
...extraHeaders && { headers: extraHeaders }
|
|
22968
22975
|
});
|
|
22969
22976
|
return anthropic2(modelId);
|
|
22970
22977
|
case "google":
|
|
22971
22978
|
const google2 = createGoogleGenerativeAI({
|
|
22972
22979
|
apiKey,
|
|
22973
|
-
...baseURL && { baseURL }
|
|
22980
|
+
...baseURL && { baseURL },
|
|
22981
|
+
...extraHeaders && { headers: extraHeaders }
|
|
22974
22982
|
});
|
|
22975
22983
|
return google2(modelId);
|
|
22976
22984
|
case "openai":
|
|
22977
22985
|
const openai2 = createOpenAI({
|
|
22978
22986
|
apiKey,
|
|
22979
|
-
...baseURL && { baseURL }
|
|
22987
|
+
...baseURL && { baseURL },
|
|
22988
|
+
...extraHeaders && { headers: extraHeaders }
|
|
22980
22989
|
});
|
|
22981
22990
|
return openai2(modelId);
|
|
22982
22991
|
case "openrouter":
|
|
22983
22992
|
const openrouter = (0, import_ai_sdk_provider.createOpenRouter)({
|
|
22984
22993
|
apiKey,
|
|
22985
|
-
...baseURL && { baseURL }
|
|
22994
|
+
...baseURL && { baseURL },
|
|
22995
|
+
...extraHeaders && { headers: extraHeaders }
|
|
22986
22996
|
});
|
|
22987
22997
|
return openrouter(modelId);
|
|
22988
22998
|
// case "claude_code":
|