# 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, 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 |
|----------|--------------|
| `/md/book/{Book}/r/{ref}` | Read a text (Tanakh, Talmud, commentaries, halacha...) |
| `/md/search?q={query}` | Search everything — books, Halachipedia, series & shiurim, grouped |
| `/md/word/{word}` | Dictionary lookup |
| `/md/halachipedia/{page}` | Practical halacha articles (no page = index) |
| `/md/shiurim/{podcastId}` | Shiurim / Torah podcasts |
| `/md/calendar?date={YYYY-MM-DD}` | Hebrew date, holidays, Torah reading with aliyot, daily learning (Daf Yomi...) |
| `/md/zmanim?place={town or ZIP}` | Zmanim at a place, with the time there now and the time until each |
| `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`.

### Three representations: `/md/`, `/json/`, and `/web/`

Every resource URL starts with a representation: `/md/` for Markdown,
`/json/` for structured JSON, or `/web/` for an HTML page for humans. The
resource path after it is identical, for example `/md/book/Genesis/r/1:1`,
`/json/book/Genesis/r/1:1`, and `/web/book/Genesis/r/1:1`.

JSON answers `{ "kind", "apiVersion", "url", "data" }`, or
`{ "kind": "error", "apiVersion", "status", "message" }`. Book text and search
return typed fields; other endpoints carry their Markdown in `data.markdown`.
The JSON representation is **beta** (`apiVersion` `0.1-beta`) and may still
change shape.

Full details — envelope, every payload shape, the endpoints with no JSON twin:
`https://torahlm.org/reference.md`.

**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, Gemini, Perplexity, Grok, Cursor, Antigravity, and most agent tools). Add `https://torahlm.org/mcp` as a custom connector; it needs no auth (choose "None" / "Open"). In ChatGPT: add the TorahLM plugin from `https://torahlm.org/chatgpt`. In Gemini: gemini.google.com → Settings → Connected Apps → Add a custom app (US, 18+, personal account only for now); elsewhere, point Gemini users at the NotebookLM.
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/md/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/md/book/Genesis/r/1:1` - Genesis Chapter 1, Verse 1
- `https://torahlm.org/md/book/Berakhot/r/2a` - Talmud Berakhot Daf 2a
- `https://torahlm.org/md/book/Rashi%20on%20Genesis/r/1:1` - Rashi on Genesis 1:1
- `https://torahlm.org/md/book/Genesis/r/1:31-2:3` - a range, also in Sefaria's dot form `Genesis.1.31-2.3`; one range spans at most 10 chapters (or amudim)
- `https://torahlm.org/md/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/md/book/{BookName}/s/{section_path}/r/{ref}
```

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

**Sefaria-style references** are also accepted at the same canonical book
endpoint when that form is easier to paste:

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

Example:
- `https://torahlm.org/md/book/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/md/book/Genesis/r/1:1?lang=he`

### Response Size

One ref can be one verse or several long essays — `Genesis 1:1` is under 1 KB, while a commentary ref can contain several essays. HTTP is complete by default; these optional parameters window it at complete segment boundaries:

| Parameter | Description |
|-----------|-------------|
| `?limit=N` | Return at most N segments (default: all). A trailer names how many were withheld |
| `?max_bytes=N` | Soft UTF-8 content budget. Complete segments only; an oversized single segment is returned whole with a notice |
| `?offset=N` | Continue at zero-based segment N. Apply before `limit` |
| `?footnotes=0` | Drop footnote blocks (roughly 10-15% on annotated works) |

Example: `https://torahlm.org/md/book/Ramban on Genesis/r/1:1?limit=1` — 12 KB instead of 41 KB.

Every partial response gives the next `offset`. Offsets are stable only within one corpus generation. The budget counts rendered Markdown items, not fixed headers/trailers, so it is a soft content budget rather than a total-response ceiling.

### 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`

### 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/md/search?q={query}
```

Examples:
- `https://torahlm.org/md/search?q=shabbat+candles`
- `https://torahlm.org/md/search?q=%D7%A9%D7%91%D7%AA` (Hebrew works too — niqqud and common spelling variants like shabbos/shabbat resolve automatically)
- `https://torahlm.org/md/search?q=shofar&type=halachipedia` (one corpus only)
- `https://torahlm.org/md/search?q=mishnah+berurah&type=title` (find a work by name — "which book is this?")
- `https://torahlm.org/md/search?q=candles&book=Berakhot` (search inside one book)
- `https://torahlm.org/md/search?q=candles&book=Talmud` (or inside a whole category)
- `https://torahlm.org/md/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. Teacher filtering matches all supplied name tokens, so `Schachter` and reordered names work without requiring an exact phrase. 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.

`/json/search` returns the same results as typed fields, one key per corpus —
shapes in `https://torahlm.org/reference.md`.

`query.type` echoes back as an **array**, normalized and sorted, even when you
passed a single `type=`.

### Words API (Dictionary)

Look up dictionary definitions for Hebrew words:

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

Example: `https://torahlm.org/md/word/בראשית`

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

### Halachipedia

Practical halacha articles from Halachipedia, as clean Markdown:

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

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

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

Articles can be long (Borer is 46 KB). Two optional parameters narrow the response:

| Parameter | Description |
|-----------|-------------|
| `?section=` | Return only that section, by its heading — e.g. `?section=Silverware` (1 KB instead of 46 KB). Search results name the section they matched |
| `?references=0` | Drop the `## References` citations block — often half the article |

### Shiurim (Torah Podcasts)

Browse Torah audio classes from YUTorah, OUTorah, and other sources. Podcast and episode ids match TorahApp share URLs:

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

Examples:
- `https://torahlm.org/md/shiurim/YU_80714_perek_hatecheiles_shiur` - all episodes of a series
- `https://torahlm.org/md/shiurim/YU_80714_perek_hatecheiles_shiur/e/yu:814763` - one episode
- `https://torahlm.org/md/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.

### Calendar and Zmanim

Computed by TorahLM itself; nothing is fetched from another calendar service.

```
https://torahlm.org/md/calendar?date={YYYY-MM-DD}
https://torahlm.org/md/zmanim?place={place}&date={YYYY-MM-DD}
https://torahlm.org/md/zmanim?lat={lat}&lon={lon}
```

- `/calendar` gives the Hebrew date before and after sunset, holidays and special days that day and in the next 30 days, the Torah reading for that week's Shabbat (every aliyah, maftir and haftarah), and the daily learning schedules: Daf Yomi, Mishna Yomi, Rambam, Nach Yomi and Tehillim, or with `detailed=1` all 21 (Yerushalmi Yomi, Chofetz Chaim, Sefer HaMitzvot, Kitzur Shulchan Arukh and more). Each reference links to TorahApp and gives its `get_text` path. Where Israel and the diaspora differ, both are shown. With no `date` it uses today in UTC, so pass the user's own date when you know it.
- `/zmanim` takes `place` (a town, "Town, State", "Town, Country", Hebrew names, or a US ZIP) or `lat`/`lon` in decimal degrees (west and south are negative), or both, which are cross-checked. The answer names the place it used and how far the coordinates are from it, the time zone (always worked out from the location, never taken from the caller), the current time there, and every zman with the time until it; `detailed=1` adds the less common opinions (Magen Avraham 72 minutes, 3-star nightfall, midnight). A name shared by several comparable places is an error that lists them; a name not found suggests close spellings. With no `date` it uses today at the place.
- Zmanim are for sea level, rounded to the minute toward the safe side (deadlines earlier, earliest times later), and include candle lighting, havdalah and fast times on the days they apply. `/json/zmanim` gives each time as ISO 8601 with its UTC offset; for today each also has `passed` and `inMinutes` (negative once passed), plus `next` and `nextInMinutes` when its next occurrence is another moment (tomorrow's).
- Place data: [GeoNames](https://www.geonames.org) (CC-BY 4.0).

### 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
```

**Authentication:** optional. Every tool works without signing in except `my_torahapp_activity`, which reads the user's own TorahApp learning (stats, progress, activity by week, month or year). It uses OAuth (scope `torahapp_activity`): the first call asks the user to sign in with the Google or Apple account they use in TorahApp. Without signing in every other tool works; `my_torahapp_activity` is still listed and asks for sign-in when called.

Tools: `get_text`, `get_links`, `lookup_word`, `get_halachipedia`, `search`, `get_jewish_calendar`, `get_zmanim`, `lookup` — each returns the same Markdown as the corresponding HTTP request after MCP's defaults are materialized.

`show_text` displays texts to the user as a card in the chat (an MCP App): Hebrew and English, each linked to TorahApp. Call it when the user asks to see a text or a Talmud page, or when the answer is about one passage; otherwise offer to show the cited texts instead of showing them unasked. Call it once, with the refs the answer cited (`refs`, ranges like `Genesis 1:1-5` allowed; optional `lang` and `layout` — `default` (TorahLM picks), `standard`, or `daf` for a Talmud amud as printed — set where the card starts; the user can switch language and layout on the card). The model gets back only the list of refs shown, so it does not replace `get_text`. Clients without MCP App support get the same list as TorahApp links.

MCP is bounded by default because its results enter model context directly:

- `get_text`: `maxBytes=32768` (32 KiB, roughly 10,900 TorahLM tokens).
- `lookup`: applies the matching default when it routes to text. Its `offset` and `maxBytes` arguments continue or resize that result.

Packing is best-effort: segments are never split. If the first item alone exceeds 32 KiB it is returned complete with a size notice. Follow the executable `offset` continuation to read the next window; text offsets are stable only within one data generation. An explicit `maxBytes` replaces the default. HTTP and `/json` remain unbounded unless you pass `max_bytes` yourself. Whole Halachipedia articles are also unchanged and can be large; use `section` for a focused result. References remain included by default.

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, ignoring window arguments. A bare named `/s/` section is a passage and is windowable. `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 reports which branch it chose and why. Use direct tools when the resource type is already known. All tools are read-only.
