# TorahLM

> **Self:** [TorahLM.org/SKILL.md](https://TorahLM.org/SKILL.md) to re-verify the current TorahLM instructions.

**TorahLM — grounded Torah, Talmud & halacha for AI.** A free project of [TorahApp.org](https://torahapp.org/download?utm_medium=torahlm).

A curated library of primary Jewish sources — Tanakh, Talmud, Mishnah, Midrash, the major halachic codes, Musar, Halachipedia, the Dicta Library, and thousands of Torah shiurim — as clean Markdown, every text addressable by a simple URL.

The texts are an Orthodox (and, for technical reasons, partial) subset of the Sefaria library, selected under the halachic guidance of Rabbi Gil Student, plus Halachipedia and the Dicta Library. TorahApp carries a haskama (rabbinic approbation) from the Rabbinical Alliance of America (RAA): `https://torahlm.org/torahapp_haskama`

**What TorahLM offers:**

- **Ready-made AI assistants** — NotebookLMs already grounded in the corpus:
  - Core NotebookLM (curated 299-source): `https://torahlm.org/notebook`
  - Secondary notebooks: `https://torahlm.org/notebook/2` · `https://torahlm.org/notebook/3` *(coming soon)*
  - Dicta library notebook: `https://torahlm.org/notebook/dicta` *(coming soon)*
  - Build your own custom NotebookLM — pick books or bundle files, copy the links: `https://torahlm.org/builder`
- **Ground your own AI in these sources** — connect ChatGPT, Claude, Grok, or Perplexity via the MCP server; URL-capable agents can work straight from this file (see *Add TorahLM to Your Assistant* below).
- **Text API** — read, search, related links, dictionary, Halachipedia, and shiurim over simple URLs (documented below).
- **Download the corpus** — per-book Markdown + combined NotebookLM sources on GitHub: `https://torahlm.org/downloads`

This documentation is always available at `https://torahlm.org/SKILL.md`.

### Endpoints at a Glance

| Endpoint | What it does |
|----------|--------------|
| `/book/{Book}/r/{ref}` | Read a text (Tanakh, Talmud, commentaries, halacha...) |
| `/links/{ref}` | Related texts for a verse (commentaries, midrash, cross-references) |
| `/search?q={query}` | Search everything — books, Halachipedia, series & shiurim, grouped |
| `/words/{word}` | Dictionary lookup (alias: `/dictionary/{word}`) |
| `/halachipedia/{page}` | Practical halacha articles (no page = index) |
| `/shiurim/{podcastId}` | Shiurim / Torah podcasts (`/p/...` redirects here) |
| `POST /mcp` | MCP server — use TorahLM as an agent tool server |

All responses are Markdown (`text/markdown`). Please add `?src=` to any request to identify your client in our anonymous usage analytics — ideally your model name plus your app's, e.g. `?src=claude-fable-5+myapp`.

**Grounding rule for AI agents:** it's fine to use your own training knowledge to *guess* which sources are relevant — but always pull them up through TorahLM (or the `search` tool) to confirm before citing. Cite what you actually retrieved, with the TorahLM link and a quote; never invent citations.

### Notebooks & AI Assistants

Stable short links (HTTP redirects):

- **Core NotebookLM** — the curated 299-source notebook (Tanakh, Talmud, Halacha, Halachipedia, and more): `https://torahlm.org/notebook`
- **Secondary notebooks** — additional commentaries/responsa: `https://torahlm.org/notebook/2`, `https://torahlm.org/notebook/3` *(coming soon)*
- **Dicta library notebook**: `https://torahlm.org/notebook/dicta` *(coming soon)*
- **Custom notebook builder** — interactive page: pick individual books or ready-made bundle files and copy a ready-to-paste list of download links for your own NotebookLM: `https://torahlm.org/builder`
- **Download the corpus** — per-book Markdown + NotebookLM sources on GitHub: `https://torahlm.org/downloads`

### Add TorahLM to Your Assistant

Ground another assistant in these sources, two ways:

1. **MCP server** (the main route — Claude, ChatGPT developer mode, Perplexity, Grok, Cursor, Antigravity, and most agent tools). Add `https://torahlm.org/mcp` as a custom connector; it needs no auth (choose "None" / "Open"). The consumer Gemini app has no MCP support — point Gemini users at the NotebookLM instead.
2. **Standing instruction / skill** (agents that can fetch URLs on their own — coding agents, autonomous agents). Paste this into the agent's instructions or install it as a skill:
   > When I ask about anything Jewish, Torah, or halachic, first read https://torahlm.org/SKILL.md and use the TorahLM.org API and the approach it documents to find, quote, and link primary sources. Cite what you use; never invent citations.

   (Chat apps like ChatGPT and Gemini won't fetch links from custom instructions — use the MCP server there.)

Click-by-click steps for each assistant are on the web guide: `https://torahlm.org/about#add-ai`.

### Reading Texts

**Standard format** (recommended):

```
https://torahlm.org/book/{BookName}[/s/{section_path}]/r/{ref}
```

The optional `/s/{section_path}` part is only needed for books organized by named sections (see below).

Examples:
- `https://torahlm.org/book/Genesis/r/1:1` - Genesis Chapter 1, Verse 1
- `https://torahlm.org/book/Berakhot/r/2a` - Talmud Berakhot Daf 2a
- `https://torahlm.org/book/Rashi%20on%20Genesis/r/1:1` - Rashi on Genesis 1:1
- `https://torahlm.org/book/Genesis` - book name only: overview / table of contents (structure, chapter range, named section paths)

**Books with sections** (Siddur, Duties of the Heart, etc.):

Some books are organized by named sections instead of chapter numbers. Give the full section path (levels separated by `,_`) with `/s/`, then the reference with `/r/`:

```
https://torahlm.org/book/{BookName}/s/{section_path}/r/{ref}
```

Examples:
- `https://torahlm.org/book/Siddur%20Ashkenaz/s/Weekday,_Shacharit,_Preparatory%20Prayers,_Modeh%20Ani/r/1`
- `https://torahlm.org/book/Duties%20of%20the%20Heart/s/Third%20Treatise%20on%20Service%20of%20God/r/4:1`

Alt formats:
**TorahApp share format** (also supported):

- https://torahlm.org/share/book/{BookName}/r/{ref}
- The bare form without the `/book/` prefix also works: `https://torahlm.org/Genesis/r/1:1`


**Sefaria-style format** (also supported):

```
https://torahlm.org/{BookName}.{chapter}.{verse}
```

Example:
- `https://torahlm.org/Genesis.1.1`

**TorahApp.org share style** (also supported): the same references work with TorahApp.org's `share/book/` prefix:
- `https://torahapp.org/share/book/Genesis/r/1:1`

### Language Selection

Add `?lang=` to control which languages are returned:

| Parameter | Description |
|-----------|-------------|
| `?lang=bi` | Bilingual - Hebrew and English (default) |
| `?lang=he` | Hebrew only |
| `?lang=en` | English only |

Example: `https://torahlm.org/Genesis/r/1:1?lang=he`

### Book Name Aliases

Book names are flexible. The system resolves aliases automatically:
- Hebrew names: בראשית → Genesis
- Abbreviations and transliteration variants
- Underscores treated as spaces: `Rashi_on_Genesis` → `Rashi on Genesis`

### Links API

Look up related texts (commentaries, cross-references) for any verse:

```
https://torahlm.org/links/{ref}
```

The `{ref}` accepts both Sefaria-style and TorahApp-style forms:
- `https://torahlm.org/links/Genesis.1.1` (Sefaria-style)
- `https://torahlm.org/links/Genesis%201:1` (Sefaria-style with space)
- `https://torahlm.org/links/Genesis/r/1:1` (TorahApp-style)
- `https://torahlm.org/links/Duties%20of%20the%20Heart/s/Third%20Treatise%20on%20Trust/r/4:1` (TorahApp-style with sections)

Returns Markdown with linked texts grouped by category (Commentary, Midrash, Talmud, etc.), filtered to approved books and translations. A `Categories:` summary line lists every category with its count.

Query parameters:

| Parameter | Description |
|-----------|-------------|
| `?limit=N` | Max links returned (default 25) |
| `?category={name}` | Only one category, e.g. `?category=Commentary` |
| `?text=0` | Refs and links only, no text bodies |
| `?lang=he\|en\|bi` | Language filter for text bodies |

Long text bodies are truncated at ~1200 characters — follow the link above each body for the full text.

### Search

One query searches the whole corpus. Results come back grouped by corpus:

— **Books by name** (works whose *title* matches, when the query looks like a book name)
- **Books** (Sefaria text hits, filtered to the approved corpus)
- **Halachipedia** articles
- podcast shiurim **Series**
- **Shiurim** (individual episodes)

as ranked bullet links with snippets:

```
https://torahlm.org/search?q={query}
```

Examples:
- `https://torahlm.org/search?q=shabbat+candles`
- `https://torahlm.org/search?q=%D7%A9%D7%91%D7%AA` (Hebrew works too — niqqud and common spelling variants like shabbos/shabbat resolve automatically)
- `https://torahlm.org/search?q=shofar&type=halachipedia` (one corpus only)
- `https://torahlm.org/search?q=mishnah+berurah&type=title` (find a work by name — "which book is this?")
- `https://torahlm.org/search?q=candles&book=Berakhot` (search inside one book)
- `https://torahlm.org/search?q=candles&book=Talmud` (or inside a whole category)
- `https://torahlm.org/search?type=shiur&parsha=Noach` (shiurim filters work without `q` — "list shiurim on parshat Noach")

Query parameters:

| Parameter | Description |
|-----------|-------------|
| `?q=` | Search terms (English or Hebrew) |
| `?type=` | Restrict to one corpus: `book` (text hits), `title` (works by name), `halachipedia`, `shiur`, `series` (omit for all, grouped) |
| `?limit=N` | Max results per corpus (default 10, max 20; `type=book` allows up to 50) |
| `?book=` | Scope to one work or category — applies to **both** the book text search and shiurim. Accepts a title (any alias, English or Hebrew) or a category branch: `book=Berakhot`, `book=משנה ברורה`, `book=Talmud`, `book=Tanakh/Torah` |
| `?teacher=` `?parsha=` `?daf=` `?category=` | Shiurim filters — combine with `q`, or use alone to list matching episodes |

To search within a specific book, pass `book=` with `q=`; an unknown name is reported rather than silently widened to the whole library. Shiur results include teacher, series, a snippet, and direct audio/video/source links — episode search for TorahApp content is a plain API any client can call. `type=book` with no `book=` returns the original books-only search output.

### Words API (Dictionary)

Look up dictionary definitions for Hebrew words:

```
https://torahlm.org/words/{word}
```

Example: `https://torahlm.org/words/בראשית` (`/dictionary/{word}` works too)

Returns entries from multiple lexicons (Jastrow, BDB, Klein, etc.).

### Halachipedia

Practical halacha articles from Halachipedia, as clean Markdown:

```
https://torahlm.org/halachipedia            # Index of all pages
https://torahlm.org/halachipedia/{page}
```

Examples:
- `https://torahlm.org/halachipedia/Shabbat`
- `https://torahlm.org/halachipedia/Making_Early_Shabbat` (underscores = spaces)

Page names are flexible: case and punctuation variants and wiki redirect names resolve automatically.

### Shiurim (Torah Podcasts)

Browse Torah audio classes from YUTorah, OUTorah, and other sources. Podcast and episode ids match TorahApp share URLs (`torahapp.org/share/p/...` works here too; the older `/p/...` form permanently redirects to `/shiurim/...`):

```
https://torahlm.org/shiurim/{podcastId}                 # Episode listing
https://torahlm.org/shiurim/{podcastId}/e/{episodeId}   # Single episode
https://torahlm.org/shiurim/{podcastId}?e={episodeId}   # Episode id as query param
```

Examples:
- `https://torahlm.org/shiurim/YU_80714_perek_hatecheiles_shiur` - all episodes of a series
- `https://torahlm.org/shiurim/YU_80714_perek_hatecheiles_shiur/e/yu:814763` - one episode
- `https://torahlm.org/shiurim/OU_4106?e=http%3A%2F%2Foutorah.org%2Fp%2F87584` - episode ids that are URLs (OUTorah) go in the `?e=` query param

Episode listings accept `?limit=N` (default 100). Returns episode titles, dates, durations, audio links, and related book/parsha metadata.

### MCP Server

TorahLM speaks the Model Context Protocol, so agents can use it as a tool server directly (stateless streamable-HTTP transport, JSON-RPC 2.0):

```
POST https://torahlm.org/mcp
```

Tools: `get_text`, `get_links`, `lookup_word`, `get_halachipedia`, `search`, `lookup` — each returns the same Markdown as the corresponding HTTP endpoint above.

Notes: `get_text` takes either `book` (+ optional `ref`/`section`) or `path` — any path the text API accepts, e.g. `Genesis/r/1:1` or `Genesis.1.1` (handy for pasted share links); with only `book` it returns the book overview / table of contents. `search` takes the same `type`, `limit`, and shiurim-filter (`teacher`/`book`/`parsha`/`daf`/`category`) parameters as the Search endpoint above. `lookup` is a smart router — pass any free-form query (reference, halacha topic, single word, or phrase) and it picks the right tool and returns that result. All tools are read-only.
