JANSETU AI API Docs
Base URL: https://jansetu-ai-web-sooty.vercel.app (web) and https://api.jansetu.ai (or NEXT_PUBLIC_API_URL). Prefer /openapi.json for code-gen. For agents, start at /llms.txt and /.well-known/mcp.
Authentication — JANSETU AI
Production: Firebase ID token via Authorization: Bearer <idToken>. Demo: allow x-role: citizen | analyst | policymaker header when ALLOW_DEMO_AUTH=true. CORS whitelist via CORS_ORIGINS. Never send GEMINI_API_KEY or SUPABASE_SERVICE_ROLE_KEY from browser — all secret-key calls are proxied via the API.
curl https://jansetu-ai-web-sooty.vercel.app/api/analytics/hotspots -H "x-role: analyst" curl https://jansetu-ai-web-sooty.vercel.app/api/projects/recommended -H "Authorization: Bearer <FIREBASE_ID_TOKEN>"
Endpoints — JANSETU AI
Deterministic scoring, audit-logged decisions| Method | Path | Description | Auth / Body |
|---|---|---|---|
| POST | /api/requests | Submit citizen request (GU/HI/EN voice/text/photo) | x-role: citizen or Bearer · { originalText, sourceLanguage, latitude?, longitude?, locationSource? } → 201 { requestId } |
| GET | /api/requests/{id} | Fetch request by ID | any · → request object |
| POST | /api/requests/{id}/analyze | AI intake → cluster → deterministic v1 score (core chain) | any · → intake, cluster, priority { priority_score, components, weightVersion }, evidenceRefs, human_review_notice |
| GET | /api/clusters | List clusters (demand groups) | any · → { clusters: [...] } |
| GET | /api/clusters/{id} | Cluster detail + members + score explain | any · → cluster + requests |
| POST | /api/clusters/{id}/score | Re-score deterministically (no AI) | analyst/policymaker · → priority |
| GET | /api/clusters/{id}/explain | Score drivers/limiters explanation | any · → explain |
| GET | /api/projects/recommended | Candidate projects ordered by priority | any · → projects |
| POST | /api/projects/generate | Generate candidate project from cluster | analyst · { clusterId } → project |
| POST | /api/projects/{id}/review | Human approve/reject with audit log | policymaker · { decision: "approved"|"rejected", reason } |
| GET | /api/projects/{id}/impact | Baseline → target → actual (observed vs modeled) | any · → baseline_metrics, estimated_impact, data_quality |
| GET | /api/projects/{id}/brief | Policy brief 12 sections + human_review_notice | analyst · → brief |
| POST | /api/copilot | Policy Q&A grounded in evidence | analyst · { question: "Which projects within ₹10 Cr?" } |
| POST | /api/copilot/simulate | Budget simulator (structured) | analyst · { budget, objective, risk_tolerance } → selected_projects, trade_offs |
| GET | /api/analytics/hotspots | GeoJSON + hotspots (centroids, not PII) | any · → geojson { features } |
| GET | /api/analytics/investment-gaps | Investment gaps by district | any · → gaps |
| GET | /api/analytics/kpis | KPIs + trend | any · → kpis, trend |
| POST | /api/upload | Photo upload (5 MB cap, base64 ≤6.7MB wire) | citizen · multipart / json → url |
| POST | /api/transcribe | Voice transcription via Gemini | citizen · { audio } → text |
Every component + weightVersion persisted. Band: critical ≥80 · high 65–79 · moderate 45–64 · low <45. Gemini explains, not overrides.
Webhooks fire on project review (approved/rejected) with audit_logs payload. MCP server exposes all API routes as tools via Streamable HTTP at /.well-known/mcp (also npm @vercel/mcp-adapter). Vercel score 42902.
# JANSETU AI — Gujarati voice to impact
GU="અમારા ગામનો રસ્તો વરસાદમાં બંધ થઈ જાય છે. હોસ્પિટલ જવા માટે ખૂબ સમય લાગે છે."
RID=$(curl -s -X POST https://jansetu-ai-web-sooty.vercel.app/api/requests -H "Content-Type: application/json" -H "x-role: citizen" -d "{\"originalText\":\"$GU\",\"sourceLanguage\":\"gu\"}" | jq -r .requestId)
curl -s -X POST https://jansetu-ai-web-sooty.vercel.app/api/requests/$RID/analyze | jq
curl -s https://jansetu-ai-web-sooty.vercel.app/api/analytics/hotspots | jq .geojson.features[0]
curl -s -X POST https://jansetu-ai-web-sooty.vercel.app/api/copilot -H "Content-Type: application/json" -d '{"question":"Which projects fit within ₹10 Cr?"}' | jq