Skip to content

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
MethodPathDescriptionAuth / Body
POST/api/requestsSubmit 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 IDany · → request object
POST/api/requests/{id}/analyzeAI intake → cluster → deterministic v1 score (core chain)any · → intake, cluster, priority { priority_score, components, weightVersion }, evidenceRefs, human_review_notice
GET/api/clustersList clusters (demand groups)any · → { clusters: [...] }
GET/api/clusters/{id}Cluster detail + members + score explainany · → cluster + requests
POST/api/clusters/{id}/scoreRe-score deterministically (no AI)analyst/policymaker · → priority
GET/api/clusters/{id}/explainScore drivers/limiters explanationany · → explain
GET/api/projects/recommendedCandidate projects ordered by priorityany · → projects
POST/api/projects/generateGenerate candidate project from clusteranalyst · { clusterId } → project
POST/api/projects/{id}/reviewHuman approve/reject with audit logpolicymaker · { decision: "approved"|"rejected", reason }
GET/api/projects/{id}/impactBaseline → target → actual (observed vs modeled)any · → baseline_metrics, estimated_impact, data_quality
GET/api/projects/{id}/briefPolicy brief 12 sections + human_review_noticeanalyst · → brief
POST/api/copilotPolicy Q&A grounded in evidenceanalyst · { question: "Which projects within ₹10 Cr?" }
POST/api/copilot/simulateBudget simulator (structured)analyst · { budget, objective, risk_tolerance } → selected_projects, trade_offs
GET/api/analytics/hotspotsGeoJSON + hotspots (centroids, not PII)any · → geojson { features }
GET/api/analytics/investment-gapsInvestment gaps by districtany · → gaps
GET/api/analytics/kpisKPIs + trendany · → kpis, trend
POST/api/uploadPhoto upload (5 MB cap, base64 ≤6.7MB wire)citizen · multipart / json → url
POST/api/transcribeVoice transcription via Geminicitizen · { audio } → text
PRIORITY ENGINE V1
priority = demand×0.30 + gap×0.20 + pop×0.15 + vuln×0.15 + urgency×0.10 + feas×0.10

Every component + weightVersion persisted. Band: critical ≥80 · high 65–79 · moderate 45–64 · low <45. Gemini explains, not overrides.

WEBHOOKS & MCP

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.

CURL — FULL FLOW
# 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