Build a Daily Digest Assistant
Call the Gemini AI API from Python to build a terminal-based daily planner.
Introduction
30 Second Summary
Every morning starts with a jumble of tasks, meetings, and goals floating around your head. What if you could brain-dump all of it into your terminal and get back a structured, prioritized plan in seconds?
In this project, you will build a daily planning assistant powered by Google's Gemini AI. You'll write a Python script that takes your messy task list and transforms it into a time-blocked plan you can actually follow.
What You'll Build
A terminal-based conversational AI assistant that reorganizes your daily tasks into a prioritized, time-blocked schedule using the Gemini API.
By the end of this project, you'll have:
- A working Python script (daily_digest.py) that connects to a real AI API and produces structured output.
- A personalized system prompt that shapes the AI's behavior to match your schedule and preferences.
- An interactive chat loop that maintains conversation context across multiple messages.
- Secret Mission: Add date and time awareness and save your daily plan as a markdown file.
Are there any prerequisites?
You should be comfortable with basic Python concepts like variables, loops, and input()/print() statements. No AI or API experience is needed.
Before We Start
Before We Start...
Set Up Your Environment
Before you can build your AI assistant, you need a few things in place: the Python SDK that talks to Google's Gemini API, and an API key that authenticates your requests.
In this step, you will confirm your Python version, install the Google GenAI SDK, grab a free API key, and store it as an environment variable so your code can find it.
In this step, get ready to:
- Install the Google GenAI SDK and verify it works.
- Create a free Gemini API key in Google AI Studio.
- Set the API key as an environment variable in your terminal.
Install the Google GenAI SDK
- Press Cmd+Space (macOS) or the Windows key (Windows) to open your search bar.
- Type VS Code and press Enter to open it.
- Open a terminal inside VS Code by clicking Terminal in the top menu bar.
- Click New Terminal.
The google-genai SDK requires Python 3.10 or higher. Let's confirm your version first.
- Check your Python version by running this command:
python --version
macOS users
On macOS, the command is typically python3 --version instead. If python --version shows an error or Python 2, try python3 --version instead.
Use whichever command shows version 3.10 or higher throughout this project.
✔️ I see version 3.10 or higher
Your Python is ready to go. Continue to the SDK installation below.
ⓧ I see an older version
You need Python 3.10+ for the Google GenAI SDK. Download and install the latest Python from the official site.
- Visit python.org/downloads and download the latest Python installer for your operating system.
- Run the installer. On Windows, check the box that says Add Python to PATH before clicking Install Now.
- Close and reopen your VS Code terminal, then run the version check again.
macOS shadow version
macOS ships with a system Python that may be older than 3.10. After installing from python.org, use python3 --version to confirm the new version is active.
ⓧ Command not found
Python is not installed on your machine yet. Download it from the official site.
- Visit python.org/downloads and download the latest Python installer.
- Run the installer. On Windows, check Add Python to PATH before clicking Install Now.
- On macOS, run the downloaded .pkg file and follow the prompts.
- Close and reopen your VS Code terminal, then run python --version (or python3 --version on macOS) to confirm.
- Install the Google GenAI SDK by running this command:
pip install google-genai
macOS and pip
If you used python3 for the version check, use pip3 install google-genai here instead.
- Verify the SDK installed correctly by running:
python -c "from google import genai; print('SDK installed successfully!')"
You should see SDK installed successfully! printed in your terminal.
Seeing an error during install?
- If you see a permissions error, try pip install --user google-genai instead.
- If pip is not recognized, use python -m pip install google-genai (or python3 -m pip install google-genai on macOS).
- Make sure you are using the same Python that showed version 3.10+ in the version check above.
Still stuck? Help me troubleshoot my pip install error
Get your free Gemini API key
To call the Gemini API, you need an API key. Google offers a free tier with no credit card required, so this costs nothing.
- Open your browser and go to Google AI Studio.
- Sign in with your Google account.
- Click Get API key in the left sidebar.
- Click Create API key.
- Copy the generated key and keep it somewhere safe temporarily (a notes app or sticky note on your desktop).
Why keep your API key private?
Your API key is like a password for your Gemini access. Anyone who has it can make requests on your behalf. Never paste it into code that gets shared publicly (like a GitHub repository).
Permission denied when creating a key?
This sometimes happens with work or school Google accounts that have restricted permissions. Try signing in with a personal Gmail account instead.
Still stuck? Help me fix my API key creation error
Set up your environment variable
The Google GenAI SDK automatically reads your API key from an environment variable called GEMINI_API_KEY. This keeps your key out of your code.
- In your VS Code terminal, set the environment variable by running this command (paste your actual key in place of the placeholder):
macOS
export GEMINI_API_KEY="your-api-key-here"
- Verify it is set by running:
echo $GEMINI_API_KEY
You should see your API key printed back in the terminal.
Windows
$env:GEMINI_API_KEY = "your-api-key-here"
- Verify it is set by running:
echo $env:GEMINI_API_KEY
You should see your API key printed back in the terminal.
How long does this variable last?
This environment variable only lasts for your current terminal session. If you close and reopen the terminal, you will need to set it again using the same command.
Key not printing back?
- Make sure you included the quotes around your key value.
- On Windows, confirm your terminal says PowerShell (not Command Prompt) in the top-right dropdown of the terminal panel.
- Double-check you pasted the full key with no extra spaces.
Still stuck? Help me set my GEMINI_API_KEY environment variable
Your environment is ready. Next up, you will write Python code that calls the Gemini API and gets a real AI response in your terminal.
Make Your First AI Call
Your environment is ready. You have the SDK installed, an API key set, and Python running.
Now it is time to write actual Python code that talks to Gemini. In this step, you will send a prompt to the AI and see a real response appear in your terminal.
In this step, get ready to:
- Create a Python script that connects to the Gemini API.
- Send your first prompt and receive an AI-generated response.
- Experiment with different prompts to see how the AI adapts.
Create your project file
You need a Python file to hold your assistant code. You will create it on your Desktop so it is easy to find and run from the terminal.
- In the VS Code terminal, move to your Desktop by running this command:
cd ~/Desktop
Windows PowerShell path
If you are on Windows and the command above does not work, try cd $HOME\Desktop instead.
- Create a new file called daily_digest.py by pressing Cmd+N (macOS) or Ctrl+N (Windows) to open a new untitled file.
- Save the file immediately by pressing Cmd+S (macOS) or Ctrl+S (Windows).
- In the save dialog, navigate to your Desktop folder.
- Name the file daily_digest.py and click Save.
- Confirm the file exists by running:
ls
You should see daily_digest.py listed in the output.
Don't see the file?
Make sure your terminal is pointed at the Desktop. Run pwd (macOS/Linux) or echo $PWD (Windows PowerShell) to check your current location. If you are not on the Desktop, run the cd command above again.
Help me find my daily_digest.py file on my Desktop
Write and run your first AI call
Every AI API call follows the same pattern: create a connection, send a prompt, and read the response. Your script will do all three in just a few lines.
- Copy the following code into your daily_digest.py file:
from google import genai
client = genai.Client()
response = client.models.generate_content(
model="gemini-3.5-flash",
contents="What are 3 tips for a productive morning?"
)
print(response.text)
What does this code do?
- from google import genai loads the Google GenAI SDK so you can use its functions.
- client = genai.Client() creates a connection to the Gemini API. It automatically reads your GEMINI_API_KEY environment variable.
- client.models.generate_content() sends your prompt to the gemini-3.5-flash model and returns the AI's response.
- response.text extracts the text content from the response object so you can print it.
- Save daily_digest.py by pressing Cmd+S (macOS) or Ctrl+S (Windows).
- Run the script by entering this command in your terminal:
python daily_digest.py
You should see a text response from the AI printed in your terminal with three tips for a productive morning. The exact wording will be different each time you run it.
Seeing an error instead of a response?
- If you see a message about GEMINI_API_KEY, your environment variable may have been lost. Re-set it in the same terminal window you are using to run the script.
- If you see a ModuleNotFoundError, make sure you installed the SDK with pip install google-genai in the same Python environment you are running the script with.
- If you see a permission or quota error, double check that your API key was copied correctly from Google AI Studio.
Help me debug my first Gemini API call
✔️ Awesome, I've got everything!
Great. Double check you have saved your file before moving on.
ⓧ I'd like to double check the full code
from google import genai
client = genai.Client()
response = client.models.generate_content(
model="gemini-3.5-flash",
contents="What are 3 tips for a productive morning?"
)
print(response.text)
Understand what just happened
What happened behind the scenes?
Your code sent an HTTP request over the internet to Google's Gemini AI model. The model processed your prompt text, generated a response, and sent it back.
The client.models.generate_content() method is the core function for single-shot requests. You give it a model name and your prompt text, and it returns the AI's full response in one go.
Experiment with the prompt
Different prompts produce wildly different responses. This is the foundation of prompt engineering.
- Change the contents string in your code to something else, like "Give me a 5-item grocery list for a healthy lunch".
- Save the file and run python daily_digest.py again.
- Try asking the AI to format its response as bullet points by adding that instruction to your prompt.
- Observe how specific instructions in the prompt shape the output format and content.
Why does format matter in prompts?
LLMs follow instructions literally. If you say "respond in bullet points," the response comes back formatted that way. This is a preview of what you will do later when you write a system prompt to make the AI behave as a daily planner.
- When you are done experimenting, change the contents string back to "What are 3 tips for a productive morning?" and save the file.
You just made a real AI API call from code you wrote. Next, you will turn this single-shot request into a back-and-forth conversation that remembers what you said.
Build the Conversation Loop
In the previous step, you made your first successful call to the Gemini API and saw a one-shot response.
Now you will turn that single question-and-answer into an interactive conversation. A multi-turn chat lets the AI remember what you said earlier in the session, so follow-up questions make sense without repeating context.
In this step, get ready to:
- Replace the single-shot API call with a multi-turn chat session.
- Add an interactive input loop so you can keep chatting.
- Test that the AI remembers earlier messages in the conversation.
Replace the single-shot call with a multi-turn chat
Your current code sends one prompt and prints one response. To have a back-and-forth conversation, you need a chat session that automatically tracks what has been said.
- In daily_digest.py, find and select the last four lines (the response = client.models.generate_content(...) block and the print(response.text) line).
- Delete those lines.
- Replace them with the following code to create a chat session:
chat = client.chats.create(
model="gemini-3.5-flash"
)
What does this code do?
The client.chats.create() method opens a multi-turn chat session with the model you specify.
Behind the scenes, the SDK still uses the same generateContent API. The difference is that it automatically sends the full conversation history with every follow-up message, so the model can see everything you have said so far.
You will not see a change yet. The next chunk adds the loop that makes this code runnable.
Add an interactive input loop
A chat session on its own does nothing until you send messages to it. You need a loop that repeatedly asks for your input, sends it to the AI, and prints the response.
- Below the chat = client.chats.create(...) block, add the following interactive loop:
while True:
user_input = input("You: ").strip()
if user_input.lower() in ["quit", "exit", "q"]:
print("\nHave a productive day!")
break
if not user_input:
print("(Please type something, or 'quit' to exit.)\n")
continue
response = chat.send_message(user_input)
print(f"\nAssistant: {response.text}\n")
What does this code do?
- while True: keeps the loop running until you explicitly break out.
- input("You: ").strip() waits for you to type something and removes extra whitespace.
- The first if checks whether you typed quit, exit, or q to end the session.
- The second if catches empty input so the script does not send a blank message to the API.
- chat.send_message(user_input) sends your text to Gemini and returns the AI's response, which you print.
- Save daily_digest.py.
- Run the script by entering this command in your terminal:
python daily_digest.py
- Type a message (for example, Hello, can you help me plan my day?) and press Enter.
- You should see the AI respond with a text message printed below your input.
- Type quit to exit the loop.
Not seeing a response?
- Make sure your GEMINI_API_KEY environment variable is still set in this terminal session. If you closed and reopened the terminal, you need to set it again.
- Check that you deleted the old client.models.generate_content(...) lines completely. Leftover code will cause a syntax error.
- Confirm you are running the command from the same folder where daily_digest.py lives.
Why isn't my chat loop connecting to Gemini?
✔️ Awesome, I've got everything!
Great. Double check you have saved daily_digest.py before moving on.
ⓧ I'd like to double check the full code
Here is what daily_digest.py should look like at this point:
from google import genai
client = genai.Client()
chat = client.chats.create(
model="gemini-3.5-flash"
)
while True:
user_input = input("You: ").strip()
if user_input.lower() in ["quit", "exit", "q"]:
print("\nHave a productive day!")
break
if not user_input:
print("(Please type something, or 'quit' to exit.)\n")
continue
response = chat.send_message(user_input)
print(f"\nAssistant: {response.text}\n")
Test the conversation memory
The real power of a multi-turn chat is that the AI remembers what you said earlier. Let's confirm this works.
- Run the script again:
python daily_digest.py
- Type I have 3 meetings today and press Enter.
- After the AI responds, type When should I schedule deep work around those? and press Enter.
- The AI should reference your 3 meetings in its response. This confirms it remembers the earlier message.
- Type quit to exit.
Why does the AI remember?
The SDK's chat helper sends the full conversation history to the model with every follow-up turn. You do not need to manage this yourself. Each time you call chat.send_message(), the SDK appends your new message to the history and includes everything in the request.
You now have an interactive AI chatbot running in your terminal. Next, you will add a system prompt that turns this generic chatbot into a personalized daily planning assistant.
Add Your Personal System Prompt
Your assistant can hold a conversation, but right now it is a generic chatbot. It has no idea that its job is to help you plan your day.
A system prompt is a set of hidden instructions that shapes how the AI behaves for every message in a conversation. In this step, you will write a system prompt that turns your generic chatbot into a focused daily planning assistant.
In this step, get ready to:
- Write a system prompt that instructs the AI to prioritize tasks and suggest time blocks.
- Add a welcome header so the script feels like a real tool.
- Personalize the prompt to match your schedule and energy patterns.
Write your system instruction
The google-genai SDK supports a system instruction parameter that gets prepended to every conversation turn. The AI reads this instruction before reading the user's message, so it always follows your rules.
- In daily_digest.py, find the line from google import genai at the top of your file.
- Add this import directly below it:
from google.genai import types
- Now find the line client = genai.Client().
- Add this system_prompt variable directly below it:
system_prompt = """You are a personal daily planning assistant. Your job is to help the user organize their day.
When the user shares their tasks, goals, or schedule:
1. Reorganize them by priority (urgent, important, nice-to-have)
2. Suggest a time-blocked schedule for the day
3. Add a short motivational note
Keep responses concise and actionable. Use bullet points and clear formatting.
If the user asks to adjust the plan, update it based on their feedback."""
What does this system prompt do?
The triple-quoted string contains your hidden instructions for the AI. It tells the model to reorganize tasks by urgency, suggest a time-blocked schedule, and include a motivational note.
The AI will follow these instructions for every message in the conversation without the user needing to ask.
Now you need to connect this system prompt to the chat session. The SDK accepts system instructions through a configuration object.
- In daily_digest.py, find the client.chats.create() call.
- Find this code:
chat = client.chats.create(
model="gemini-3.5-flash"
)
- Replace it with this version that passes your system prompt via the config parameter:
chat = client.chats.create(
model="gemini-3.5-flash",
config=types.GenerateContentConfig(
system_instruction=system_prompt
)
)
What is GenerateContentConfig?
types.GenerateContentConfig is a configuration object from the SDK that lets you pass settings alongside your chat. The system_instruction field tells the model how to behave before it reads any user messages.
- Save daily_digest.py.
- Run your script with this command:
python daily_digest.py
- Type something like I have a report due, gym, grocery shopping, and a team meeting at 2pm and press Enter.
- You should see the AI respond with a prioritized list, time blocks, and a motivational note.
Getting a NameError about types?
Make sure your from google.genai import types import is on line 2, directly below from google import genai. If you see NameError: name 'types' is not defined, the import is missing or misspelled.
Also check that system_prompt is defined above the client.chats.create() call, not below it. Python reads top to bottom, so the variable must exist before it is referenced.
Need help debugging? Why is my system prompt not working?
Add a welcome message and polish the terminal output
Right now the script drops straight into the input prompt with no context. Adding a welcome header makes it clear what the tool does and how to use it.
- In daily_digest.py, find the while True: line.
- Add this welcome header directly above it:
print("=" * 50)
print(" Daily Digest Assistant")
print(" Type your tasks, goals, or questions.")
print(" Type 'quit' to exit.")
print("=" * 50)
print()
What does this code do?
print("=" * 50) prints a line of 50 equals signs as a visual separator. The lines in between show the app name and usage instructions. The final print() adds an empty line before the first prompt so the output is not cramped.
- Save daily_digest.py and run it again:
python daily_digest.py
- You should see a boxed header with "Daily Digest Assistant" and usage instructions before the You: prompt appears.
Header not showing up?
Make sure the print() statements are placed between the chat = client.chats.create(...) block and the while True: loop. If they are inside the loop, the header prints every time you send a message.
Need a hand? Help me figure out where my print statements should go.
Personalize the system prompt for your life
The system prompt works, but it does not know anything about your actual schedule. Adding a few personal details makes the AI's suggestions dramatically more useful.
- In daily_digest.py, find the closing """ of your system_prompt variable.
- Before those closing triple quotes, add 1-2 sentences about your schedule and preferences.
What to include
Think about what would help a planner make better suggestions for you. Are you a morning person or a night owl? When do you have classes or work? When is your peak focus time?
For example, you could add: "The user is a morning person who prefers deep work before noon. They have classes from 2-4pm on weekdays."
- Save daily_digest.py and run it one more time:
python daily_digest.py
- Brain-dump your real tasks for today. The AI should now produce a plan that respects your personal schedule and energy patterns.
- Try a follow-up message like Can you move the gym to the evening instead? to test that the conversation memory still works with the system prompt active.
Why does personalization matter?
A generic planner suggests generic time blocks. When you tell the AI your constraints ("classes at 2pm", "low energy after lunch"), it avoids scheduling deep work in those slots. This is the core skill of prompt engineering — giving the model enough context to produce output tailored to your situation.
✔️ Awesome, I've got everything!
Great. Double check you have saved daily_digest.py and that your personalized system prompt is in place.
ⓧ I'd like to double check the full code
Here is the complete daily_digest.py at this point (your personal additions to the system prompt will differ):
from google import genai
from google.genai import types
client = genai.Client()
system_prompt = """You are a personal daily planning assistant. Your job is to help the user organize their day.
When the user shares their tasks, goals, or schedule:
1. Reorganize them by priority (urgent, important, nice-to-have)
2. Suggest a time-blocked schedule for the day
3. Add a short motivational note
Keep responses concise and actionable. Use bullet points and clear formatting.
If the user asks to adjust the plan, update it based on their feedback."""
chat = client.chats.create(
model="gemini-3.5-flash",
config=types.GenerateContentConfig(
system_instruction=system_prompt
)
)
print("=" * 50)
print(" Daily Digest Assistant")
print(" Type your tasks, goals, or questions.")
print(" Type 'quit' to exit.")
print("=" * 50)
print()
while True:
user_input = input("You: ").strip()
if user_input.lower() in ["quit", "exit", "q"]:
print("\nHave a productive day!")
break
if not user_input:
print("(Please type something, or 'quit' to exit.)\n")
continue
response = chat.send_message(user_input)
print(f"\nAssistant: {response.text}\n")
Secret mission
Save Your Plan and Add Time Awareness
Your assistant works great, but it has no idea what day or time it is. That means its time-blocked suggestions are generic. In this secret mission, you'll inject real-time awareness into the system prompt and add the ability to save your finalized plan as a markdown file you can reference all day.
Clean Up Your Resources
Clean Up Your Resources
This project runs entirely locally and uses the Gemini API free tier, so there are no ongoing costs. Decide whether to keep your resources running, pause them to come back later, or delete them entirely.
Resources you used:
- daily_digest.py (your project script).
- daily_plan_*.md files (saved plans generated by the save command).
- google-genai Python package (installed via pip).
- Gemini API key (stored in Google AI Studio).
Keep everything running
No action needed. Choose this if you plan to keep using your Daily Digest Assistant or want to build on it further.
- Your daily_digest.py file stays wherever you saved it in VS Code.
- The GEMINI_API_KEY environment variable only lasts for your current terminal session. You will need to re-set it next time you open a terminal.
- Your API key remains active in Google AI Studio. The free tier has no expiration and no credit card requirement.
Pause - I'll come back to this later
Free up your terminal session while keeping all files intact so you can return later.
- Close the terminal in VS Code. This clears the GEMINI_API_KEY environment variable automatically since it was session-only.
- Your daily_digest.py and any daily_plan_*.md files remain on disk.
- When you come back, re-set the environment variable in a new terminal by running:
$env:GEMINI_API_KEY = "your-api-key-here"
- Then run python daily_digest.py to pick up where you left off.
Delete - I don't want to use this again
Remove all project files, uninstall the SDK, and delete your API key.
- Delete your project files. In your VS Code terminal, navigate to the folder containing daily_digest.py and run:
Remove-Item daily_digest.py
Remove-Item daily_plan_*.md
- Uninstall the google-genai package by running:
pip uninstall google-genai
- Type y when prompted to confirm the uninstall.
- Delete your Gemini API key from Google Cloud. Open the Google Cloud API Credentials page at https://console.cloud.google.com/apis/credentials.
- Find the API key you created for this project and click the Actions icon (three dots).
- Select Delete API key.
- In the Delete credential modal, click Delete to confirm.
- Close your terminal session. This automatically clears the GEMINI_API_KEY environment variable.
Nice Work!
Nice Work!
You just built a fully functional AI-powered daily planning assistant from scratch. Every morning, you can run this script to turn a messy brain dump into an organized, time-blocked plan.
You've learned how to:
- Called the Gemini API from Python using the official google-genai SDK, sending prompts and receiving AI-generated text responses.
- Designed a system prompt that shapes AI behavior for a specific use case, turning a general-purpose model into a focused daily planner.
- Built a multi-turn chat loop that maintains conversation context across messages, so the AI remembers what you said earlier.
- Secret Mission: Added real-time date/time awareness and the ability to save your generated plan as a markdown file.
Ready to quiz yourself?