Google's Gemini models are fast, capable and have a free tier for development, which makes them a good first model for an in-app assistant. This guide gets a key, keeps it safe, and calls Gemini from FastAPI, including letting the model call your own Python functions.
1. Create the key in Google AI Studio
Go to aistudio.google.com/apikey and sign in with a Google account.
Click Create API key . New accounts get a default Google Cloud project; if you already use Google Cloud, choose Import projects and pick the project that should own the key and its billing.
Copy the key into your server's environment:
GEMINI_API_KEY=...
Enter fullscreen mode
Exit fullscreen mode
Every key belongs to a Google Cloud project, which is where billing, quotas and limits live. Before you launch, read Google's current free-tier limits and data-use terms: Google has treated free-tier and paid-tier prompts differently, so turn on billing before real users' data goes through it.
2.…