I tried to use URL context in both aistudio and code, but I keep getting
“I am sorry, but I am unable to browse the provided URL.”
I provide a public link, selected URL context in aistudio and provide the right code.
Hi @PaoloB , Welcome to the forum.
I just tested it using a public url, and it worked fine on my end. It is possible that the link you are using might be private, behind a login, or restricted in some way.
Would you mind sharing the URL you are trying to use?
Hi @GUNAND_MAYANGLAMBAM,
thanks for the reply. First I used a page hosted on cloudflare, but then picked any random page to make sure that was not the issue. Here is a CNN article. I even tried curl directly as in my code it didn’t work. I guess I’m doing something wrong, but the error message is not helpful (Note: I redacted some links as I’m prevented to post more than 2 per post here)
curl -X POST
-H “x-goog-api-key: GOOGLE_KEY”
-H “Content-Type: application/json”
-d ‘{
“model”:“gemini-2.5-flash”,
“contents”:[{“parts”:[{“text”:“Read cnn travel/canadian-food-best-dishes and give me a two-sentence summary.”}]}],
“tools”:[{ “url_context”: {} }]
}’
“https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent”
I get the following:
{
“candidates”: [
{
“content”: {
“parts”: [
{
“text”: “I apologize, but I was unable to access the content of the CNN article to provide a summary. The website may have a paywall, require a login, or contain sensitive information, preventing me from accessing it.”
}
],
“role”: “model”
},
“finishReason”: “STOP”,
“index”: 0,
“groundingMetadata”: {},
“urlContextMetadata”: {
“urlMetadata”: [
{
“retrievedUrl”: “REDACTED”,
“urlRetrievalStatus”: “URL_RETRIEVAL_STATUS_ERROR”
}
]
}
}
],
“usageMetadata”: {
“promptTokenCount”: 29,
“candidatesTokenCount”: 69,
“totalTokenCount”: 166,
“promptTokensDetails”: [
{
“modality”: “TEXT”,
“tokenCount”: 29
}
],
“toolUsePromptTokenCount”: 33,
“thoughtsTokenCount”: 35
},
“modelVersion”: “gemini-2.5-flash”,
“responseId”: “aQ1kaOfkB8_Uz7IP_ufCqQo”
}
The CNN site uses a metered paywall, which likely blocked your request. Try testing with a fully open site like wikipedia, it should work without issues.
the article is not behind paywall itself, but if you say “metered” you mean that it’s blocked if many requests?
Anyway, I tried also raw pastebin “Modified by moderator” or even public github documentation that should not have this problem and didn’t work.
It worked for wikipedia, for some github page, but it’s hit or miss. I even created a public github page myself and it said not accessible