Hi,
I’m using gemini-3-flash-preview with the REST API and trying to enable URL Context.
I tested both:
-
“tools”: [{“url_context”:{}}] (snake_case, per docs https://ai.google.dev/gemini-api/docs/url-context?)
-
“tools”: [{“urlContext”:{}}] (camelCase, as in the code generated by AI Studio)
MODEL_ID="gemini-3-flash-preview"
curl "https://generativelanguage.googleapis.com/v1beta/models/${MODEL_ID}:generateContent" \
-H "x-goog-api-key: ${GEMINI_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"contents":[{"parts":[{"text":"Summarize the main article at https://www.sciencedaily.com/releases/2024/06/240610171001.htm in 2 sentences."}]}],
"tools":[{"url_context":{}}]
}'
Problem:
-
url_context_metadata is always {}
-
No url_retrieval_status
-
Output is completely hallucinated and unrelated to the URL
However, the same URL works correctly in Google AI Studio.
Questions:
-
What does AI Studio do differently?
-
Is it using a different endpoint or model version?
-
Is additional configuration required for REST?
-
How can I reliably verify that URL retrieval actually happened?
Any help appreciated.