Context URL Supported on Gemini Pro 3 Preview?

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

No one? Maybe it just me? Anyone have any examples?

Could the URLs you are generating potentially conflict with any of the Context URL limitations outlined in the documentation?

They are direct links to PDFs, or simple text/html pages without paywalls. I’ve also tried just a single, simple (but relevant to the other context) page containing text/html content with no luck.

Simplified repro here:


package main

import (
	"context"
	"encoding/json"
	"flag"
	"fmt"
	"log"

	"google.golang.org/genai"
)

var (
	modelName    = flag.String("model", "gemini-3-pro-preview", "Gemini model to use for analysis (e.g., 'gemini-2.5-flash', 'gemini-3-pro-preview')")
	geminiAPIKey = flag.String("gemini-key", "", "Gemini API Key for generating AI summaries")
)

type AIAnalysis struct {
	Summary     string   `json:"summary"`
	Ingredients []string `json:"ingredients"`
}

func main() {
	flag.Parse()

	if *geminiAPIKey == "" {
		log.Fatal("gemini API key is required")
	}

	ctx := context.Background()
	client, err := genai.NewClient(ctx, &genai.ClientConfig{
		APIKey:  *geminiAPIKey,
		Backend: genai.BackendGeminiAPI,
	})
	if err != nil {
		log.Fatalf("failed to create gemini client: %s", err)
	}

	recipeURL := "https://downshiftology.com/recipes/shakshuka"

	contents := genai.Text(
		fmt.Sprintf("Analyze the receipt at %s and provide a summary and a list of ingredients.", recipeURL),
	)

	tools := []*genai.Tool{
		{
			URLContext:   &genai.URLContext{},
			GoogleSearch: &genai.GoogleSearch{},
		},
	}

	resp, err := client.Models.GenerateContent(ctx, *modelName, contents, &genai.GenerateContentConfig{
		ResponseMIMEType: "application/json",
		ResponseSchema:   getResponseSchema(),
		Tools:            tools,
	})
	if err != nil {
		log.Fatalf("gemini API call failed: %s", err)
	}

	respText := resp.Text()

	var analysis AIAnalysis
	if err := json.Unmarshal([]byte(respText), &analysis); err != nil {
		log.Fatalf("failed to unmarshal gemini JSON response: %s. Raw text: %s", err, respText)
	}

	fmt.Printf("Summary: %s\nIngredients: %v\n", analysis.Summary, analysis.Ingredients)
}

func getResponseSchema() *genai.Schema {
	schema := &genai.Schema{
		Type: genai.TypeObject,
		Properties: map[string]*genai.Schema{
			"summary":     {Type: genai.TypeString},
			"ingredients": {Type: genai.TypeArray, Items: &genai.Schema{Type: genai.TypeString}},
		},
	}

	return schema
}