Skip to content
Retrieval for Islamic apps

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.

275 works of tafsir675,049 pagesFrom Mujahid ibn Jabr, d. 104 AH

What do the scholars say about patience when someone dies?
Searching the tafsir
  1. Round 1 · searches the model wrote1 of 3
    • keywordإنا لله وإنا إليه راجعون
    • keywordالصبر عند المصيبة
    • semanticpatience at the first shock of loss
    • semanticand your own words, as asked
  2. Merged and ordered against your question, not the model’s searches

  3. Do these passages answer it? Yes. Stopped after one round.

The model wrote three searches and one word: yes. The answer is the scholars’.

What your user reads2 of 10 passages
الجامع لأحكام القرآنal-Qurtubi · d. 671 AH
Al-Baqarah 2:155

… وَالصَّبْرُ أَصْلُهُ الْحَبْسُ، وَثَوَابُهُ غَيْرُ مُقَدَّرٍ، وَقَدْ تَقَدَّمَ. لَكِنْ لَا يَكُونُ ذَلِكَ إِلَّا بِالصَّبْرِ عِنْدَ الصَّدْمَةِ الْأُولَى، كَمَا رَوَى الْبُخَارِيُّ عَنْ أَنَسٍ عَنِ النَّبِيِّ ﷺ قَالَ: (إِنَّمَا الصَّبْرُ عِنْدَ الصَّدْمَةِ الْأُولَى). وَأَخْرَجَهُ مُسْلِمٌ أَتَمَّ مِنْهُ، أَيْ إِنَّمَا الصَّبْرُ الشَّاقُّ عَلَى النَّفْسِ الَّذِي يَعْظُمُ الثَّوَابُ عَلَيْهِ إِنَّمَا هُوَ عِنْدَ هُجُومِ الْمُصِيبَةِ وَحَرَارَتِهَا

تفسير القرطبي ٢/ ١٧٤vol. 2, p. 174
تفسير القرآن العظيمIbn Kathir · d. 774 AH
Al-Baqarah 2:156–157

ثم بيَّن تعالى من الصابرين الذين شكرهم فقال: ﴿الَّذِينَ إِذَا أَصَابَتْهُمْ مُصِيبَةٌ قَالُوا إِنَّا لِلَّهِ وَإِنَّا إِلَيْهِ رَاجِعُونَ (١٥٦)﴾ أي: تسلَّوا بقولهم هذا عما أصابهم، وعلموا أنهم مُلك لله يتصرف في عبيده بما يشاء، وعلموا أنه لا يضيع لديه مثقال ذرة يوم القيامة

تفسير ابن كثير ٢/ ٢٢vol. 2, p. 22

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.

On the shelf

Thirteen centuries of commentary, from the students of Ibn ʿAbbas to the twentieth century, decoded and ready to retrieve.

تفسير مجاهدمجاهد بن جبر · ت ١٠٤ هـ
تفسير قتادةقتادة بن دعامة السدوسي · ت ١١٧ هـ
تفسير مقاتل بن سليمانمقاتل · ت ١٥٠ هـ
تفسير سفيان الثوريسفيان الثوري · ت ١٦١ هـ
جامع البيانابن جرير الطبري · ت ٣١٠ هـ
معاني القرآن وإعرابهالزجاج · ت ٣١١ هـ
تفسير ابن أبي حاتمابن أبي حاتم · ت ٣٢٧ هـ
الكشف والبيانالثعلبي · ت ٤٢٧ هـ
النكت والعيونالماوردي · ت ٤٥٠ هـ
لطائف الإشاراتعبد الكريم القشيري · ت ٤٦٥ هـ
الوجيزالواحدي · ت ٤٦٨ هـ
تفسير السمعانيأبو المظفر السمعاني · ت ٤٨٩ هـ
تفسير البغويالبغوي · ت ٥١٦ هـ
الكشافالزمخشري · ت ٥٣٨ هـ
المحرر الوجيزابن عطية · ت ٥٤٢ هـ
زاد المسير في علم التفسيرابن الجوزي · ت ٥٩٧ هـ
مفاتيح الغيبالفخر الرازي · ت ٦٠٦ هـ
تفسير العز بن عبد السلامعز الدين بن عبد السلام · ت ٦٦٠ هـ
الجامع لأحكام القرآنالقرطبي · ت ٦٧١ هـ
أنوار التنزيل وأسرار التأويلناصر الدين البيضاوي · ت ٦٨٥ هـ
مدارك التنزيل وحقائق التأويلأبو البركات النسفي · ت ٧١٠ هـ
التسهيل لعلوم التنزيلابن جزي الكلبي · ت ٧٤١ هـ
لباب التأويل في معاني التنزيلالخازن · ت ٧٤١ هـ
البحر المحيط في التفسيرأبو حيان الأندلسي · ت ٧٤٥ هـ
تفسير القرآن العظيمابن كثير · ت ٧٧٤ هـ
تفسير الجلالينجلال الدين المحلي · ت ٨٦٤ هـ
الجواهر الحسانأبو زيد الثعالبي · ت ٨٧٥ هـ
الدر المنثور في التفسير بالمأثورالجلال السيوطي · ت ٩١١ هـ
إرشاد العقل السليمأبو السعود · ت ٩٨٢ هـ
فتح القديرالشوكاني · ت ١٢٥٠ هـ
روح المعانيشهاب الدين الألوسي · ت ١٢٧٠ هـ
التحرير والتنويرابن عاشور · ت ١٣٩٣ هـ
أضواء البيانمحمد الأمين الشنقيطي · ت ١٣٩٣ هـ
275works of tafsir in the corpus, the oldest from 104 AH
152,783passages cut from the first 25, each one cited
6,236of 6,236 ayahs mapped in Ibn Kathir, al-Baghawi and ar-Razi
0words of any answer written by a model
Ship with confidence

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.

The model wroteإنا لله وإنا إليه راجعونpatience at the first shock of lossyes
Your user readsإِنَّمَا الصَّبْرُ الشَّاقُّ عَلَى النَّفْسِ الَّذِي يَعْظُمُ الثَّوَابُ عَلَيْهِ إِنَّمَا هُوَ عِنْدَ هُجُومِ الْمُصِيبَةِ وَحَرَارَتِهَا
Words of that answer a model wrote0

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.

SurahAl-Baqarah Ayah156 Ibn Kathir al-Qurtubi al-Baghawi at-Tabari DisciplineTafsir
filter: { surah: 2, ayah: 156, books: [1503, 20855] }

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.

Mushafٱلَّذِينَ إِذَآ أَصَٰبَتۡهُم مُّصِيبَةٞ قَالُوٓاْ إِنَّا لِلَّهِ وَإِنَّآ إِلَيۡهِ رَٰجِعُونَ ١٥٦
As typedالذين إذا أصابتهم مصيبة قالوا إنا لله وإنا إليه راجعون
In English · Saheeh InternationalWho, when disaster strikes them, say, "Indeed we belong to Allāh, and indeed to Him we will return."

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.

GET/v1/tafsir/2/156
  • مفاتيح الغيب · الفخر الرازي7 passages
  • تفسير البغوي · البغوي6 passages
  • المحرر الوجيز · ابن عطية5 passages
  • فتح القدير · الشوكاني5 passages
  • تفسير القرآن العظيم · ابن كثير4 passages
15 of the first 25 tafsirs explain 2:156.
Built for developers

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.

NowNext

          
        
200 OKResponse

        

MCP server

Hand Claude, Cursor or any MCP client a library card. Four tools: search, ayah lookup, surrounding context and the catalog.

search_librarytafsir_for_ayahpassage_contextlist_books
{
  "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.

Embed
bge-m3EmbeddingGemma 2Qwen3 Embedding
Rerank
bge-rerankerCohere Rerank
Reason
Gemma 4Llama 4 ScoutClaudeGPTGeminiMistralDeepSeek
Principles

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.

01
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 prose
02
Not 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 letter
03
Only 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 check
04
Your 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 line
Why not build it?

A 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
Questions

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.

عَلَّمَهُ ٱلۡبَيَانَ ٤ [And] taught him eloquence. Ar-Rahman 55:4 · Saheeh International

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.