AlifZetta GSI · API Reference

Sovereign, sub-5ms answer API for Nepal. No RAG, no vector DB, no chain-of-thought — pure grounded structural intelligence with 18 live/curated handlers.

v1 · demo.axz.si · Public preview

Overview

Every query is routed through a fallthrough chain: smalltalk → semantic cache → emergency handler → 12 live/curated handlers → intent dispatch → curated KB (17.3M entries) → web fallback. First hit wins. Warm-path latency: P50 2ms · P95 3ms.

Live handlers12
Curated KB entries17.3M
Emergency cards16 · bilingual
Gold-eval pass rate177 / 177 · 100%
P50 warm latency2 ms
P95 warm latency3 ms

Answer endpoint

POST /api/gsi/answer

Route a free-text query to the most appropriate handler and return a structured answer.

Request

POST https://demo.axz.si/api/gsi/answer
Content-Type: application/json

{"query": "petrol price nepal"}

Response

{
  "answer_en":  "⛽ Nepal fuel prices — NOC reference (Kathmandu Valley retail)\n...",
  "grounded":   true,
  "source":     "fuel_handler",
  "match": {
    "id":         "fuel:petrol",
    "title":      "Petrol — NPR 175/litre",
    "category":   "curated_fuel",
    "score":      1800.0,
    "highlighted":"petrol",
    "prices_npr": { "petrol": {"unit":"litre","price":175.00,...}, ... }
  },
  "citations": [{"kind":"curated","source":"Nepal Oil Corporation (noc.org.np)",...}],
  "traversal_trace": ["fuel_handler: petrol"],
  "query_class": "live_handler",
  "compute_ms":  2.4,
  "_cache":      {"hit": false, "key": null},
  "_intent":     {"intent":"fuel","confidence":0.85,...}
}

Handlers

emergency_handler

16 bilingual first-aid cards (snake bite, heart attack, stroke, burn, drowning, choking, seizure, poisoning, fire, quake, flood, landslide, suicide, DV, child abuse).

weather_handler

Live weather for 15 Nepal cities via open-meteo. Bilingual card + advisory (heat, cold, thunder, wind, rain).

aqi_handler

US AQI + PM2.5 + PM10 via open-meteo. 6-level bilingual health advisory.

quake_handler

USGS earthquake feed filtered to Nepal region. Latest quake + 30-day totals + magnitude advisory.

news_handler

Top 8 bilingual headlines from Gorkhapatra + Kantipur + Nagarik + BBC Nepali + Setopati + Al Jazeera + NYT.

calendar_handler

AD ↔ BS date, weekday bilingual, Nepal fiscal year, Bikram Sambat panchang.

currency_handler

Live NPR conversion for USD/EUR/GBP/INR/AED/+9 via open.er-api.com (ECB daily).

holiday_handler

Next Nepal public holiday + all remaining this year (Dashain, Tihar, Buddha Jayanti, Chhath, etc).

distance_handler

Curated km + drive-time between top Nepal cities (KTM ↔ Pokhara, Chitwan, Biratnagar, etc).

geography_handler

Peaks (8 eight-thousanders), rivers (Koshi, Gandaki, Karnali, Bagmati, Mahakali), lakes (Rara, Phewa, Tilicho).

fuel_handler

NOC reference prices for petrol / diesel / kerosene / LPG cylinder.

metals_handler

FENEGOSIDA daily reference for gold (24k / 22k / worked) and silver, per tola + per 10g.

bank_handler

NRB policy rate + commercial bank savings / FD / home / auto / personal loan rates.

calculator

AST-based safe arithmetic (2+2, 2**10, sqrt, log, etc).

date_time

Current NPT + BS date + weekday.

smalltalk_guard

Handles greetings, name questions, capability probes bilingually.

curated_kb

17.3M keyword-indexed entries across ministries, services, culture, medical pathways.

web_fallback

Wikipedia + DuckDuckGo when no KB confidence — Nepal-context biased.

Auxiliary endpoints

GET /api/news/today

Structured JSON of today's Nepal news feed (up to 20 items from 13 sources). Refreshed every 30 min.

GET /api/cache/live/stats

Live-handler cache stats (hits, misses, hit-rate, active entries, TTL config).

GET /api/log/stats?hours=24

Query volume + P50/P95 latency + cache hit-rate for the rolling window.

GET /api/log/top?hours=168&limit=20

Top-N most-frequent queries.

GET /api/log/misroutes?hours=168&limit=20

Actionable KB-expansion targets: queries with low confidence + low volume.

GET /admin/analytics.html

Auto-refreshing analytics dashboard (24h volume, top queries, misroutes, coverage, cache stats).

POST /api/partner/search GET /api/partner/search?q=...

One call returns an AlifZetta engine answer (text, sources, confidence, source tier) plus web results (title, url, snippet). English and Nepali. Requires a partner key with scope search (or full) in the X-Partner-Key header. Keys are issued by padam@axz.si.

Server to server only. Call this from your backend. Never ship the key in a web page or a mobile app; browser CORS is not enabled for this endpoint.

Request

POST https://demo.axz.si/api/partner/search
X-Partner-Key: <your search key>
Content-Type: application/json

{"q": "who is the prime minister of Nepal", "lang": "auto", "limit": 5, "include_web": true, "safe": true}
FieldTypeDefaultNotes
qstringrequiredUp to 500 characters. query is accepted as an alias.
langen | ne | autoautoauto picks ne when the query contains Devanagari.
limitint 1 to 105Maximum web results.
include_webbooltruefalse returns the engine answer only (faster).
safebooltrueAccepted for forward compatibility. The abuse guard is always on.

GET takes the same fields as query parameters, for example /api/partner/search?q=capital%20of%20nepal&include_web=false.

Response

{
  "ok": true,
  "query": "who is the prime minister of Nepal",
  "lang": "en",
  "answer": {
    "text": "As of 2026, the Prime Minister of Nepal is Balen Shah, sworn in on 27 March 2026. ...",
    "sources": [{"title": "balen shah", "url": null}],
    "confidence": 0.99,
    "engine": "alifzetta-gsi",
    "tier": "canonical_query",
    "grounded": true,
    "status": "ok"
  },
  "web": [
    {"title": "Prime Minister of Nepal", "url": "https://en.wikipedia.org/wiki/Prime_Minister_of_Nepal", "snippet": "The Prime Minister of Nepal is the head of government ..."}
  ],
  "status": {"answer": "ok", "web": "ok"},
  "took_ms": 611,
  "request_id": "srch_2b6a442d36b1"
}

Each section reports its own status (ok, empty, timeout, error, skipped). If one source fails the other is still returned. Budgets: answer about 12 s, web about 8 s.

DTL v0.1 output

Send Accept: application/dtl or add ?format=dtl. The body is a signed DTL v0.1 document with header @DTL v0.1 | dom:dtSRCH | C0 | cs:<sha256> | prf:partner-search | ts:.... dtSRCH is a custom domain code (DTL v0.1 has no search domain); C0 because search results are public. The checksum is also in the X-DTL-CS response header.

Errors and quotas

HTTPerrorMeaning
400missing_query, query_too_long, invalid_lang, invalid_jsonFix the request.
401missing_partner_key, invalid_partner_keyHeader absent or key unknown.
403scope_not_allowedKey exists but is not a search key.
422content_policy_violationAbusive or unsafe query. A polite message in the request language is included.
429quota_exceededHourly quota used. Honour the Retry-After header (seconds).
503upstream_unavailableBoth the engine and web search failed. Retry with backoff.

Every response carries X-Request-Id. Successful responses carry X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset. Quotas are per key per clock hour; nginx also applies a per-IP burst limit.

Example

curl -sS -X POST https://demo.axz.si/api/partner/search \
  -H "X-Partner-Key: $AZ_SEARCH_KEY" -H 'Content-Type: application/json' \
  -d '{"q":"नेपालको प्रधानमन्त्री को हुन्?","lang":"ne","limit":3}' | jq

Example curls

# Emergency (safety-critical, highest score)
curl -sS -X POST https://demo.axz.si/api/gsi/answer \
  -H 'Content-Type: application/json' \
  -d '{"query":"snake bite emergency"}' | jq

# Live weather (any of 15 Nepal cities, bilingual)
curl -sS -X POST https://demo.axz.si/api/gsi/answer \
  -H 'Content-Type: application/json' \
  -d '{"query":"पोखराको मौसम"}' | jq

# Currency (100 USD → NPR)
curl -sS -X POST https://demo.axz.si/api/gsi/answer \
  -H 'Content-Type: application/json' \
  -d '{"query":"100 usd in npr"}' | jq

Design principles