v148 · AI · JavaScript

Quality Control Panel

Benchmark the Prompt API across four dimensions: first-token latency, total response time, context window usage, and output quality. Tune temperature and topK, then see how those parameters affect speed and coherence.

Avg first-token (ms)
Avg total (ms)
Context tokens used
Inference mode
Parameters
Temperature
0.50
Top-K
40
Benchmark suite
// Measuring Prompt API performance const session = await window.ai.languageModel.create({ temperature: 0.5, topK: 40, }); // First-token latency: time to first streamed chunk const firstToken = { time: null }; const t0 = performance.now(); const stream = await session.promptStreaming(prompt); let result = ''; for await (const chunk of stream) { if (!firstToken.time) firstToken.time = performance.now() - t0; result = chunk; } const totalMs = performance.now() - t0; // Context window: session.tokensSoFar / session.maxTokens console.log({ firstToken, totalMs, tokensUsed: session.tokensSoFar });

see also

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗