Skip to content

1.0.10 — Proxy support for Gemini API requests

Choose a tag to compare

@tobrien tobrien released this 04 Mar 16:00
· 10 commits to working since this release
524de28

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_proxy
    • HTTP_PROXY / http_proxy
  • Routes requests through the proxy using undici’s ProxyAgent.
  • 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-ai SDK does not expose a way to provide a custom fetch, so this package temporarily replaces globalThis.fetch only 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.fetch should be aware that it will be temporarily overridden during Gemini requests when a proxy is enabled.

Versioning / packaging

  • package.json version 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.fetch is 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 (or HTTP_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