Can I use both web search and code execution tool?

tried the following

    client = genai.Client(api_key=api_key)

    response = await client.aio.models.generate_content(
        model='gemini-2.0-flash',
        contents="What's the sum of first 50 primes?",
        config=types.GenerateContentConfig(
            tools=[
                types.Tool(google_search=types.GoogleSearch()),
                types.Tool(code_execution=types.ToolCodeExecution()),
            ]
        ),
    )

but get error

google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Code execution and search tool is not supported.', 'status': 'INVALID_ARGUMENT'}}

actually, seems can work with gemini-2.5-flash . maybe not working with 2.0-flash?

Hi @Peter_Xie,

Welcome to the Forum,

You cannot use both Google Search and Code Execution tools simultaneously in a single generate_content call with gemini-2.0-flash model. You need to choose one or the other for a single generate_content call or implement a multi-turn approach.

Thank you!