Three Markdown Services, Three Integrations
AI agents, crawlers, and LLM-powered search engines tokenize everything they receive. Raw HTML is expensive: Cloudflare measured a single blog post at 16,180 tokens in HTML versus 3,150 in Markdown, an 80% reduction. At scale, the savings in context window budget and inference cost are substantial.
Cloudflare shipped three services for HTML-to-Markdown conversion: Markdown for Agents (edge content negotiation), Workers AI toMarkdown (binary file conversion), and Browser Rendering (headless Chromium for JS-heavy pages). Each has its own REST endpoint, auth pattern, and response format. Wiring them individually means duplicating HTTP client setup, error handling, response parsing, and caching across each integration.
The Solution
This package wraps all three services behind a single fluent interface with a driver-based architecture. Each Cloudflare service maps to a driver (agents, workers_ai, browser), and the package handles HTTP client setup, authentication, response normalization, caching, and error recovery. The same ConversionResult DTO is returned regardless of which backend handled the request.
The package also includes a middleware that implements Cloudflare's content negotiation pattern on your own Laravel routes. When a request includes Accept: text/markdown, the middleware converts your HTML response to Markdown locally using league/html-to-markdown. No Cloudflare API calls, no external dependencies. Make your Laravel app agent-ready with a single middleware.