… وَالصَّبْرُ أَصْلُهُ الْحَبْسُ، وَثَوَابُهُ غَيْرُ مُقَدَّرٍ، وَقَدْ تَقَدَّمَ. لَكِنْ لَا يَكُونُ ذَلِكَ إِلَّا بِالصَّبْرِ عِنْدَ الصَّدْمَةِ الْأُولَى، كَمَا رَوَى الْبُخَارِيُّ عَنْ أَنَسٍ عَنِ النَّبِيِّ ﷺ قَالَ: (إِنَّمَا الصَّبْرُ عِنْدَ الصَّدْمَةِ الْأُولَى). وَأَخْرَجَهُ مُسْلِمٌ أَتَمَّ مِنْهُ، أَيْ إِنَّمَا الصَّبْرُ الشَّاقُّ عَلَى النَّفْسِ الَّذِي يَعْظُمُ الثَّوَابُ عَلَيْهِ إِنَّمَا هُوَ عِنْدَ هُجُومِ الْمُصِيبَةِ وَحَرَارَتِهَا
Building blocks for Islamic AI. Answers in the scholars’ own words.
Agentic search, extraction, chunking and retrieval over thirteen centuries of tafsir. Every result is a passage a scholar wrote: word for word, cited to the volume and page.
-
Round 1 · searches the model wrote1 of 3
- keywordإنا لله وإنا إليه راجعون
- keywordالصبر عند المصيبة
- semanticpatience at the first shock of loss
- semanticand your own words, as asked
Merged and ordered against your question, not the model’s searches
Do these passages answer it? Yes. Stopped after one round.
The model wrote three searches and one word: yes. The answer is the scholars’.
ثم بيَّن تعالى من الصابرين الذين شكرهم فقال: ﴿الَّذِينَ إِذَا أَصَابَتْهُمْ مُصِيبَةٌ قَالُوا إِنَّا لِلَّهِ وَإِنَّا إِلَيْهِ رَاجِعُونَ (١٥٦)﴾ أي: تسلَّوا بقولهم هذا عما أصابهم، وعلموا أنهم مُلك لله يتصرف في عبيده بما يشاء، وعلموا أنه لا يضيع لديه مثقال ذرة يوم القيامة
The model asks. The scholars answer.
A model writes searches in Arabic and English, reads what comes back and judges whether it’s enough, in at most three rounds. What your user reads is never its prose.
{ "\u064b": { "\u064c": 1503, "\u064d": "تفسير ابن كثير - ط ابن الجوزي", … }, "\u0659": { "\u0660": [ … ] }, "pages": [ … { "text": "… <span id=\"aya-163\"> </span>\n\n<span id=\"aya-164\"> </span>ثم بيَّن تعالى من الصابرين الذين شكرهم فقال: ﴿الَّذِينَ إِذَا أَصَابَتْهُمْ مُصِيبَةٌ …﴾ … أمنة من العذاب (^٢). …", "vol": "2", "page": 22 } ] }
{ "id": "1503000934", "book": { "id": 1503, "name": "تفسير ابن كثير - ط ابن الجوزي" }, "author": { "name": "ابن كثير", "died": 774 }, "vol": "2", "page": 22, "pageEnd": 22, "ayahs": { "surah": 2, "from": 156, "to": 157 }, "text": "ثم بيَّن تعالى من الصابرين الذين شكرهم فقال: ﴿الَّذِينَ إِذَا أَصَابَتْهُمْ مُصِيبَةٌ …﴾ … أمنة من العذاب. …", "notes": null }
Every word as published. Nothing else.
The books arrive with scrambled fields, markup and an editor’s pages mixed in. What leaves is the author’s text, with its volume and printed page.
Cut where the scholar paused, not where the tokenizer did.
152,783 passages from the first 25 tafsirs, each mapped to the ayahs it explains. Bars show letters used, of the 1,200 a passage may hold.
Arabic-aware hybrid search.
Built for the way Arabic is written and typed: with and without harakat, with every form of hamza, with و and ال fused to the word.
On the shelf
Thirteen centuries of commentary, from the students of Ibn ʿAbbas to the twentieth century, decoded and ready to retrieve.
Ship with confidence. Here, a wrong answer is a misquote.
A chatbot that paraphrases a tafsir puts words in a scholar’s mouth. So we didn’t make hallucination unlikely. We left it nowhere to happen.
Accurate answers, by construction.
Results are passages, never paraphrases. Search returns the scholar’s text exactly as published. Agentic search lets a model write search terms and a yes-or-no verdict, and nothing your users read.
Citations to the page.
Book, edition, author and year of death, volume and printed page, the headings above the passage and the ayahs it explains. On every result, in fields your UI can render.
- Author
- القرطبي · d. 671 AH
- Edition
- تحقيق: أحمد البردوني وإبراهيم أطفيش
- Under
- تفسير سورة البقرة › [سورة البقرة (٢): آية ١٥٥]
- Explains
- Al-Baqarah 2:155
Filters that think in ayahs.
Narrow a search to a surah or a single ayah, to chosen books, authors or disciplines. Filters hold in keyword and meaning search alike.
Script, sense and the printed page.
Type it the way people type; get the ayah back in mushaf script. Ask in English and land on Arabic passages. And 214 of the 275 editions come with page scans.
The ayah is the address.
One GET returns what every tafsir says about an ayah, who says it and how much: paged, and cached at the edge. Most traffic never needs a search.
- مفاتيح الغيب · الفخر الرازي7 passages
- تفسير البغوي · البغوي6 passages
- المحرر الوجيز · ابن عطية5 passages
- فتح القدير · الشوكاني5 passages
- تفسير القرآن العظيم · ابن كثير4 passages
Built for developers. JSON in, scholarship out.
A small HTTP API with no SDK to learn. Plug it into your agent through MCP or the AI SDK, and keep whichever model you trust.
Tafsir first. The same pipeline reads turath’s whole catalog, 8,609 books across 40 disciplines; hadith commentaries and the Qur’anic sciences are next.
MCP server
Hand Claude, Cursor or any MCP client a library card. Four tools: search, ayah lookup, surrounding context and the catalog.
{
"mcpServers": {
"bayan-library": {
"url": "https://library.getbayan.app/mcp"
}
}
}AI SDK
One tool and your agent can consult Ibn Kathir. Passages come back with ids and page numbers, so every claim can point at its source.
import { streamText } from "ai";
import { bayanLibrary } from "@bayan/library/ai";
const result = streamText({
model, // any provider
tools: bayanLibrary(),
prompt: "What do the mufassirun say on 2:156?",
});Model agnostic
Open models on the edge by default. Swap the embedder, the reranker or the model behind agentic search, or bring your own through MCP.
Adab, enforced in code. Our principles fail the build.
Most products promise accuracy in a brochure. Ours are written as hard rules, and the rules have tests.
The scholars speak. We don’t.
No model writes anything a person is shown as an answer. In agentic search it writes search terms and a verdict; the passages are the answer.
Agentic search returns passages, never proseNot one word changed.
Cleaning removes markup, never words. Harakat, spellings and the editor’s [brackets] are kept exactly as printed.
Every book’s text compared letter for letterOnly the author’s pages.
Editors’ introductions, indexes and printers’ notes stay out of the index. Footnotes are kept, and served only when you ask.
Every exclusion listed for a person to checkYour users’ questions are theirs.
Logs carry timings, counts and kinds of failure. Never a query, never a word a model wrote.
A test reads every log lineA year of Arabic NLP,
or one request.
Everything on the right is a problem we met in real books, measured, and wrote tests for.
With Bayan Library
One request. Cited passages back.
- One API for any ayah, question or phrase
- Hybrid Arabic search: stems, phrases, meaning, reranking
- Every passage mapped to the ayahs it explains
- Citations to volume and printed page
- Agentic search with nothing to hallucinate
- Edge caching, rate limits and logs that keep no queries
Building it yourself
Months, if it goes well.
- Reverse-engineer field names scrambled into diacritics
- Normalise harakat, hamza seats, alif maqsura and ta marbuta
- Write a stemmer that leaves the name of Allah whole
- Chunk without cutting an ayah in half
- Map passages to ayahs across five styles of heading
- Tell the editor’s words from the author’s
- Explain why your chatbot misquoted Ibn Kathir
Frequently asked.
Anything else, ask us. We answer in our own words.
What is Bayan Library?
Retrieval infrastructure for Islamic apps. The classical tafsir, decoded, cleaned, cut into passages, mapped to the ayahs they explain and indexed for keyword and meaning search, behind a small JSON API, an MCP server and an AI SDK tool.
Does an AI write the answers?
No. Every result is a scholar’s passage, word for word, with its book, volume and page. In agentic search a model writes search terms and judges whether the passages found speak to the question. It never writes the answer, so there is nothing of ours to fact-check.
Which books are in the library?
Tafsir first: the 275 works in turath.io’s tafsir catalog, from Mujahid ibn Jabr (d. 104 AH) and Qatada through at-Tabari, al-Qurtubi and Ibn Kathir to the modern commentaries. Hadith commentaries and the Qur’anic sciences follow on the same pipeline.
Can people ask in English?
Yes. Meaning search uses multilingual embeddings, so an English question can find Arabic passages, and keyword search joins in whenever the query has Arabic letters. Passages always come back in the Arabic their authors wrote. Translating them is your decision, made openly.
How exact are the citations?
Each passage carries its book and edition line, its author and year of death, the volume, first and last printed page, the headings it sits under and the ayahs it explains. Enough to find it on the printed page.
Can I narrow a search?
Filter by surah or a single ayah, and by books, authors or discipline, in any mode: keywords, meaning, or both together (the default).
Is it tied to one model?
No. It runs on open models on Cloudflare’s edge by default: bge-m3 for meaning, a cross-encoder for reranking, Gemma or Llama for agentic search. Each layer can be swapped, and your own agent can use any model through MCP or the AI SDK.
What about the editors’ work?
Only the author’s text is indexed. Modern editors’ introductions, indexes and printers’ notes are left out, every exclusion is listed for review, and footnotes, which are the editor’s words, are served only on request.
Let the scholars speak in your app.
Bayan means clear speech. Give your users the clearest voices of the tradition: unedited, cited, one request away.