Hi,
I’m attempting to try out the structured responses + context url features for gemini-3-pro-preview announced here: New Gemini API updates for Gemini 3 - Google Developers Blog
It says context url is supported, but when attempt to use it with the go sdk, the response only includes “groundingMetadata”.
Here’s how I’m using it (buildSystemInstruction(ticker) returns an instruction that tells the system to visit a set of 5 or so pages):
prompt := fmt.Sprintf("Analyze the following document text:\n\n---\n%s", text)
contents := genai.Text(prompt)
systemContent := &genai.Content{
Parts: []*genai.Part{
{Text: buildSystemInstruction(ticker)},
},
Role: "system",
}
tools := []*genai.Tool{
{
URLContext: &genai.URLContext{},
GoogleSearch: &genai.GoogleSearch{},
},
}
resp, err := client.Models.GenerateContent(ctx, modelName, contents, &genai.GenerateContentConfig{
SystemInstruction: systemContent,
ResponseMIMEType: "application/json",
ResponseSchema: getResponseSchema(),
Tools: tools,
})
if err != nil {
return nil, fmt.Errorf("gemini API call failed: %w", err)
}
fmt.Println(resp.Candidates[0].URLContextMetadata)
fmt.Println(resp.Candidates[0].GroundingMetadata)
If I look at the logs in Google AI Studio, the tool is clearly listed:
"tools": [
{
"googleSearch": {},
"urlContext": {}
}
]
But Candidates[0].URLContextMetadata is nil and the logs clearly show that it is not used, while “Search grounding” is since Candidates[0].GroundingMetadata has the data from the searches.
Is anyone else experiencing this issue?
Is it actually supported using this model? It’s not in the list here: https://ai.google.dev/gemini-api/docs/url-context#supported-models
Thanks,
Shane