Use the
generateContent method
to send a request to the Gemini API.
fromgoogleimportgenaiclient=genai.Client(api_key="YOUR_API_KEY")response=client.models.generate_content(model="gemini-2.0-flash",contents="Explain how AI works")print(response.text)
What's next
Now that you made your first API request, you might want to explore the following
guides which showcase Gemini in action:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-05 UTC."],[],[]]