Use the
generateContent method
to send a request to the Gemini API.
importgoogle.generativeaiasgenaigenai.configure(api_key="YOUR_API_KEY")model=genai.GenerativeModel("gemini-1.5-flash")response=model.generate_content("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 2024-12-11 UTC."],[],[]]