Skip to main content

Gemini Web2API - Netlify Deployment Documentation

Run Gemini Web2API on Netlify Edge Functions for SSE streaming and no server maintenance.

Quick Deploy

Option 1: 1-Click Deploy to Netlify

Deploy to Netlify
  1. Click the Deploy to Netlify button above.
  2. Connect your GitHub account and choose a repository name.
  3. (Optional) In Environment Variables, configure API_KEY or COOKIE_STRING.
  4. Click Deploy. Your API is live within a minute at https://your-app-name.netlify.app.

Option 2: Connect via Netlify Dashboard (Git)

  1. Fork or push this repository to your GitHub account.
  2. Open the Netlify Dashboard.
  3. Click Add new site → Import an existing project.
  4. Select GitHub and authorize access to your repository.
  5. In the build settings:
    • Base directory: (leave blank)
    • Build command: (leave blank)
    • Publish directory: (leave blank)
  6. Click Deploy site.
  7. Netlify will automatically detect netlify.toml and configure the edge function at /*.

Environment Variables (Optional)

Configure these in Netlify: Site configuration → Environment variables → Add a variable.
Proxy support on Netlify: Netlify Edge Functions do not provide raw TCP sockets (Deno.connect / cloudflare:sockets), so the rotating proxy pool (ENABLE_PROXY/PROXY_ENABLED) is not supported on Netlify and is ignored with a WARN in the logs. To route traffic through a proxy on Netlify, set HTTPS_PROXY instead — this is the same native Deno tunneling the Deno Deploy deployment gets, and it works out of the box because Edge Functions run on Deno. Check /health after setting HTTPS_PROXY: proxy.mode should flip from direct to outbound and proxy.enabled to true (the proxy URL value itself is never reported). If it still says direct, the two usual causes are:
  1. Scope: the environment variable’s scope must include Functions (Netlify Dashboard → Site configuration → Environment variables → the variable’s scope checkboxes), otherwise Edge Functions never see it at runtime.
  2. Redeploy: environment variables are injected at deploy time — trigger a redeploy after adding/changing HTTPS_PROXY.
Node.js runtime caveat: the above applies to Edge Functions (netlify/edge-functions/, Deno). The classic Netlify Functions runtime (netlify/functions/, Node.js) does not auto-tunnel fetch() through HTTPS_PROXY — on Node 18+ you’d need a custom dispatcher (e.g. undici.ProxyAgent). This repo’s Netlify deployment uses the Edge function at /*, so HTTPS_PROXY works as described.
Tip for Multiple Cookies: You can rotate between multiple Google accounts by separating cookies with a pipe character (|), e.g. cookie_account_1| cookie_account_2.

Verification

Once deployed, check your health endpoint in your browser or with curl:
Expected response:
The proxy block reflects the actual outbound mode: direct (default), outbound (static HTTPS_PROXY in effect), or pool (rotating proxy pool — Cloudflare Workers and Deno Deploy only). Note that poolSupported is always false on Netlify Edge, so ENABLE_PROXY=true alone can never switch the mode to pool here; use HTTPS_PROXY to get "mode": "outbound" — that’s the supported way to proxy upstream traffic on Netlify.

Client Configuration

NextChat / ChatGPT-Next-Web

Cherry Studio / ChatBox

curl Test


Local Development

You can run and test the Netlify Edge Function locally using Netlify CLI:
The local edge server will start at http://localhost:8888.

Troubleshooting

Error - Request ID: 01M...

That page is Netlify’s generic error response. It shows up when the edge function crashes with an unhandled exception, or when it fails to send response headers within Netlify’s 40-second limit. The real error is in the dashboard under Logs → Edge Functions. Known causes and fixes: After any failure, the response body and the function logs now show the actual error message, so you no longer have to guess behind Error - Request ID.