Skip to content

Documentation is missing for Search Grounding with DynamicRetrievalConfig in the new SDK. #686

@marcsitelabs

Description

@marcsitelabs

Description of the bug:

I've been checking the docs for the new SDK, and in the Search Grounding section, I saw this:

Before

import google.generativeai as genai

model = genai.GenerativeModel('gemini-1.5-flash')
response = model.generate_content(
    contents="what is the Google stock price?",
    tools='google_search_retrieval'
)

After

from google import genai
from google.genai import types
client = genai.Client()

response = client.models.generate_content(
    model='gemini-2.0-flash',
    contents='What is the Google stock price?',
    config=types.GenerateContentConfig(
        tools=[
            types.Tool(
                google_search=types.GoogleSearch()
            )
        ]
    )
)

However, the example does not explain how to use dynamic retrieval (DynamicRetrievalConfig).

I found this example in the yet-to-be-updated Gemini API Docs, but it clearly follows the old SDK structure.

from google import genai
from google.genai import types

client = genai.Client(api_key="GEMINI_API_KEY")

response = client.models.generate_content(
    model='gemini-2.0-flash',
    contents="Who won Wimbledon this year?",
    config=types.GenerateContentConfig(
        tools=[types.Tool(
            google_search=types.GoogleSearchRetrieval(
                dynamic_retrieval_config=types.DynamicRetrievalConfig(
                    dynamic_threshold=0.6))
        )]
    )
)
print(response)

Is it possible to include an example of how to use DynamicRetrievalConfig within the new SDK?

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions