Url_context via REST API not working (hallucinated output, empty metadata) but works in AI Studio

Hi,

I’m using gemini-3-flash-preview with the REST API and trying to enable URL Context.

I tested both:

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.