Gemini API fetch failed
Gemini API Fetch Failed: Network, CORS, or Endpoint Issue
TL;DR: Gemini fetch failed is usually a client/runtime transport error, not a Gemini model error. The request often fails before a useful Gemini API response body exists.
What this error means
Gemini API fetch failed usually means your runtime could not complete the HTTP request because of network, CORS, DNS, endpoint, or key placement problems.
client_runtime network path
Is it code, key, rate limit, or server-side?
| Signal | Diagnosis |
|---|---|
| Provider | Google Gemini |
| Error | fetch-failed |
| Likely category | client_runtime |
| Likely fault area | network path |
Immediate checklist
- Confirm whether the error comes from browser fetch, Node fetch, Vercel, Cloudflare Workers, or another runtime.
- Check that the endpoint path includes the model and method, such as :generateContent.
- Do not expose a Gemini API key in frontend JavaScript just to work around CORS.
- Run a server-side curl test from the deployment environment if local curl works.
cURL test command
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=$GEMINI_API_KEY" \
-H "content-type: application/json" \
-d '{"contents":[{"parts":[{"text":"ping"}]}]}' Run this from your server or terminal. llmping does not collect API keys and does not send this command for you.
Common fixes
- Move API calls to your server or edge function if the browser blocks the request.
- Verify the exact Gemini endpoint and model string.
- Check DNS/proxy/firewall settings in the runtime where the error happens.
- Log HTTP status and response text when available; fetch failed alone is too generic.