Gemini API Issue

I’m trying out the Gemini API. I took a first look at it in Google Colab using the following code, but when I try to run it in Visual Studio (Python 3.12.6), the process never finishes

import google.generativeai as genai

genai.configure(api_key = ‘MY API’)

model = genai.GenerativeModel(“gemini-1.5-flash”)

response = model.generate_content(“Write a story about a magic backpack.”)

print(response.text)

@fer_fog

With the same Python version, I tried it in Visual Studio and it worked.
Try adding error handling to your code to catch any exceptions that might occur.