Friction: this note describes roadblocks while refining testing methodology
Google AI Studio API key
Process for getting a Google AI Studio/Gemini API key was more straightforward than the
for the Claude API. The Gemini API URL context docs includes a tools bar on the top
right of the page with a Get API key section.
Instructions:
- Go to aistudio.google.com → sign in
- Click
Get API key→Create API key - Copy the key → add it to your
.envfile - Run
source .env - Run
python gemini-url-context/url_context_test_raw.py
API not available on the free tier - Raw Track
The free tier imposes two hard limits that make reliable test suite runs impossible without a paid account:
- Per-minute:
GenerateRequestsPerMinutePerProjectPerModel-FreeTier, limit: 5 - Per-day:
GenerateRequestsPerDayPerProjectPerModel-FreeTier, limit: 20
The 8-test suite requires a minimum of 8 requests per run with no headroom for
retries. The daily cap was exhausted across three partial runs; tests 3–8
returned 429 RESOURCE_EXHAUSTED on the final run. A paid-tier is required
to complete the suite reliably in a single run, otherwise you’ll see:
429 RESOURCE_EXHAUSTED: Quota exceeded for metric:
generativelanguage.googleapis.com/generate_content_free_tier_requests,
limit: 20, model: gemini-2.5-flash. Please retry in Xs.
Raw Track Roadblocks
-
candidate.content.partsisNone, test_5_multi_url_21 - with candidate guard, Gemini still raisesNoneType object is not iterable- candidate exists but isNone- error originates insideextract_textandextract_url_metadataFix: guard both helpers against
Nonecontent before iterating -
max_output_tokensceiling interferes with multi-URL metadata,test_3_multi_url_5,test_4_multi_url_20-max_output_tokens=128causedtest_3to returnFinishReason.MAX_TOKENSwith zerourl_metadataentries; initially appeared in r1 as a silent metadata gap ontest_4: 4,233 tool tokens firing buturl_metadata: [], no error; was the same root cause: response truncated before metadata populatedFix: raising to 512 resolved
test_3;test_4hit the ceiling at r4 (FinishReason.MAX_TOKENS, 111,326 tool tokens); raising to 1,024 resolved both -
Missing candidates guard,
test_3_multi_url_5,test_5_multi_url_21- when Gemini hits an internal tool call budget, it returnsresponse.candidates = Nonerather than a structured error; SDK emitsUserWarning: TOO_MANY_TOOL_CALLS isn't a valid FinishReason, but the response object isn’t usable; script crashed atresponse.candidates[0]because no guard was in placeFix: check
if not response.candidatesbefore accessing the candidate, raise aValueErrorwith the prompt feedback, recordfinish_reasonin all result branches -
test_8_json_contentinconsistent retrieval status across runs - GitHub API endpoint succeeded in r1 and r2:URL_RETRIEVAL_STATUS_SUCCESS, ~2,490 tool tokens, but returnedURL_RETRIEVAL_STATUS_ERRORin r4, 116 tool tokens; the near-zero token count on the failed run suggests the retriever received an empty or rejected response, likely GitHub API rate limiting or auth requirements on unauthenticated requestsFix: result is non-deterministic; treat as unreliable for the raw track
-
Transient
503 UNAVAILABLE,test_4_multi_url_20, r2 - Gemini returned a503on the 20-URL test, citing high demand: infrastructure-level noise, not a behavioral finding; error is caught and recorded correctlyFix: re-run required to get a clean result for this test case