A REST service that reads a vehicle CSV and, for a given VIN, returns a JSON report:
summary: short human-readable market positionrisk_score: 1–10 (1=low risk, 10=high risk) — computed deterministically from CSV metricsreasoning: concise explanation (from the LLM)
- Your Azure OpenAI resource deployed with a model (e.g.,
o4-mini) and deployment name - A CSV with columns:
vin, make, model, year, price, price_to_market, days_on_lot, mileage, vdp_views, sales_opportunities - Docker (for container run) or Python 3.11+
Set these (match your setup):
# Azure resource endpoint (no trailing /openai/v1)
AZURE_OPENAI_ENDPOINT=https://<your-resource>.openai.azure.com
# API key (either name works)
AZURE_OPENAI_API_KEY=<key> # preferred per docs
# or
AZURE_OPENAI_KEY=<key>
# Deployment name you created for the model (e.g., o4-mini)
AZURE_OPENAI_DEPLOYMENT=o4-mini
# Optional: lock a specific API version
AZURE_OPENAI_API_VERSION=2024-12-01-preview
# Path to your CSV (mounted into the container or local path)
CSV_PATH=/app/data/vehicles.csvNote: The SDK call pattern follows the Azure Responses API examples (Python) where the client is created with
OpenAI(base_url=..., api_key=...)andresponses.create(...)(see Microsoft Learn).
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
export AZURE_OPENAI_ENDPOINT="https://<your-resource>.openai.azure.com"
export AZURE_OPENAI_API_KEY="<your-key>"
export AZURE_OPENAI_DEPLOYMENT="o4-mini"
export AZURE_OPENAI_API_VERSION="2024-12-01-preview" # optional
export CSV_PATH="<absolute/path/to/your/vehicles.csv>"
uvicorn app.main:app --reload --port 8000docker build -t VINalyze .
docker run --rm -p 8000:8000 \
-e AZURE_OPENAI_ENDPOINT="https://<your-resource>.openai.azure.com" \
-e AZURE_OPENAI_API_KEY="<your-key>" \
-e AZURE_OPENAI_DEPLOYMENT="o4-mini" \
-e AZURE_OPENAI_API_VERSION="2024-12-01-preview" \
-e CSV_PATH="/app/data/vehicles.csv" \
-v /absolute/path/to/your.csv:/app/data/vehicles.csv:ro \
VINalyze- Get a few VINs to test:
curl http://localhost:8000/vins- Request a report:
curl -X POST http://localhost:8000/report \
-H "Content-Type: application/json" \
-d '{"vin": "PUT_A_VIN_FROM_YOUR_CSV_HERE"}'PowerShell:
Invoke-RestMethod -Method Post "http://localhost:8000/report" `
-ContentType "application/json" `
-Body (@{ vin = "PUT_A_VIN" } | ConvertTo-Json)The response is a strict JSON object:
{
"summary": "…",
"risk_score": 7,
"reasoning": "…"
}Place your CSV at data/vehicles.csv or set CSV_PATH to your file. The service loads it once at startup.
- If you see
LLM call failed: Missing AZURE_OPENAI_ENDPOINT(or KEY/DEPLOYMENT), double‑check your env vars. - If your Azure stack requires an explicit
api-version, setAZURE_OPENAI_API_VERSION(the client will attach it). - The LLM is only used to craft
summaryandreasoning. The numericrisk_scoreis computed deterministically so tests are reproducible.
MIT
- Resource Name:
VINalyze - Project Name:
VINalyzeUse these names consistently in Azure AI Studio/Foundry and your deployment’sAZURE_OPENAI_DEPLOYMENT(e.g.,o4-mini).