Support: support@tinplate.dev · Zero-Retention Edge Security Support Trust Center DPA GitHub Issues
Developer Utilities Tier 2 All-Access

Smart RAG Document Chunker API — Split Markdown by Token Budget Without Breaking Code or Tables

Split Markdown into token-budgeted RAG chunks with heading breadcrumbs and intact code/tables. Split Markdown and technical docs into token-budgeted RAG chunks while keeping fenced code blocks and tables intact, injecting heading breadcrumbs, and generating deterministic chunk IDs.

Interactive Sandbox · No API Key Required 200 OK · Ready
POST /v1/rag-chunkerinput
200 OK sample / live responsejson
{
  "ok": true,
  "data": {
    "chunk_count": 2,
    "total_chars": 188,
    "total_estimated_tokens": 68,
    "avg_chunk_tokens": 34,
    "preserved_code_blocks": 1,
    "preserved_tables": 1,
    "chunks": [
      {
        "index": 0,
        "chunk_id": "chk_2296f0a18a703ee7",
        "text": "[Context: Gateway Manual > Authentication]\n\n# Gateway Manual\n\n## Authentication\n\nPass your proxy secret header.\n\n```bash\ncurl -X POST https://api.tinplate.dev/v1/json-heal\n```",
        "raw_text": "# Gateway Manual\n\n## Authentication\n\nPass your proxy secret header.\n\n```bash\ncurl -X POST https://api.tinplate.dev/v1/json-heal\n```",
        "heading_path": [
          "Gateway Manual",
          "Authentication"
        ],
        "block_types": [
          "heading",
          "prose",
          "code"
        ],
        "char_count": 175,
        "estimated_tokens": 44,
        "start_line": 1,
        "end_line": 8
      },
      {
        "index": 1,
        "chunk_id": "chk_664daeea150dbc83",
        "text": "[Context: Gateway Manual > Quotas]\n\n## Quotas\n\n| Plan | Calls |\n| --- | --- |\n| Basic | 500 |",
        "raw_text": "## Quotas\n\n| Plan | Calls |\n| --- | --- |\n| Basic | 500 |",
        "heading_path": [
          "Gateway Manual",
          "Quotas"
        ],
        "block_types": [
          "heading",
          "table"
        ],
        "char_count": 93,
        "estimated_tokens": 24,
        "start_line": 10,
        "end_line": 13
      }
    ]
  },
  "meta": {
    "request_id": "req_chk_01",
    "ms": 1
  }
}
OpenAPI 3.0.3 Get All-Access Key ($29/mo) No signup. No payload storage.
Quickstart Code Examples
curl -X POST "https://api.tinplate.dev/v1/rag-chunker" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TINPLATE_KEY" \
  -d '{"text":"# Gateway Manual\n\n## Authentication\nPass your proxy secret header.\n\n```bash\ncurl -X POST https://api.tinplate.dev/v1/json-heal\n```\n\n## Quotas\n| Plan | Calls |\n| --- | --- |\n| Basic | 500 |","max_tokens":128,"overlap_tokens":16,"prepend_breadcrumbs":true}'
import { TinplateClient } from "@tinplate/sdk";

const tinplate = new TinplateClient({
  apiKey: process.env.TINPLATE_API_KEY!,
});

const { data, meta } = await tinplate.call("/v1/rag-chunker", {
  "text": "# Gateway Manual\n\n## Authentication\nPass your proxy secret header.\n\n```bash\ncurl -X POST https://api.tinplate.dev/v1/json-heal\n```\n\n## Quotas\n| Plan | Calls |\n| --- | --- |\n| Basic | 500 |",
  "max_tokens": 128,
  "overlap_tokens": 16,
  "prepend_breadcrumbs": true
});
console.log(`[${meta.ms} ms]`, data);
import requests

response = requests.post(
    "https://api.tinplate.dev/v1/rag-chunker",
    headers={
        "Content-Type": "application/json",
        "Authorization": "Bearer YOUR_TINPLATE_KEY",
    },
    json={
  "text": "# Gateway Manual\n\n## Authentication\nPass your proxy secret header.\n\n```bash\ncurl -X POST https://api.tinplate.dev/v1/json-heal\n```\n\n## Quotas\n| Plan | Calls |\n| --- | --- |\n| Basic | 500 |",
  "max_tokens": 128,
  "overlap_tokens": 16,
  "prepend_breadcrumbs": true
}
)
print(response.json())
const response = await fetch("https://api.tinplate.dev/v1/rag-chunker", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TINPLATE_KEY",
  },
  body: JSON.stringify({
  "text": "# Gateway Manual\n\n## Authentication\nPass your proxy secret header.\n\n```bash\ncurl -X POST https://api.tinplate.dev/v1/json-heal\n```\n\n## Quotas\n| Plan | Calls |\n| --- | --- |\n| Basic | 500 |",
  "max_tokens": 128,
  "overlap_tokens": 16,
  "prepend_breadcrumbs": true
}),
});
const result = await response.json();
console.log(result);
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "tinplate_rag_chunker",
    "arguments": {
      "text": "# Gateway Manual\n\n## Authentication\nPass your proxy secret header.\n\n```bash\ncurl -X POST https://api.tinplate.dev/v1/json-heal\n```\n\n## Quotas\n| Plan | Calls |\n| --- | --- |\n| Basic | 500 |",
      "max_tokens": 128,
      "overlap_tokens": 16,
      "prepend_breadcrumbs": true
    }
  }
}
OpenAPI 3.0.3 Schema Contract

Request Parameters & Response Schema Reference

Request Body Parameters (POST /v1/rag-chunker)

ParameterType & ConstraintsDescription
text required string
minLen: 1, maxLen: 200000
Raw Markdown, technical documentation, or prose document to split into semantic RAG chunks.
max_tokens optional integer
min: 32, max: 8192, default: 256
Target maximum token budget per chunk (default: 256).
overlap_tokens optional integer
min: 0, max: 1024, default: 24
Approximate trailing token overlap carried into the next chunk within the same section (default: 24).
prepend_breadcrumbs optional boolean
default: true
Prepend the active Markdown heading breadcrumb path (e.g. '[Context: Guide > Auth]') to each chunk's 'text' field for embedding context.
split_on_heading_level optional integer
min: 1, max: 6, default: 2
Always start a new chunk when encountering a heading at or above this level (1 = H1, 2 = H1/H2).

Response data Object Fields (200 OK)

FieldTypeDescription
chunk_count integer Field 'chunk_count'
total_chars integer Field 'total_chars'
total_estimated_tokens integer Field 'total_estimated_tokens'
avg_chunk_tokens number Field 'avg_chunk_tokens'
preserved_code_blocks integer Field 'preserved_code_blocks'
preserved_tables integer Field 'preserved_tables'
chunks object[] Field 'chunks'

What Markdown & Code Aware Smart RAG Document Chunker API Detects & Validates

  • Respects atomic fenced code blocks (``` / ~~~) and Markdown tables so embeddings never contain half-sliced code or broken table rows
  • Tracks ATX heading hierarchy (# H1 through ###### H6) and prepends '[Context: H1 > H2 > H3]' breadcrumbs to every chunk
  • Enforces configurable max_tokens and overlap_tokens budgets with sentence-aware fallback splitting for long prose paragraphs
  • Emits deterministic content-addressed chunk_id hashes and line-number coordinates (start_line, end_line) for idempotent vector database upserts
Honest Engineering Boundaries

Known Limitations & Test Verification

Release: v1.0.39 · Verified: 16 November 2026 · Portfolio Median: 0.318 ms in-Worker V8 compute (add 15–65 ms HTTPS RTT) · See Full Portfolio Benchmarks →

  • Uses a fast deterministic token estimator (~4 chars/token) rather than model-specific BPE tables; execution is typically under 5 ms in deterministic mode.
  • Tested v1.0.4 (14 November 2026).

Direct All-Access & Marketplace Plans

Direct Polar All-Access Keys unlock all 42 APIs (49 endpoints), /v1/pipeline, and /mcp on api.tinplate.dev: Pro ($29/mo · 120 req/min · 100k/mo · 128 KB) or Team ($79/mo · 300 req/min · 500k/mo · 256 KB).

PlanMonthly PriceIncluded RequestsRate LimitMax PayloadBest For
BASIC$0.00 / mo500 / month10 req / min64 KBEvaluation & CI smoke tests
PRO$9.99 / mo15,000 / month60 req / min128 KBSolo devs & production apps
ULTRA$29.99 / mo100,000 / month300 req / min256 KBGrowing SaaS & multi-agent pipelines
MEGA$79.99 / mo500,000 / month1,000 req / min256 KBHigh-volume enterprise workloads

Frequently Asked Questions

How does this pair with 04-html-to-markdown and 14-hallucination-diff?

Use 04-html-to-markdown to clean raw web pages into Markdown, 35-rag-chunker to split that Markdown into context-enriched vector chunks, and 14-hallucination-diff to verify LLM answers against the retrieved chunks.

Why prepend heading breadcrumbs to each chunk?

A chunk that only says 'Rate limit is 60 req/min' loses what product or tier it belongs to. Prepending '[Context: Gateway Manual > Pricing > PRO Tier]' dramatically improves retrieval precision.

Are chunk_id values deterministic across runs?

Yes, chunk_id is a deterministic hash of the chunk index and normalized text, making vector DB re-indexing idempotent.

Zero Payload Logging

Data Handling, Privacy & Proxy Disclosure

Documents are chunked in memory with zero payload logging or storage.

Worker Zero-Logging Guarantee: Cloudflare Workers Observability and invocation logging are disabled (observability.enabled = false, head_sampling_rate = 0, invocation_logs = false). Requests via RapidAPI or Zyla traverse marketplace proxies; use a Direct Bearer Key for zero-intermediary routing.

Related Tinplate APIs

POST /v1/html-to-markdown Tier 1

LLM HTML-to-Markdown Cleaner API

Convert noisy web pages or raw HTML into clean, token-efficient Markdown for RAG.

POST /v1/prompt-cache-budgeter AI Safety & Agents

Prompt Cache Key & Context Budgeter API

Estimate tokens, optimize message order for prompt caching, and calculate LLM API costs.

POST /v1/hallucination-diff AI Safety & Agents

Deterministic Hallucination Diff API

Fast first filter to catch unsupported numbers, dates, and names in LLM answers vs RAG sources.