DV

davidkk/vercel-gemini-proxy

Developer tools

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

16 stars Качество 85 Тренд 41MIT

Gemini API proxy on Vercel Edge.

Обзор

is a Gemini API proxy on Vercel (Next.js App Router) for regions where direct Gemini access is slow or blocked, plus a browser streaming playground for debugging. gemini-relay-proxy.vercel.app/chat (demo only) - Prefer DNS in a region that can reach Google Gemini. Do not rely on *.vercel.app in production. If needed, front the service with a jump host or another edge proxy (e.g. CF). - Use Gemini API key. Do not share or reuse others’ keys. - Multiturn messages must end with role: user (or a function response). If the first message is not user, the proxy drops it; if the last is not user, the request is rejected. - Auth paths: /api/v1, /api/v1beta, /api/v1beta2 only. - ?key= or x-goog-api-key with your Gemini key. - headers from PROXY_AUTH_HEADERS; server injects a key from GEMINI_API_KEYS. - Missing credential/path → 401. Proxy mode without GEMINI_API_KEYS → 503. Empty JSON body on POST/PUT/PATCH → 403 (GET needs no body). - Runs on Next.

README

Показан фрагмент оригинального README. Открыть оригинал.

Gemini Relay

Gemini Relay is a Gemini API proxy on Vercel (Next.js App Router) for regions where direct Gemini access is slow or blocked, plus a browser streaming playground for debugging.

Try it: gemini-relay-proxy.vercel.app/chat (demo only)

Important notes

  • Custom domain required for production. Prefer DNS in a region that can reach Google Gemini. Do not rely on *.vercel.app in production. If needed, front the service with a jump host or another edge proxy (e.g. CF).
  • Use your own Gemini API key. Do not share or reuse others’ keys.
  • Multiturn messages must end with role: user (or a function response). If the first message is not user, the proxy drops it; if the last is not user, the request is rejected.
  • Auth paths: /api/v1, /api/v1beta, /api/v1beta2 only.
    • Passthrough: ?key= or x-goog-api-key with your Gemini key.
    • Proxy mode: headers from PROXY_AUTH_HEADERS; server injects a key from GEMINI_API_KEYS.
    • Missing credential/path → 401. Proxy mode without GEMINI_API_KEYS → 503. Empty JSON body on POST/PUT/PATCH → 403 (GET needs no body).
  • Runs on Next.js App Router Route Handlers (nodejs + Fluid Compute): app/api/v1|v1beta|v1beta2/[...path] → services/gemini/. Successful calls return 200 then stream. maxDuration and business timeout are 120s.
  • Model IDs live in the URL (transparent forward), e.g. /api/v1beta/models/{model}:generateContent. Prefer current Stable: gemini-3.5-flash (general) or gemini-3.5-flash-lite (lighter). Playground can Refresh the official model list.
  • Debug via Vercel → Logs (or local pnpm dev terminal). Playground / MCP are for debugging; generation still goes through the REST proxy.

Deploy

  1. Clone / import the repo and deploy.
  2. Attach a custom domain.
Открыть полный README на GitHub

Рекомендуемые инструменты

Попробуйте другой запрос или уберите фильтр.

Установка

npx skillfish add davidkk/vercel-gemini-proxy
Новичок в MCP? Начните с руководства на mcpskill.org →