Independent API referenceField notes updated 29 Aug 2026

Gemini API field note

Gemini API key not valid: environment, restriction, and endpoint checks

Debug Gemini API API_KEY_INVALID and invalid key errors across AI Studio keys, project restrictions, environment variables, and endpoint versions.

API_KEY_INVALIDAPI key not validINVALID_ARGUMENTGoogle AI Studio key

Reviewed Source: Gemini API troubleshooting

An invalid-key response is usually resolved before changing prompts or models. Confirm the key source, active Google Cloud project, API restrictions, environment-variable interpolation, and that the request is going to the Gemini API endpoint expected by the selected SDK.

Treat the complete response as an evidence record: status, headers, provider code, request identifier, method, and raw body. The sequence below separates what the response proves from the checks still needed before a safe retry or code change.

Diagnostic procedure

Work from evidence to recovery.

  1. 01

    Confirm the literal credential

    Check for quotes, whitespace, placeholder text, a missing environment variable, or a key copied from the wrong project.

  2. 02

    Inspect key restrictions

    Application and API restrictions can reject a real key when host, IP, referrer, or API scope does not match.

  3. 03

    Match SDK and endpoint

    Verify the SDK generation, API version, model name, and whether the integration expects Google AI Studio or Vertex AI credentials.

Before
x-goog-api-key: ${GEMINI_API_KEY}  // unresolved placeholder
Target-safe shape
Resolve secret at runtime → verify project/API restrictions → call matching endpoint

Interactive check

Test the evidence locally.

Use the related workbench to reproduce the decision with your own response, headers, method, or retry policy. Pasted values remain in the active browser tab.

01 / Evidence
02 / TriageUnidentified provider
429HTTP status
Limitsfailure layer
6headers read

Evidence

HTTP 429: A rate, quota, concurrency, or resource lock limit blocked the request.

Retry-After is present; it should take precedence over a guessed delay.

The reported request window has no remaining capacity.

Next checks

01Parse Retry-After as either delta-seconds or an HTTP date before scheduling the next attempt.

No account · no upload · no endpoint calledOpen the full incident decoder and operating notes →

FAQ

Before you ship

Does APITC send this evidence to an API?

No. The matching and calculations in the linked workbench run in the active browser tab.

Should every Gemini authentication response be retried?

No. Retry behavior depends on the method, idempotency protection, provider instructions, and whether the failure is temporary.

Protocol behavior checked against the Gemini API troubleshooting. Recheck your pinned provider/API version before production deployment.