supermemory/apps/docs/concepts/super-rag.mdx
sohamd22 ca89d161cc docs(api): move v5 search and ingest options into the request body (#1808)
Fixes v5 search and recall docs that didn't match the API.

- **Options in the URL.** Search examples passed `searchMode`/`limit` as query params, and ingest examples passed `dreaming`/`taskType` the same way. v5 rejects every query param on these routes with `400`. They now go in the JSON body (quickstart, rules, super-rag, recall/search).
- **`include`, not `attach`.** Renamed the search option. Its `forgotten` flag also admits forgotten memories into the main results, not just related context.
- **Search response.** Added the required `isInference`. `metadata` is always an object, and `system.createdAt` is optional.
- **Search add-ons are billed.** `rewriteQuery` and `rerank` each bill one extra operation; the docs said "no extra cost".
- **Removed claims that don't match current behavior:**
  - inferred memories being down-weighted in search;
  - AST code chunking via `code-chunk` (super-rag now describes how chunking actually works);
  - a 64-character metadata key limit.
- **Smaller fixes:**
  - The namespace is the SDK's first argument; the docs called it a top-level key.
  - "No v5 Python SDK" was stale.
  - Memory review: `total` semantics, the internal review stamp, and the missing 403.

Checked against the current API and the published SDKs (TS 5.0.1, Python 5.0.0). Legacy v3/v4 docs are unchanged apart from factual fixes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-10-15 18:52:40 +00:00

220 lines
8.2 KiB
Text

---
title: "SuperRAG (managed RAG as a service)"
sidebarTitle: "SuperRAG"
description: "Supermemory provides a managed RAG solution - extraction, indexing, storing, and retrieval."
icon: "/icons/hugeicons/flash.svg"
---
Supermemory doesn't just store your content—it transforms it into optimized, searchable knowledge. Every upload goes through an intelligent pipeline that extracts, chunks, and indexes content in the ideal way for its type.
## Automatic content intelligence
When you add content, Supermemory:
1. **Detects the content type** — PDF, code, markdown, images, video, etc.
2. **Extracts content optimally** — Uses type-specific extraction (OCR for images, transcription for audio)
3. **Chunks intelligently** — Applies the right chunking strategy for the content type
4. **Generates embeddings** — Creates vector representations for semantic search
5. **Builds relationships** — Connects new knowledge to existing memories
```typescript
// Just upload — Supermemory handles the rest
await supermemory.documents.uploadFile("docs_kb", {
file: fs.createReadStream('technical-documentation.pdf'),
metadata: JSON.stringify({ title: "Technical Documentation" }),
});
```
No chunking strategies to configure. No embedding models to choose. It just works.
---
## Ingesting as pure SuperRAG (`taskType: "superrag"`)
By default, every `supermemory.add()` call runs on the **memory** path (`taskType: "memory"`): Supermemory chunks and embeds the content for retrieval, *and* runs it through the memory pipeline — extracting facts, updating the profile, and linking it into the knowledge graph.
If you're ingesting content that's purely reference material — documentation, a large PDF, a knowledge base article — and you don't need Supermemory to derive personal facts or update a profile from it, set `taskType: "superrag"` in the request body. It skips the memory pipeline entirely and only does the chunk → embed → index work needed to make the content searchable.
<CodeGroup>
```typescript TypeScript
await supermemory.add("docs_kb", { // e.g. a long internal wiki page
content: "...",
taskType: "superrag",
});
```
```python Python
client.add(
"docs_kb",
content="...", # e.g. a long internal wiki page
task_type="superrag",
)
```
```bash cURL
curl -X POST "https://api.supermemory.ai/ns/docs_kb/document" \
-H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "content": "...", "taskType": "superrag" }'
```
</CodeGroup>
| | `taskType: "memory"` (default) | `taskType: "superrag"` |
|---|---|---|
| Chunking, embedding, indexing | ✅ | ✅ — searchable immediately via `searchMode: "chunks"` |
| Fact extraction into memories | ✅ | ❌ skipped |
| Profile (`static`/`dynamic`/buckets) updates | ✅ | ❌ skipped |
| Graph linking (updates/extends/derives) | ✅ | ❌ skipped |
| Price per ingested token | Full rate | **5x cheaper** |
<Tip>
`taskType: "superrag"` is a **5x discount on ingested tokens** — `sm_superrag_text`/`sm_superrag_rich` are priced at 20% of `sm_tokens_text`/`sm_tokens_rich`. See [Billing → Memory vs SuperRAG tokens](/overview/billing#memory-vs-superrag-tokens) for the exact rates.
</Tip>
<Warning>
Content ingested as `superrag` is retrievable via chunk search (`searchMode: "chunks"`), but it will **never** surface as a memory, contribute to a user's profile, or connect into the knowledge graph. Use it for reference material you want searchable, not for anything that should shape what Supermemory knows about a user — that still needs the default `taskType: "memory"`.
</Warning>
When you're searching over a mix of both, `searchMode: "hybrid"` (below) is what pulls memory-path facts and superrag-path document chunks into one result set. More ingestion guidance: [Rules of supermemory → Ingest with SuperRag when you just need search](/concepts/rules#ingest-with-superrag-when-you-just-need-search).
---
## Smart chunking by content type
Different content types need different chunking strategies. Supermemory applies the optimal approach automatically:
### Documents (PDF, DOCX)
PDFs and documents are chunked by **semantic sections** — headers, paragraphs, and logical boundaries. This preserves context better than arbitrary character splits.
```
├── Executive Summary (chunk 1)
├── Introduction (chunk 2)
├── Section 1: Architecture
│ ├── Overview (chunk 3)
│ └── Components (chunk 4)
└── Conclusion (chunk 5)
```
### Code
When content is recognized as Markdown, fenced code blocks are kept whole when they fit in a chunk. Larger blocks are split and re-wrapped in the original fence, including its language tag. Overlap can contain part of a previous line, so chunks are not guaranteed to be independently valid code.
Raw source files and content not recognized as Markdown use plain-text chunking. A lone fenced block may not be enough for automatic Markdown detection.
### Web pages
URLs are fetched, cleaned of navigation/ads, and chunked by article structure — headings, paragraphs, lists.
### Markdown
Chunked by heading hierarchy, preserving the document structure.
See [Content Types](/concepts/content-types) for the full list of supported formats.
---
## Hybrid memory + RAG
Supermemory combines the best of both approaches in every search:
<CardGroup cols={2}>
<Card title="Traditional RAG" icon="/icons/hugeicons/search-01.svg">
- Finds similar document chunks
- Great for knowledge retrieval
- Stateless — same results for everyone
</Card>
<Card title="Memory system" icon="/icons/hugeicons/brain-01.svg">
- Extracts and tracks user facts
- Understands temporal context
- Personalizes results per user
</Card>
</CardGroup>
With `searchMode: "hybrid"` (the default), you get both:
```typescript
const results = await supermemory.search("user_123", {
query: "how do I deploy the app?",
searchMode: "hybrid",
});
// Returns:
// - Deployment docs from your knowledge base (RAG)
// - User's previous deployment preferences (Memory)
// - Their specific environment configs (Memory)
```
---
## Search optimization
Two flags give you fine-grained control over result quality:
### Reranking
Re-scores results using a cross-encoder model for better relevance. `rerank` takes `"none"` (default), `"order"`, or `"aggregate"`:
```typescript
const results = await supermemory.search("user_123", {
query: "complex technical question",
rerank: "order", // +~100ms, significantly better ranking
});
```
**When to use:** Complex queries, technical documentation, when precision matters more than speed.
### Query rewriting
Expands your query to capture more relevant results:
```typescript
const results = await supermemory.search("user_123", {
query: "how to auth",
rewriteQuery: true, // Expands to "authentication login oauth jwt..."
});
```
**When to use:** Short queries, user-facing search, when recall matters.
---
## Why it's "Super"
| Traditional RAG | SUPER RAG |
|-----------------|-----------|
| Manual chunking config | Automatic per content type |
| One-size-fits-all splits | AST-aware code chunking |
| Just document retrieval | Hybrid memory + documents |
| Static embeddings | Relationship-aware graph |
| Generic search | Rerank + query rewriting |
You focus on building your product. Supermemory handles the RAG complexity.
---
## Next steps
<CardGroup cols={2}>
<Card title="Content types" icon="/icons/hugeicons/files-01.svg" href="/concepts/content-types">
All supported formats and how they're processed
</Card>
<Card title="How it works" icon="/icons/hugeicons/cpu.svg" href="/concepts/how-it-works">
The full processing pipeline
</Card>
<Card title="Memory vs RAG" icon="/icons/hugeicons/balance-scale.svg" href="/concepts/memory-vs-rag">
When to use each approach
</Card>
<Card title="Search" icon="/icons/hugeicons/search-01.svg" href="/recall/search">
Search parameters and optimization
</Card>
<Card title="Billing" icon="/icons/hugeicons/invoice-01.svg" href="/overview/billing#memory-vs-superrag-tokens">
Exact meter rates for memory vs SuperRAG tokens
</Card>
<Card title="Adding memories" icon="/icons/hugeicons/plus-sign.svg" href="/ingestion/add-memories">
`taskType` and other ingestion parameters
</Card>
</CardGroup>