Repository navigation
1.0.10 — Proxy support for Gemini API requests
Main changes
Proxy support for Gemini API requests
Gemini API calls can now be routed through an HTTP(S) proxy when proxy environment variables are set. This is primarily for environments where outbound traffic must go through a corporate proxy.
What it does
- Detects proxy configuration from standard environment variables:
HTTPS_PROXY/https_proxyHTTP_PROXY/http_proxy
- Routes requests through the proxy using
undici’sProxyAgent. - Respects proxy bypass lists via:
NO_PROXY/no_proxy(comma-separated, supports*, exact host matches, and domain suffix matches like.example.com)
- Respects TLS verification configuration via:
NODE_TLS_REJECT_UNAUTHORIZED- TLS verification is only disabled when
NODE_TLS_REJECT_UNAUTHORIZED='0'; otherwise TLS verification remains enabled.
Important implementation detail
- The
@google/generative-aiSDK does not expose a way to provide a customfetch, so this package temporarily replacesglobalThis.fetchonly for the duration of the Gemini call when a proxy is configured. - If no proxy environment variable is set, behavior is unchanged (no fetch override).
Impact
- Users behind proxies can use the provider without custom networking workarounds.
- Users who rely on a custom
globalThis.fetchshould be aware that it will be temporarily overridden during Gemini requests when a proxy is enabled.
Versioning / packaging
package.jsonversion bumped to 1.0.10.
Breaking changes
- No explicit breaking changes were detected in the diff.
- Operational note (behavioral consideration): when proxying is enabled,
globalThis.fetchis temporarily replaced during request execution. If your application depends on a customized global fetch implementation, validate behavior in your environment.
How to use
Set environment variables before running:
- Proxy routing:
HTTPS_PROXY=http://proxy.company:8080(orHTTP_PROXY=...)
- Bypass proxy for certain hosts:
NO_PROXY=localhost,127.0.0.1,.internal.company
- (Optional) disable TLS verification (not recommended except for controlled debugging):
NODE_TLS_REJECT_UNAUTHORIZED=0