from google import genai client = genai.Client( api_key='API_KEY', http_options={ 'api_version': 'v1alpha', }) stream = client.models.generate_content_stream( model='gemini-2.0-flash-thinking-exp-1219', contents=f"""What is 2*2-1*4^4""" ) thinking = True print("****** Start thinking... ******") for chunk in stream: for candidate in chunk.candidates: for part in candidate.content.parts: if part.thought: is_thinking = True elif is_thinking: # prints "Finished thinking" when transitioning from thinking to not thinking is_thinking = False print("\n") print("****** Finished thinking... ******") print("\n") print(part.text, end="", flush=True)