Hint

🧠 Not sure how to get started building an app like this?

Break it into small steps:

  1. Load your API key securely
    Use the python-dotenv library to load your Gemini API key from a .env file.
    In your code:

from dotenv import load_dotenv
import os
load_dotenv()
  1. Now you can access your key with:

api_key = os.getenv("GEMINI_API_KEY")
  1. Configure the Gemini client
    Use:

import google.generativeai as genai
genai.configure(api_key=api_key)
  1. Set up the model
    Pick gemini-1.5-flash-latest for quick responses:

model = genai.GenerativeModel("gemini-1.5-flash-latest")
  1. Shape the assistant’s behavior
    Instead of just sending the user question, prepend a system-style instruction like:

You are a travel assistant. You give travel advice for out of the beaten path places, not the mainstream destinations.
  1. Run a loop
    Use a while True loop to keep taking user input, and call model.generate_content(...) to get the AI’s response.


✅ Click Show Solution on the project page to see exactly how all these pieces fit together into a friendly travel assistant app.