Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/edge-bundler/node/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,25 @@ To install Deno manually: https://ntl.fyi/install-deno`,
// Ensure PATH is always set as otherwise we are not able to find the global deno binary
env[pathKey()] = inputEnv[pathKey({ env: inputEnv })] || process.env[pathKey()]

// Inject placeholder AI Gateway env vars for bundling to prevent SDK initialization errors
// These allow SDKs to be initialized at top-level during bundling without throwing
// Real AI Gateway credentials will be injected at runtime by the platform
const aiGatewayProviders = [
{ key: 'OPENAI_API_KEY', url: 'OPENAI_BASE_URL' },
{ key: 'ANTHROPIC_API_KEY', url: 'ANTHROPIC_BASE_URL' },
{ key: 'GEMINI_API_KEY', url: 'GOOGLE_GEMINI_BASE_URL' },
]

for (const { key, url } of aiGatewayProviders) {
// Only inject if user hasn't set their own values
if (!env[key]) {
env[key] = 'placeholder-for-bundling'
}
if (!env[url]) {
env[url] = 'http://localhost/.netlify/ai'
}
}

return env
}

Expand Down
Loading