Hint

Not sure how to start building this travel assistant with a Gradio web interface?

Break it down step by step:

  1. Load your API key securely
    Use dotenv so your key isn’t exposed in your code. In your script:

from dotenv import load_dotenv
import os
load_dotenv()
  1. Then pull it with:

api_key = os.getenv("GEMINI_API_KEY")
  1. Configure the Gemini client
    So it knows which key to use:

import google.generativeai as genai
genai.configure(api_key=api_key)
  1. Create the model
    Use a lightweight, responsive model for your app:

model = genai.GenerativeModel("gemini-1.5-flash-latest")
  1. Build the function that answers travel questions
    Make sure to combine your system prompt with the user’s question to guide the AI to recommend hidden gems:

system_message = "You are a travel assistant. You give advice for out of the beaten path places."

def travel_advice(user_input):
    response = model.generate_content([
        {"role": "user", "parts": [f"{system_message}\n\n{user_input}"]}
    ])
    return response.text.strip()
  1. Wrap it in a Gradio interface
    So you have a simple web app:

import gradio as gr
iface = gr.Interface(
    fn=travel_advice,
    inputs="text",
    outputs="markdown",
    title="✈️ Hidden Gems Travel Assistant",
    description="Get advice on lesser-known travel destinations."
)
iface.launch()

✅ That’s all there is to it. Click Show Solution on the project page to see the complete program, perfectly tied together.