A deployable AI agent application built with Google Vertex AI Gemini, Firestore, and Cloud Run. It demonstrates persistent conversational memory, controlled tool execution, API design, and practical production-oriented safeguards in one end-to-end project.
- Vertex AI Gemini for model inference and tool-aware conversations
- Firestore for session-scoped persistent conversation history
- Cloud Run for containerized serverless deployment
- Google Cloud authentication through Application Default Credentials
This repository is designed as a practical reference for developers building agentic applications on Google Cloud. Rather than stopping at a single prompt/response example, it connects the model to memory, tools, an HTTP application layer, and deployable infrastructure.
- Persistent memory β conversation history is stored per session in Firestore
- Tool calling β the agent can invoke a calculator, a restricted web-fetch tool, and an email integration interface
- REST API β Flask endpoints support chat and session reset flows
- Cloud deployment β the application is structured for deployment to Cloud Run
- Input safeguards β validation, request-size controls, and domain allowlisting reduce unsafe tool execution
- Responsive web UI β a lightweight front end provides an interactive chat experience
User
β
Flask Web/API Layer
β
Vertex AI Gemini
βββ Conversation reasoning
βββ Tool selection
βββ Calculator
βββ Restricted Web Fetch
βββ Email integration interface
β
Firestore session memory
β
Cloud Run deployment
| Layer | Technology |
|---|---|
| AI | Google Vertex AI Gemini |
| Memory | Google Cloud Firestore |
| Compute | Google Cloud Run |
| Backend | Python 3.11+, Flask |
| Front end | HTML, CSS, JavaScript |
| Auth | Google Cloud Application Default Credentials |
git clone https://github.com/tejas5038/vertex-gemini-chatbot.git
cd vertex-gemini-chatbotpython -m venv venv
source venv/bin/activate
pip install -r requirements.txtOn Windows, activate with:
venv\Scripts\activateCreate your local environment file:
cp .env.example .envThen configure your Google Cloud project and enable the services required by the application, including Vertex AI and Firestore.
Authenticate locally:
gcloud auth application-default login
gcloud config set project YOUR_PROJECT_IDpython app.pyOpen http://localhost:8080.
Send a message:
curl -X POST http://localhost:8080/api/chat \
-H "Content-Type: application/json" \
-d '{"session_id":"demo-session","user_message":"What is 25 * 47?"}'Reset a conversation:
curl -X POST http://localhost:8080/api/reset \
-H "Content-Type: application/json" \
-d '{"session_id":"demo-session"}'After configuring your project-specific environment variables, deploy from the repository root:
gcloud run deploy vertex-gemini-chatbot \
--source . \
--platform managed \
--region us-central1 \
--allow-unauthenticated \
--set-env-vars GCP_PROJECT_ID=YOUR_PROJECT_ID,GCP_LOCATION=us-central1,FIRESTORE_COLLECTION=chat_sessionsFor a real production deployment, review authentication, authorization, rate limiting, logging, secrets management, and access policy before exposing the service publicly.
The sample includes several safeguards that are useful when building tool-enabled AI systems:
- calculator expressions are constrained rather than passed to unrestricted execution
- web requests are limited to approved domains
- inputs and request sizes are validated
- credentials are expected to remain outside source control
- the email capability is an integration interface and is not enabled with embedded credentials
This project can be used as a starting point for workshops, demos, and experiments involving:
- Gemini-powered conversational applications
- agent memory patterns
- tool-use orchestration
- serverless AI deployment on Google Cloud
- secure integration of LLMs with external capabilities
Alongside building Google-technology projects, I contribute fixes and tests to open-source projects in the Google ecosystem.
- Google Magika β PR #1443 β merged upstream
- Google Highway β PR #3361 β merged upstream
Tejas Pravinbhai Patel
Software Development Engineer | AI, distributed systems, and cloud engineering
GitHub: @tejas5038
MIT