demo · v137

Multi-turn chat & quota

A real LanguageModel session with system prompt, persisting turns, fork-on-branch (session.clone()), and live read-out of tokensSoFar / tokensLeft / maxTokens. Watch the budget tick as the conversation grows.

Origin trialRequires Chrome 137+ with on-device Prompt API. Without it the chat simulates the bookkeeping but answers come from a deterministic stub.
probing…

session quota

tokensSoFar0
tokensLeft
maxTokens

turns

this session0
branches alive0

timings

last latency
avg latency

the code

const session = await window.ai.languageModel.create({
  systemPrompt: "You are a terse Welsh poet…",
  temperature: 0.7,
  topK: 40,
});

await session.prompt("write me three lines about Cardiff in May");

console.log(session.tokensSoFar, session.tokensLeft, session.maxTokens);

const branch = await session.clone();      // fork the chat
await branch.prompt("now about Aberystwyth");

see also