🪄 Easy Language Model

A near drop-in wrapper for the Prompt API's LanguageModel: Sanitizer API on every response, streaming HTML output, in-place session compacting, always-on download reporting, and user activation handled for you.

This demo needs two flags enabled in Chrome:

Tool use
chrome://flags/#prompt-api-tool-use
Gemma 4
chrome://flags/#gemma4-for-built-in-ai
checking Checking availability…

Try the tools: — several calls over a couple of rounds, and no loop in this page's code.

Try an injection: — it arrives as text, never as an element.

Everything below comes from one promptStreaming() call, so one prompt is one inference. tee() splits it: the raw Markdown goes to the right, and the other branch runs through markdownToHtml() into renderStreamingHTML() to build the DOM on the left, tapped by a TransformStream on the way past for the listing beside them.

renderStreamingHTML() live HTML

promptStreaming() raw Markdown chunks


        

markdownToHtml() raw HTML chunks


        
Library events
    session.history, as JSON