PTU Advisor helps you decide when to use Provisioned Throughput Units (PTU) versus Pay-As-You-Go (PAYG) for Azure AI Foundry deployments.
It combines Azure usage metrics, 4-dimension scoring, break-even analysis, and hybrid spillover modeling to produce clear recommendations with confidence and cost impact.
PTU Advisor provides three delivery surfaces over one analysis engine:
| Surface | Tech | Primary Use | Output |
|---|---|---|---|
| Dashboard | React + TypeScript | Interactive exploration and what-if analysis | Cost curves, break-even point, scoring breakdown |
| API | FastAPI | Integrations and programmatic analysis | JSON recommendation payloads |
| CLI | Typer | Terminal-first workflows and reports | Console summaries + HTML report |
Core analysis includes:
- 4-dimension recommendation model (Workload Shape, Capacity Pressure, Latency Sensitivity, Load Predictability)
- Hybrid PTU + spillover PAYG cost model
- Break-even TPM calculation and baseline PTU sensitivity
- Auto-discovery for subscriptions, accounts, and deployments
- Optional LLM-powered narrative explanation
Before running PTU Advisor, prepare the following.
- Python 3.9+
- Node.js 18+ and npm
- Docker + Docker Compose (for containerized run)
- Azure subscription access to the target AI Foundry / Azure OpenAI resources
- Azure CLI installed and authenticated (required before
docker compose upwhen using live Azure mode):
az login
az account showCreate a .env file in the project root when using service principals or optional LLM explanations:
# Azure credentials (optional if using az login + user context)
AZURE_TENANT_ID=...
AZURE_CLIENT_ID=...
AZURE_CLIENT_SECRET=...
AZURE_SUBSCRIPTION_ID=...
# Optional LLM narrative explanation
AZURE_OPENAI_ENDPOINT=https://my-resource.openai.azure.com
AZURE_OPENAI_DEPLOYMENT=gpt-4oYes — this repository supports host-based Azure CLI auth with Docker.
Important: For live Azure discovery/analysis,
az loginon the host is a prerequisite todocker compose up. Without a valid host login, setup/discovery endpoints will fail in live mode.
- Authenticate on your host machine:
az login
az account set --subscription <your-subscription-id>- Start the stack:
docker compose up --buildThe compose file mounts your host ~/.azure into the container and sets AZURE_CONFIG_DIR, so discovery and live analysis can use the same signed-in context.
If you only want demo mode, Azure login is not required.
docker compose upThe app is available at http://localhost:8000.
docker build -t ptu-advisor .
docker run -p 8000:8000 ptu-advisorOpen http://localhost:8000 and choose one of:
- Deployment Advisor (live Azure or demo scenarios)
- PTU Calculator (manual estimation, no Azure dependency)
# Run demo scenario
docker compose run --rm cli demo --scenario ptu-recommended
# List scenarios
docker compose run --rm cli demo-list
# Analyze live deployment
docker compose run --rm cli analyze \
--resource-group my-rg \
--workspace my-workspace \
--deployment gpt-4o-productioncd ptu-recommander
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
uvicorn ptu_advisor.api.server:app --reload --port 8000cd frontend
npm install
npm run devThe frontend dev server runs on http://localhost:5173 and proxies /api/* to backend port 8000.
# Demo mode
ptu-advisor demo --scenario ptu-recommended
# List demos
ptu-advisor demo-list
# Live deployment analysis
ptu-advisor analyze \
--resource-group my-rg \
--workspace my-workspace \
--deployment gpt-4o-production \
--days 14| Method | Endpoint | Description |
|---|---|---|
GET |
/api/health |
Health check |
GET |
/api/focus-topics |
Demo focus topics |
GET |
/api/pricing/options |
Regions and deployment types |
GET |
/api/discovery/subscriptions |
List subscriptions |
GET |
/api/discovery/accounts |
List Azure OpenAI accounts |
GET |
/api/discovery/deployments |
List deployments |
POST |
/api/analyze |
Run PTU vs PAYG analysis |
PTU Advisor evaluates four dimensions and combines them into a recommendation:
| Dimension | Focus | PTU-Favorable Signal |
|---|---|---|
| Workload Shape | Throughput stability and variance | Stable, sustained demand |
| Capacity Pressure | Throttling and utilization pressure | Frequent saturation / 429s |
| Latency Sensitivity | Tail latency behavior (P95/P99) | High or unstable tail latency |
| Load Predictability | Regularity of demand patterns | Predictable baseline load |
Recommendation outcomes:
- ✅ PTU Recommended
⚠️ Borderline- ❌ PTU Not Recommended
Cost outputs include:
- PAYG monthly estimate
- Hybrid PTU + spillover monthly estimate
- Break-even TPM
- Suggested baseline PTU and sensitivity curve
This solution uses a layered architecture so UI, API, and decision logic can evolve independently.
- Frontend (
frontend/): React dashboard for interactive analysis and PTU calculator - API (
ptu_advisor/api/server.py): FastAPI orchestration layer and response shaping - Analysis Engine (
ptu_advisor/analysis/): 4-dimension scoring and recommendation logic - Cost Engine (
ptu_advisor/cost/): PTU sizing, break-even, and spillover calculations - Metrics & Discovery (
ptu_advisor/metrics/,ptu_advisor/discovery.py): data collection and Azure resource discovery - Reports (
ptu_advisor/report/): HTML report generation for CLI workflows
- Keeps cost math and recommendation scoring testable and reusable
- Supports multiple interfaces (CLI, API, Dashboard) with a shared core
- Enables demo mode and live Azure mode with the same decision path
ptu-recommander/
├── ptu_advisor/
│ ├── api/server.py
│ ├── analysis/
│ ├── cost/
│ ├── metrics/
│ ├── report/
│ ├── visualization/
│ ├── cli.py
│ ├── config.py
│ ├── demo.py
│ └── discovery.py
├── frontend/
│ ├── src/
│ ├── package.json
│ └── vite.config.ts
├── tests/
├── Dockerfile
├── docker-compose.yml
└── pyproject.toml
# Backend
pytest
# Frontend
cd frontend && npm test# Backend static checks
mypy ptu_advisor
ruff check ptu_advisor
ruff format ptu_advisor
# Frontend type check + build
cd frontend && npx tsc -b --noEmit
cd frontend && npm run buildaz login
az account showFor live mode with Docker, verify this order:
az login
az account set --subscription <your-subscription-id>
docker compose up --buildIf discovery still fails:
- Confirm host Azure profile exists at
~/.azure - Rebuild the app image:
docker compose up -d --build - Check app logs:
docker compose logs -f app
az cognitiveservices account show \
--name my-workspace \
--resource-group my-rg- Ensure deployment has recent traffic
- Verify Azure Monitor metrics are available
- Confirm Reader+ access to the resource scope
docker compose build --no-cache
docker compose logs -f- Fork the repository
- Create a feature branch
- Add or update tests for your changes
- Run backend/frontend test suites
- Open a pull request
MIT