{"openapi":"3.0.3","info":{"title":"TokenSlimmer API","description":"Sub-millisecond token compression and context window optimizer for AI agents, LangChain pipelines, and LLM applications. Cuts OpenAI and Anthropic token bills by 30-70%.","version":"1.0.0","contact":{"name":"TopAI SaaS Dev","email":"top.ai.saas@gmail.com"}},"servers":[{"url":"https://tokenslimmer-api.topaisaas.workers.dev","description":"Cloudflare Workers Global Edge Production"}],"paths":{"/v1/slim/html":{"post":{"summary":"Slim and Clean Web HTML","description":"Strips boilerplate, scripts, CSS classes, SVG, base64 images, and empty layout wrappers while preserving core semantic text, headings, and tables.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["html"],"properties":{"html":{"type":"string","example":"<!DOCTYPE html><html><body><div class='nav-bar bg-dark py-4'><ul><li><a href='/home'>Home</a></li></ul></div><article><h1 class='font-bold text-3xl'>Q3 Earnings Report</h1><p>Net profit rose 28% to $4.2B.</p></article></body></html>"},"preserve_links":{"type":"boolean","default":true},"preserve_tables":{"type":"boolean","default":true},"preserve_headings":{"type":"boolean","default":true},"strip_images":{"type":"boolean","default":true}}}}}},"responses":{"200":{"description":"Slimmed HTML and token reduction statistics"},"400":{"description":"Invalid input"}}}},"/v1/slim/json":{"post":{"summary":"Prune and Compress JSON Payload","description":"Recursively removes nulls, empty strings, empty arrays, and developer telemetry keys from API JSON payloads to slash token usage.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["json_data"],"properties":{"json_data":{"type":"object","example":{"id":"usr_102","name":"Alice Johnson","title":"Lead AI Engineer","middle_name":null,"tags":[],"notes":"","created_at":"2024-01-01T00:00:00Z","company":{"name":"Fintech Corp","website":"https://fintech.example.com","fax":null}}},"remove_nulls":{"type":"boolean","default":true},"remove_empty_strings":{"type":"boolean","default":true},"remove_empty_arrays":{"type":"boolean","default":true},"strip_metadata_keys":{"type":"boolean","default":true},"compact_format":{"type":"string","enum":["minified","key_value","yaml_compact"],"default":"minified"}}}}}},"responses":{"200":{"description":"Cleaned JSON and token reduction metrics"}}}},"/v1/slim/text":{"post":{"summary":"Normalize & Deduplicate Text","description":"Normalizes line breaks, collapses multiple spaces, and strips formatting noise from raw text or prompts.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["text"],"properties":{"text":{"type":"string","example":"This   is   an      unnecessarily \n\n\n\n spaced text prompt."},"deduplicate_spaces":{"type":"boolean","default":true},"collapse_linebreaks":{"type":"boolean","default":true},"strip_markdown_noise":{"type":"boolean","default":false}}}}}},"responses":{"200":{"description":"Slimmed text output"}}}},"/v1/slim/estimate":{"post":{"summary":"Estimate Token Count & Cost Valuation","description":"High-accuracy BPE token estimator and price simulator for OpenAI GPT-4o, Claude 3.5 Sonnet, and Gemini Flash.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["content"],"properties":{"content":{"type":"string","example":"Paste any text or code snippet here to calculate token size and cost."}}}}}},"responses":{"200":{"description":"Token count and cost breakdown"}}}},"/v1/health":{"get":{"summary":"Healthcheck & Capability Status","responses":{"200":{"description":"Service is operational"}}}}}}