Skip to content

Conversation

@kathmbeck
Copy link
Contributor

@kathmbeck kathmbeck commented Nov 20, 2025

Injects placeholder environment variables (OPENAI_API_KEY, OPENAI_BASE_URL, etc.) during bundling to enable top-level AI SDK initialization.

Without these placeholders, SDKs like OpenAI throw errors when initialized at top-level scope during local dev.

Tested with npm link to CLI in local dev and this site.
https://aig-bootstrap-test.netlifystg.app/

🎉 Thanks for submitting a pull request! 🎉

Summary

Fixes #<replace_with_issue_number>


For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures
    we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or
    something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures
    your code follows our style guide and passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)

kathmbeck and others added 2 commits November 20, 2025 17:17
Injects placeholder environment variables (OPENAI_API_KEY, OPENAI_BASE_URL, etc.)
during bundling to enable top-level AI SDK initialization.

During local 'netlify deploy', the bundler executes edge function code for:
1. Creating ESZIP bundles
2. Extracting function configs

Without these placeholders, SDKs like OpenAI throw errors when initialized at
top-level scope (e.g., 'const client = new OpenAI()').

Real AI Gateway credentials (JWT tokens + BASE_URLs) are injected at runtime
by Stargate (hosted) or Bootstrap (self-hosted).

Only injects if user hasn't set their own values, preserving user-defined keys.
@kathmbeck kathmbeck marked this pull request as ready for review November 20, 2025 23:05
@kathmbeck kathmbeck requested a review from a team as a code owner November 20, 2025 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants