Quickstart Guide
Get started with Gemini 3 in just a few minutes
1
Get Your API Key
- Visit Google AI Studio (https://ai.google.dev/?hl=en)
- Sign in with your Google account
- Navigate to API keys section
- Create a new API key
- Save it securely - you'll need it for all API calls
2
Choose Your Model
gemini-3-pro-image-preview
Best for professional assets, supports up to 4K resolution, Google Search grounding, and advanced reasoning
gemini-2.5-flash-image
Optimized for speed, perfect for prototyping and quick iterations
3
Run Your First Text-to-Image Request
Run Your First Text-to-Image Request
from google import genai
from PIL import Image
client = genai.Client()
prompt = "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme"
response = client.models.generate_content(
model="gemini-2.5-flash-image",
contents=[prompt],
)
for part in response.parts:
if part.text is not None:
print(part.text)
elif part.inline_data is not None:
image = part.as_image()
image.save("generated_image.png")