LLM HTML-to-Markdown Cleaner API
Convert noisy web pages or raw HTML into clean, token-efficient Markdown for RAG.
Estimate tokens, optimize message order for prompt caching, and calculate LLM API costs. Estimate token counts across OpenAI, Anthropic, and Gemini models, reorder messages for maximum prompt-cache hits, and enforce context budgets.
{
"ok": true,
"data": {
"model": "claude-3-7-sonnet",
"total_input_tokens": 27,
"cacheable_prefix_tokens": 11,
"uncached_tail_tokens": 16,
"min_cacheable_tokens_required": 1024,
"cache_eligible": false,
"cache_prefix_key": "pck_none_below_threshold",
"within_budget": true,
"context_utilization_pct": 3.29,
"ordering_optimal": true,
"recommended_order_ids": [
"sys",
"usr"
],
"block_breakdown": [
{
"index": 0,
"id": "sys",
"role": "system",
"inferred_volatility": "static",
"estimated_tokens": 11,
"cumulative_tokens": 11,
"in_cacheable_prefix": true,
"recommended_cache_breakpoint": false
},
{
"index": 1,
"id": "usr",
"role": "user",
"inferred_volatility": "turn",
"estimated_tokens": 16,
"cumulative_tokens": 27,
"in_cacheable_prefix": false,
"recommended_cache_breakpoint": false
}
],
"cost_estimate_usd": {
"single_uncached_call": 0.007581,
"single_cache_write_call": 0.007581,
"single_cache_read_call": 0.007581,
"batch_uncached_total": 0.07581,
"batch_cached_total": 0.07581,
"estimated_savings_usd": 0,
"estimated_savings_pct": 0
},
"recommendations": [
"Cacheable prefix (11 tokens) is below claude-3-7-sonnet's minimum threshold of 1024 tokens. Consolidate system instructions or few-shot examples into the static prefix."
]
},
"meta": {
"request_id": "req_pcb_01",
"ms": 1
}
}
curl -X POST "https://api.tinplate.dev/v1/prompt-cache-budgeter" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TINPLATE_KEY" \
-d '{"model":"claude-3-7-sonnet","max_context_tokens":16000,"blocks":[{"id":"sys","role":"system","content":"You are a contract analyst.","volatility":"static"},{"id":"usr","role":"user","content":"Analyze clause 4.2 of the attached agreement.","volatility":"turn"}]}'import { TinplateClient } from "@tinplate/sdk";
const tinplate = new TinplateClient({
apiKey: process.env.TINPLATE_API_KEY!,
});
const { data, meta } = await tinplate.call("/v1/prompt-cache-budgeter", {
"model": "claude-3-7-sonnet",
"max_context_tokens": 16000,
"blocks": [
{
"id": "sys",
"role": "system",
"content": "You are a contract analyst.",
"volatility": "static"
},
{
"id": "usr",
"role": "user",
"content": "Analyze clause 4.2 of the attached agreement.",
"volatility": "turn"
}
]
});
console.log(`[${meta.ms} ms]`, data);import requests
response = requests.post(
"https://api.tinplate.dev/v1/prompt-cache-budgeter",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TINPLATE_KEY",
},
json={
"model": "claude-3-7-sonnet",
"max_context_tokens": 16000,
"blocks": [
{
"id": "sys",
"role": "system",
"content": "You are a contract analyst.",
"volatility": "static"
},
{
"id": "usr",
"role": "user",
"content": "Analyze clause 4.2 of the attached agreement.",
"volatility": "turn"
}
]
}
)
print(response.json())const response = await fetch("https://api.tinplate.dev/v1/prompt-cache-budgeter", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TINPLATE_KEY",
},
body: JSON.stringify({
"model": "claude-3-7-sonnet",
"max_context_tokens": 16000,
"blocks": [
{
"id": "sys",
"role": "system",
"content": "You are a contract analyst.",
"volatility": "static"
},
{
"id": "usr",
"role": "user",
"content": "Analyze clause 4.2 of the attached agreement.",
"volatility": "turn"
}
]
}),
});
const result = await response.json();
console.log(result);{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "tinplate_prompt_cache_budgeter",
"arguments": {
"model": "claude-3-7-sonnet",
"max_context_tokens": 16000,
"blocks": [
{
"id": "sys",
"role": "system",
"content": "You are a contract analyst.",
"volatility": "static"
},
{
"id": "usr",
"role": "user",
"content": "Analyze clause 4.2 of the attached agreement.",
"volatility": "turn"
}
]
}
}
}POST /v1/prompt-cache-budgeter)| Parameter | Type & Constraints | Description |
|---|---|---|
model optional |
string | stringdefault: "claude-3-7-sonnet" |
Field 'model' |
blocks required |
object[] |
Field 'blocks' |
max_context_tokens optional |
integermin: 512, max: 2000000 |
Field 'max_context_tokens' |
expected_output_tokens optional |
integermin: 0, max: 128000, default: 500 |
Field 'expected_output_tokens' |
estimated_cache_hits optional |
integermin: 1, max: 10000, default: 10 |
Field 'estimated_cache_hits' |
data Object Fields (200 OK)| Field | Type | Description |
|---|---|---|
model |
string |
Field 'model' |
total_input_tokens |
integer |
Field 'total_input_tokens' |
cacheable_prefix_tokens |
integer |
Field 'cacheable_prefix_tokens' |
uncached_tail_tokens |
integer |
Field 'uncached_tail_tokens' |
min_cacheable_tokens_required |
integer |
Field 'min_cacheable_tokens_required' |
cache_eligible |
boolean |
Field 'cache_eligible' |
cache_prefix_key |
string |
Field 'cache_prefix_key' |
within_budget |
boolean |
Field 'within_budget' |
context_utilization_pct |
number |
Field 'context_utilization_pct' |
ordering_optimal |
boolean |
Field 'ordering_optimal' |
recommended_order_ids |
string[] |
Field 'recommended_order_ids' |
block_breakdown |
object[] |
Field 'block_breakdown' |
cost_estimate_usd |
object |
Field 'cost_estimate_usd' |
recommendations |
string[] |
Field 'recommendations' |
warnings |
string[] |
Field 'warnings' |
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 →
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).
| Plan | Monthly Price | Included Requests | Rate Limit | Max Payload | Best For |
|---|---|---|---|---|---|
| BASIC | $0.00 / mo | 500 / month | 10 req / min | 64 KB | Evaluation & CI smoke tests |
| PRO | $9.99 / mo | 15,000 / month | 60 req / min | 128 KB | Solo devs & production apps |
| ULTRA | $29.99 / mo | 100,000 / month | 300 req / min | 256 KB | Growing SaaS & multi-agent pipelines |
| MEGA | $79.99 / mo | 500,000 / month | 1,000 req / min | 256 KB | High-volume enterprise workloads |
OpenAI, Anthropic, and Gemini only cache identical static prefixes. Putting dynamic timestamps or user queries before static RAG docs breaks cache hits.
Yes. It flags budget overruns and provides truncation/chunking recommendations while preserving system instructions.
No. Everything runs in volatile V8 memory.
Stateless in-memory token counting and hashing. Prompts are never retained.
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.
Convert noisy web pages or raw HTML into clean, token-efficient Markdown for RAG.
Repair malformed or truncated LLM JSON outputs into valid, schema-checked JSON in 1 ms.
Validate and auto-repair broken LLM tool-call arguments against your JSON Schema.