AI agents & LLM apps
Language models hallucinate numbers. If your assistant answers questions about Pakistan's economy, such as "what's the latest inflation?", "how have remittances trended?" or "what's KIBOR today?", give it PakDataHub as a tool, so every figure comes from the official source with a date attached.
Two tools are enough
Most agents need only search and fetch:
[
{
"name": "search_pakistan_series",
"description": "Find PakDataHub series ids for a Pakistan economic/financial concept (e.g. 'cpi', 'kibor', 'remittances saudi', 'raast').",
"input_schema": { "type": "object", "properties": { "q": { "type": "string" } }, "required": ["q"] }
},
{
"name": "get_pakistan_series",
"description": "Get observations for a PakDataHub series id. Returns dated values from the official source (SBP/PBS/PTA/MUFAP).",
"input_schema": { "type": "object", "properties": {
"series_id": { "type": "string" },
"from": { "type": "string", "description": "YYYY-MM-DD" },
"transform": { "type": "string", "enum": ["yoy", "mom", "pct_change", "3ma", "index"] },
"limit": { "type": "integer" } }, "required": ["series_id"] }
}
]
Implement them as two HTTP calls:
import httpx
H = {"X-API-Key": "pk_live_xxx"}
B = "https://api.pakdatahub.com/v1"
def search_pakistan_series(q):
return httpx.get(f"{B}/search", params={"q": q, "limit": 8}).json()["data"]
def get_pakistan_series(series_id, **params):
params.setdefault("limit", 24)
r = httpx.get(f"{B}/series/{series_id}", params=params, headers=H).json()
return {"meta": r["meta"], "data": r["data"]}
Add /v1/funds/screener for mutual-fund questions and /v1/commodities/by-city for prices by city.
Grounding the model in the docs
https://pakdatahub.com/llms.txtis the overview plus one-line answers.https://pakdatahub.com/docs/llms.txtindexes every docs page.https://pakdatahub.com/llms-full.txtholds all the docs in one file, ready for a system prompt or RAG index.- Append
.mdto any docs URL for the raw Markdown. https://pakdatahub.com/AGENTS.mdhas instructions written for agents.
Prompting tips
- Tell the model to always call the tool for numbers, and to state the
dateandmeta.sourceit got back. - Ids are stable, so you can cache common ones (e.g.
inflation.cpi.national.yoy,fx.rate.avg.usd,rates.kibor.3m) in the system prompt to save a search call. - PSX stock prices are out of scope. Route those questions to pypsx.com.