feat: 支持用环境变量配 provider baseURL(所有 provider 通用)
resolveSDK 在 config 未设 baseURL 时,回退读环境变量: 专属 <PROVIDER>_BASE_URL(如 OPENAI_BASE_URL/ANTHROPIC_BASE_URL) > 通用 ZMO_BASE_URL。env.all() 含 process.env,用户设系统环境变量即可。 优先级:config options.baseURL > 专属env > 通用 ZMO_BASE_URL > 官方默认。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1540,6 +1540,17 @@ export const layer = Layer.effect(
|
||||
const provider = s.providers[model.providerID]
|
||||
const options = { ...provider.options }
|
||||
|
||||
// zmo: 支持用环境变量配 baseURL(所有 provider 通用)。
|
||||
// 优先级:config options.baseURL > 专属 <PROVIDER>_BASE_URL > 通用 ZMO_BASE_URL。
|
||||
// 仅当 config 未显式设置 baseURL 时才用环境变量回退。
|
||||
if (typeof options["baseURL"] !== "string" || options["baseURL"] === "") {
|
||||
const envName = model.providerID.toUpperCase().replace(/-/g, "_") + "_BASE_URL"
|
||||
const envBaseURL = envs[envName] ?? envs["ZMO_BASE_URL"]
|
||||
if (typeof envBaseURL === "string" && envBaseURL !== "") {
|
||||
options["baseURL"] = envBaseURL
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
model.providerID === "google-vertex" &&
|
||||
model.api.npm === "@ai-sdk/google-vertex/anthropic" &&
|
||||
|
||||
Reference in New Issue
Block a user