Azure Cost Estimator Chatbot - AI Agent

AI Agent

AI-Powered Automation:

Azure Cost Estimator Chatbot

Conversational Azure Pricing · Real-Time Cost Estimation · Session History · Secure Auth Streamlit · FastAPI · OpenAI GPT-4 · PostgreSQL · Azure Pricing API · Azure VM

Overview

The Azure Cost Estimator Chatbot is a web-based conversational application that enables users to interactively estimate Azure cloud service costs through natural language. Built on a three-tier architecture, it combines a Streamlit frontend, a FastAPI backend, and a PostgreSQL database to deliver a seamless, intelligent, and secure cost estimation experience. Users interact with a familiar chat interface to ask questions about Azure pricing in plain English. The system understands their intent via OpenAI GPT-4, calls real-time Azure Pricing APIs as tools, and returns accurate, itemised cost breakdowns — no manual lookup or pricing documentation required.
The platform currently provides:
Conversational Chat Interface

A Streamlit-powered chat UI that accepts natural language queries about Azure services and pricing.

Secure User Authentication

Login and registration with hashed password storage to protect user accounts and session data.

Real-Time Azure Pricing API Integration

FastAPI backend calls Azure's live Pricing API as an LLM tool to fetch accurate, up-to-date cost data.

OpenAI GPT-4 Intent Processing

Understands and classifies user queries, extracts service parameters, and generates structured cost responses.

Itemised Cost Breakdowns

Returns detailed, line-by-line Azure cost estimates per service, region, tier, and usage pattern.

Chat History Persistence

All conversations are stored per user in PostgreSQL, enabling future reference and session continuity.

Linux Deployment Ready

Fully deployable on an Azure VM running Ubuntu, with zero downtime and production-grade configuration.

Challenges

Before this chatbot existed, organisations estimating Azure cloud costs faced significant friction and inefficiency:
Complex Pricing Documentation:

Azure's pricing pages are vast and service-specific. Engineers spent hours navigating documentation to estimate costs for even straightforward deployments.

Manual Estimation Errors:

Cost estimates created manually in spreadsheets were prone to version mismatch, incorrect tier assumptions, and outdated pricing — leading to budget overruns.

No Conversational Interface:

Existing Azure calculators require users to fill structured forms and know exactly which parameters to input — creating a steep learning curve for non-technical stakeholders.

No Session Continuity:

Pricing discussions held verbally or over email were lost immediately. There was no structured way to revisit, compare, or refine past cost estimates.

Slow Cross-Team Collaboration:

DevOps, finance, and product teams had no shared tool to estimate and align on cloud costs collaboratively and in real time.

Objectives / Goals

This chatbot was designed to achieve the following goals:

Provide an intuitive, natural language interface for Azure cost estimation — removing the need to manually navigate pricing pages or fill structured forms.

Securely authenticate users with hashed password storage, ensuring each user has a private, protected session environment.

Persist chat history per user in PostgreSQL, enabling future reference, session continuity, and side-by-side cost comparisons.

Use OpenAI GPT-4 to understand user intent, extract service parameters, and generate structured, human-readable cost breakdowns.

Call Azure Pricing APIs dynamically as LLM tools to return accurate, real-time pricing data — never relying on static or cached figures.

Deploy on a Linux Azure VM with production-grade configuration and zero downtime, making the system immediately operational for enterprise teams.

Scale cost estimation across technical and non-technical roles — enabling finance managers, architects, and developers to use the same tool without training.

Solution

Built on a clean three-tier architecture, the Azure Cost Estimator Chatbot connects a Streamlit frontend to a FastAPI backend and a PostgreSQL database, with OpenAI and the Azure Pricing API powering the intelligence layer. Each component has a clearly defined responsibility, making the system modular, maintainable, and production-ready.

Workflow Logic

User Login / Registration:

The user authenticates via the Streamlit UI. Passwords are hashed before storage in PostgreSQL. Authenticated users receive a session token.

Chat Query Submission:

The user types a natural language question such as 'How much will 4 Azure VMs (Standard D4s v3) in East US cost per month?' into the chat interface.

FastAPI Request Handling:

The Streamlit frontend posts the message to the FastAPI backend via a REST endpoint. FastAPI validates the session and routes the query to the OpenAI processing layer.

OpenAI Intent Extraction:

GPT-4 analyses the query, identifies the Azure services requested, and determines the required parameters — service name, region, tier, and usage volume.

Azure Pricing API Tool Call:

FastAPI calls the Azure Pricing API as an LLM tool, passing the extracted parameters. The API returns real-time, itemised pricing data for the specified services.

Response Generation:

OpenAI GPT-4 receives the API response and formats a structured, readable reply with per-service cost breakdowns, totals, and relevant notes.

Reply Delivery & History Persistence:

The FastAPI backend saves the full conversation turn (user message + AI response) to PostgreSQL. The formatted reply is returned to the Streamlit UI and rendered in the chat window.

Session Review:

Users can revisit previous estimation sessions from the chat history panel, allowing them to compare costs across configurations or resume a prior conversation.

Key Tools & Technologies

Tools & Services Purpose
Streamlit Frontend chat UI — conversational interface, session state, and history display
FastAPI Backend API layer — request handling, authentication, routing, and tool orchestration
OpenAI GPT-4 Natural language understanding — intent extraction, response generation, and tool use
Azure Pricing API Real-time Azure cost data — fetched dynamically per user query as an LLM tool
PostgreSQL User data persistence — account storage, hashed passwords, and full chat history
Azure VM (Linux) Deployment environment — Ubuntu-based production server with zero downtime setup
REST APIs Inter-service communication between Streamlit frontend and FastAPI backend

Deliverables included:

Streamlit frontend:

fully configured chat UI with session management and history panel

FastAPI backend :

authentication, request routing, and Azure Pricing API integration

OpenAI GPT-4 integration :

prompt design, intent extraction, and tool call configuration

PostgreSQL schema :

user accounts, hashed password storage, and conversation persistence

Azure Pricing API tool :

dynamic real-time pricing fetch per service query

Deployment configuration :

production setup on Azure VM (Ubuntu) with zero downtime

Full handover documentation :

architecture overview, setup guide, and API reference

Duration & Resources

Metric Value
Total Build Time 4 Days
Resources Used 1 Automation Engineer
Handover Full documentation included
Deployment Zero downtime — Azure VM (Linux)
Operating Mode 24×7 — fully automated, always on

Use Cases

The following are key real-world applications of this chatbot:
VM Cost Estimation:

An engineer asks 'What is the monthly cost of running 10 Standard D8s v3 VMs in UK South?' — the chatbot fetches live pricing and returns a full itemised breakdown instantly.

Multi-Service Architecture Pricing:

A cloud architect inquires about the combined cost of an App Service, Azure SQL Database, and Blob Storage for a new product — the system estimates all three in a single response.

Region Comparison:

A finance manager asks 'Which is cheaper for Azure Kubernetes Service — East US or West Europe?' — the chatbot calls the API for both regions and provides a cost comparison.

Budget Planning:

A product team asks for a full infrastructure cost estimate ahead of a product launch. The chatbot accumulates multiple service estimates across the conversation and provides a session total.

Session History Review:

A user returns to the chatbot a week later to revisit a cost estimate from a previous session — all prior conversations are retrieved from PostgreSQL and displayed in context.

Non-Technical Stakeholder Access:

A business director with no cloud expertise asks 'How much does it cost to run a website on Azure?' — the chatbot guides the conversation, asks clarifying questions, and returns an accessible estimate.

Outcomes

Metric Before Automation After Deployment Improvement
Estimation Time 30–120 mins manual < 30 seconds 99% faster
Pricing Accuracy Error-prone (static docs) Real-time API data 100% live pricing
Accessibility Technical users only Any stakeholder Fully democratised
Session Continuity None — lost after call Full history in DB Permanent record
Deployment Effort No prior tooling Zero downtime on VM Production-ready
Scalability 1 engineer, manual Unlimited queries ∞ capacity

Key Features

What makes this system particularly powerful:
Conversational Cost Estimation :

Users ask questions in plain English, with no forms or structured input required. GPT-4 handles all intent parsing and parameter extraction automatically.

Real-Time Azure Pricing API as LLM Tool :

Pricing is never cached or hardcoded. Every query triggers a live API call to Azure's Pricing API, returning accurate, current data for the exact service configuration requested.

Secure User Authentication :

Passwords are hashed using industry-standard cryptography before storage in PostgreSQL. No plaintext credentials are ever retained.

Persistent Chat History :

Every conversation turn is saved to PostgreSQL per user, enabling session continuity, historical review, and side-by-side cost comparisons across configurations.

Three-Tier Modular Architecture:

Streamlit handles UI, FastAPI handles business logic and API orchestration, and PostgreSQL handles persistence — each tier independently replaceable and scalable.

Itemised Cost Breakdowns :

Responses include per-service line items, regional pricing, tier-specific rates, and estimated monthly totals in a structured, readable format.

Multi-Service Query Support :

A single user message can request pricing for multiple Azure services simultaneously. GPT-4 decomposes the query and the backend fetches pricing for each independently.

Zero-Downtime Linux Deployment :

The entire stack is deployable on an Azure VM (Ubuntu) with production-grade configuration, startup scripts, and environment management built in.

Limitations

The following limitations currently apply to this system:
Azure Services Coverage :

The chatbot relies on the Azure Pricing API for data retrieval. Services or SKUs not exposed through this API may return incomplete or unavailable pricing information.

No Cost Optimisation Recommendations :

The system estimates costs for specified configurations but does not proactively suggest cheaper alternatives, reserved instance savings, or Azure Hybrid Benefit discounts without being explicitly asked.

Single Currency Output :

Cost estimates are returned in USD by default, aligned with the Azure Pricing API. Multi-currency support or dynamic conversion requires additional implementation.

No Azure Account Integration :

The chatbot provides general pricing estimates based on public Azure rates. It does not connect to a user's actual Azure subscription, meaning enterprise agreements, negotiated discounts, or actual usage data are not reflected.

Conclusion

The Azure Cost Estimator Chatbot demonstrates the practical power of combining large language models, real-time APIs, and a clean full-stack architecture to solve a genuinely time-consuming problem in cloud infrastructure planning. By integrating OpenAI GPT-4, the Azure Pricing API, FastAPI, Streamlit, and PostgreSQL, this solution enables any stakeholder — technical or otherwise — to estimate Azure cloud costs through natural conversation, in seconds rather than hours. Whether it is pricing a single virtual machine, comparing multi-region costs, planning a multi-service architecture, or reviewing a previous estimation session — every query is handled with accuracy, speed, and clarity.
Estimate smarter. Deploy faster. Plan with confidence.