Get a Gemini API key and make your first API request in minutes.
Python
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)
Node.js
const{GoogleGenerativeAI}=require("@google/generative-ai");constgenAI=newGoogleGenerativeAI("YOUR_API_KEY");constmodel=genAI.getGenerativeModel({model:"gemini-2.0-flash"});constprompt="Explain how AI works";constresult=awaitmodel.generateContent(prompt);console.log(result.response.text());
REST
curl"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=YOUR_API_KEY"\
-H'Content-Type: application/json'\
-XPOST\
-d'{ "contents": [{ "parts":[{"text": "Explain how AI works"}] }] }'
[[["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-03-17 UTC."],[],[]]