> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ragrails.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK Reference

> All RagRails SDK methods.

<Note>This page is generated from `inspect.signature(RagRails)`. Run `RAGRAILS_SOURCE=/path/to/ragrails uv run python scripts/generate-reference.py` from the docs repo after SDK signature changes.</Note>

SDK defaults live on each `RagRails(...)` instance. They do not write `.ragrails.toml` and they do not change CLI or REST defaults.

Use [SDK Overview](/usage/sdk/overview) for workflow guidance. Use this page when you need exact method signatures.

## Constructor

| Method     | Signature                       |                                               |                                           |                                     |                                          |                           |
| ---------- | ------------------------------- | --------------------------------------------- | ----------------------------------------- | ----------------------------------- | ---------------------------------------- | ------------------------- |
| `RagRails` | \`RagRails(\*, collection: 'str | None' = None, vector\_store: 'dict\[str, Any] | None' = None, embedding: 'dict\[str, Any] | None' = None, llm: 'dict\[str, Any] | None' = None, reranker: 'dict\[str, Any] | None' = None) -> 'None'\` |

## Ingestion

| Method          | Signature                                             |                               |                                                                              |                                                                                                                                                                                                                                                                                                              |                                                                                                                                                                                      |                                  |                                                        |                                |       |                                                                                                                                                                                      |                                      |
| --------------- | ----------------------------------------------------- | ----------------------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------- | ------------------------------------------------------ | ------------------------------ | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------ |
| `setup_url`     | `setup_url(*, browser: 'str' = 'chromium') -> 'dict'` |                               |                                                                              |                                                                                                                                                                                                                                                                                                              |                                                                                                                                                                                      |                                  |                                                        |                                |       |                                                                                                                                                                                      |                                      |
| `scrape`        | \`scrape(url: 'str                                    | list\[str                     | dict]                                                                        | None' = None, \*, mode: "Literal\['each', 'full']" = 'each', max\_depth: 'int' = 3, max\_pages: 'int' = 200, verbose: 'bool' = False, frontmatter: 'bool' = False, output\_format: "Literal\['markdown', 'json']" = 'markdown', output\_dest: "Literal\['response', 'file']" = 'response', output\_dir: 'str | None' = None, dlq: 'DLQ                                                                                                                                                              | str                              | None' = None) -> 'ScrapeResult'\`                      |                                |       |                                                                                                                                                                                      |                                      |
| `scrape_stream` | \`scrape\_stream(url: 'str                            | list\[str                     | dict]                                                                        | None' = None, \*, mode: "Literal\['each', 'full']" = 'each', max\_depth: 'int' = 3, max\_pages: 'int' = 200, verbose: 'bool' = False, frontmatter: 'bool' = False)\`                                                                                                                                         |                                                                                                                                                                                      |                                  |                                                        |                                |       |                                                                                                                                                                                      |                                      |
| `parse`         | \`parse(files: 'str                                   | list\[str                     | dict]                                                                        | None' = None, \*, folder: 'str                                                                                                                                                                                                                                                                               | None' = None, frontmatter: 'bool' = False, output\_format: "Literal\['markdown', 'json']" = 'markdown', output\_dest: "Literal\['response', 'file']" = 'response', output\_dir: 'str | None' = None) -> 'ParseResult'\` |                                                        |                                |       |                                                                                                                                                                                      |                                      |
| `fetch`         | \`fetch(url: 'str                                     | None' = None, \*, title: 'str | None' = None, description: 'str' = '', method: 'str' = 'GET', headers: 'dict | None' = None, params: 'dict                                                                                                                                                                                                                                                                                  | None' = None, body: 'dict                                                                                                                                                            | None' = None, pagination: 'dict  | None' = None, max\_pages: 'int' = 100, timeout: 'float | None' = None, apis: 'list\[str | dict] | None' = None, frontmatter: 'bool' = False, output\_format: "Literal\['markdown', 'json']" = 'markdown', output\_dest: "Literal\['response', 'file']" = 'response', output\_dir: 'str | None' = None) -> 'ApiIngestResult'\` |

## Chunking

| Method  | Signature                  |           |                                                                                                                                                                       |
| ------- | -------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `chunk` | \`chunk(\*, markdown: 'str | list\[str | dict\[str, Any]]', title: 'str' = '', source: 'str' = '', chunk\_size: 'int' = 2000, chunk\_overlap: 'int' = 200, min\_chunk\_length: 'int' = 100) -> 'ChunkResult'\` |

## Embedding

| Method     | Signature                                                                                                                |                           |                                                                          |                 |
| ---------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------- | ------------------------------------------------------------------------ | --------------- |
| `embedder` | \`embedder(\*, provider: 'str                                                                                            | None' = None, model: 'str | None' = None, input\_type: 'str' = 'document', options: 'dict\[str, Any] | None' = None)\` |
| `embed`    | `embed(*, chunks: 'list[dict]', embedder=None, input_type: 'str' = 'document', batch_size: 'int' = 64) -> 'EmbedResult'` |                           |                                                                          |                 |

## Storing

| Method   | Signature                                                                                                                 |                                |                         |                                                                                                     |                                   |
| -------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ----------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------- |
| `store`  | \`store(\*, embedded\_chunks: 'list\[dict]', vector\_db: "Literal\['qdrant', 'qdrant\_cloud', 'pinecone', 'weaviate']     | None" = None, collection: 'str | None' = None, url: 'str | None' = None, batch\_size: 'int' = 64, ensure\_collection: 'bool' = True, options: 'dict\[str, Any] | None' = None) -> 'StoreResult'\`  |
| `edit`   | \`edit(\*, chunks: 'list\[dict]', embedder=None, vector\_db: "Literal\['qdrant', 'qdrant\_cloud', 'pinecone', 'weaviate'] | None" = None, collection: 'str | None' = None, url: 'str | None' = None, batch\_size: 'int' = 64, options: 'dict\[str, Any]                                    | None' = None) -> 'EditResult'\`   |
| `delete` | \`delete(\*, ids: 'list\[str]', vector\_db: "Literal\['qdrant', 'qdrant\_cloud', 'pinecone', 'weaviate']                  | None" = None, collection: 'str | None' = None, url: 'str | None' = None, options: 'dict\[str, Any]                                                             | None' = None) -> 'DeleteResult'\` |

## Retrieval

| Method     | Signature                                                                                                            |                                |                                         |                                         |                                                                                                                                                                                                                                                    |
| ---------- | -------------------------------------------------------------------------------------------------------------------- | ------------------------------ | --------------------------------------- | --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `reranker` | \`reranker(\*, provider: 'str                                                                                        | None' = None, model: 'str      | None' = None, options: 'dict\[str, Any] | None' = None)\`                         |                                                                                                                                                                                                                                                    |
| `retrieve` | \`retrieve(query: 'str', \*, embedder=None, vector\_db: "Literal\['qdrant', 'qdrant\_cloud', 'pinecone', 'weaviate'] | None" = None, collection: 'str | None' = None, url: 'str                 | None' = None, options: 'dict\[str, Any] | None' = None, top\_k: 'int' = 10, use\_query\_rewrite: 'bool' = False, rewrite\_llm=None, rewrite\_context: 'str' = '', session\_context: 'str' = '', use\_rerank: 'bool' = False, reranker=None, rerank\_top\_k: 'int' = 5) -> 'RetrieveResult'\` |

## Chat

| Method        | Signature                                                                  |                                |                                 |                              |                                                    |                                                             |                                                   |                                                     |                                                               |                                                                              |
| ------------- | -------------------------------------------------------------------------- | ------------------------------ | ------------------------------- | ---------------------------- | -------------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------- | --------------------------------------------------- | ------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| `llm`         | \`llm(\*, provider: 'str                                                   | None' = None, model: 'str      | None' = None, max\_tokens: 'int | None' = None)\`              |                                                    |                                                             |                                                   |                                                     |                                                               |                                                                              |
| `chat`        | \`chat(query: 'str', \*, llm=None, embedder=None, vector\_db: 'str         | None' = None, collection: 'str | None' = None, url: 'str         | None' = None, options: 'dict | None' = None, reranker=None, history: 'list\[dict] | None' = None, history\_compaction: 'HistoryCompactionConfig | None' = None, query\_rewrite: 'QueryRewriteConfig | None' = None, intent\_routing: 'IntentRoutingConfig | None' = None, retrieval\_quality: 'ChatRetrievalQualityConfig | None' = None, persona: 'str' = '', retrieval\_config=None) -> 'ChatResult'\` |
| `chat_stream` | \`chat\_stream(query: 'str', \*, llm=None, embedder=None, vector\_db: 'str | None' = None, collection: 'str | None' = None, url: 'str         | None' = None, options: 'dict | None' = None, reranker=None, history: 'list\[dict] | None' = None, history\_compaction: 'HistoryCompactionConfig | None' = None, query\_rewrite: 'QueryRewriteConfig | None' = None, intent\_routing: 'IntentRoutingConfig | None' = None, retrieval\_quality: 'ChatRetrievalQualityConfig | None' = None, persona: 'str' = '', retrieval\_config=None)\`                 |

## Pipeline

| Method   | Signature                                             |                                           |                                     |                 |                          |           |       |                 |                         |           |       |                 |                              |           |                  |                                           |                                          |                                           |                                         |                                                                          |
| -------- | ----------------------------------------------------- | ----------------------------------------- | ----------------------------------- | --------------- | ------------------------ | --------- | ----- | --------------- | ----------------------- | --------- | ----- | --------------- | ---------------------------- | --------- | ---------------- | ----------------------------------------- | ---------------------------------------- | ----------------------------------------- | --------------------------------------- | ------------------------------------------------------------------------ |
| `ingest` | \`ingest(\*, docs: 'str                               | list\[str                                 | dict]                               | dict\[str, Any] | None' = None, urls: 'str | list\[str | dict] | dict\[str, Any] | None' = None, api: 'str | list\[str | dict] | dict\[str, Any] | None' = None, markdown: 'str | list\[str | dict\[str, Any]] | None' = None, ingestion: 'dict\[str, Any] | None' = None, chunking: 'dict\[str, Any] | None' = None, embedding: 'dict\[str, Any] | None' = None, storage: 'dict\[str, Any] | None' = None, concurrency: 'str' = 'serial') -> 'IngestPipelineResult'\` |
| `query`  | \`query(query: 'str', \*, embedding: 'dict\[str, Any] | None' = None, retrieval: 'dict\[str, Any] | None' = None) -> 'RetrieveResult'\` |                 |                          |           |       |                 |                         |           |       |                 |                              |           |                  |                                           |                                          |                                           |                                         |                                                                          |

## Important validation notes

* `rag.llm()` requires a model unless `llm={"model": ...}` was configured on the constructor.
* Provider, embedding, vector-store, and reranker defaults are constructor defaults only.
* SDK `fetch(apis=...)` supports batch API ingestion; REST `/v1/ingest/api` currently requires `url`.

## Config objects

| Class                                                                                                        | Used with                      | Description                                     |
| ------------------------------------------------------------------------------------------------------------ | ------------------------------ | ----------------------------------------------- |
| `DLQ(path, items)`                                                                                           | `scrape(dlq=...)`              | Dead-letter queue for retryable scrape failures |
| `QueryRewriteConfig(enabled, session_context, llm)`                                                          | `chat(query_rewrite=...)`      | Query rewriting config                          |
| `HistoryCompactionConfig(enabled, history_limit, keep_recent)`                                               | `chat(history_compaction=...)` | History summarisation config                    |
| `IntentRoutingConfig(enabled)`                                                                               | `chat(intent_routing=...)`     | Intent routing config                           |
| `ChatRetrievalQualityConfig(min_retrieval_score, min_rerank_score, low_confidence_mode, max_context_chunks)` | `chat(retrieval_quality=...)`  | Retrieval quality thresholds                    |
