
The Gemini API is Google’s gateway to the most capable AI models available today. Whether you’re building a chatbot, analyzing images, generating code, or creating AI agents, the Gemini API gives you programmatic access to the same models that power Google’s AI products.
This tutorial walks you through everything from getting your first API key to building a multimodal application — with practical code examples you can use today.
Getting Your Gemini API Key
The fastest path to a Gemini API key:
- Go to Google AI Studio
- Sign in with your Google account
- Click “Get API Key” in the left sidebar
- Create a new key or use an existing Google Cloud project
- Copy your key — you’ll need it for every API call
The free tier gives you generous rate limits for development and prototyping. For production applications, you can upgrade through Google Cloud.
Your First Gemini API Call
Here’s a simple text generation call using Python:
import google.generativeai as genai
genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel("gemini-pro")
response = model.generate_content("Explain quantum computing in simple terms")
print(response.text)
That’s it — three lines of code to access one of the most powerful AI models in the world.
Multimodal: Text + Images
Gemini’s multimodal capabilities let you send images alongside text:
import PIL.Image
model = genai.GenerativeModel("gemini-pro-vision")
image = PIL.Image.open("receipt.jpg")
response = model.generate_content([
"Extract the total amount, date, and vendor from this receipt. Return as JSON.",
image
])
print(response.text)
This is the foundation for applications like receipt scanners, document analyzers, medical image analysis, and accessibility tools — all ideas that have won prizes at hackathons on Reskilll.
Building a Chatbot with Conversation History
model = genai.GenerativeModel("gemini-pro")
chat = model.start_chat(history=[])
response = chat.send_message("I'm building a hackathon project. Can you help?")
print(response.text)
response = chat.send_message("It should use AI to help farmers detect crop diseases")
print(response.text)
# The model remembers the full conversation context
Structured Output with JSON
For applications that need parseable responses:
model = genai.GenerativeModel("gemini-pro",
generation_config={"response_mime_type": "application/json"})
response = model.generate_content(
"List 5 hackathon project ideas with title, difficulty, and tech stack"
)
import json
ideas = json.loads(response.text)
for idea in ideas:
print(f"{idea['title']} - {idea['difficulty']}")
System Instructions
Set persistent context that shapes all model responses:
model = genai.GenerativeModel("gemini-pro",
system_instruction="You are a hackathon mentor. Give practical, actionable advice. Keep responses concise. Focus on what can be built in 24 hours.")
response = model.generate_content("How should we approach building an AI study buddy?")
print(response.text)
What to Build Next
With the Gemini API, you can build any of the projects from our 15 AI Hackathon Ideas guide. The API is free to start, the documentation is excellent, and the community is growing fast.
For hands-on learning, join a Build With AI bootcamp where you’ll build a complete Gemini-powered application in a single day. Or jump into a hackathon on Reskilll and build something real under time pressure — the best way to learn any API.
This Gemini API tutorial is exactly what I needed. The multimodal example with receipt scanning gave me an idea for my next hackathon project. Clean and practical.
The structured JSON output feature is a lifesaver for building real applications. No more parsing messy AI responses. Thanks for the clear examples.