v139 · AI · JavaScript
Prompt API
Direct access to Gemini Nano running on-device in Chrome. Text, image, and audio inputs; structured JSON output; no server round-trip, no API key, no network dependency for inference.
concepts
-
Prompt Playground
A chat-style interface that sends your prompts to Gemini Nano via
LanguageModel.create()and streams the response back. Falls back to a simulation when the model isn't available, with step-by-step setup instructions. -
Structured Output Studio
Force the model to respond in strict JSON using
responseConstraint: { type: "json_schema", ... }. Enter a piece of text and see it analyzed and returned as a structured object — sentiment, keywords, a summary — guaranteed valid JSON. -
Multimodal Explorer
Three tabs, one model: send a text prompt, an image plus instruction, or a recorded audio clip. Streams tokens back live and shows the exact request shape per modality.
-
Streaming vs Batch
promptStreaming()yields tokens as Gemini Nano generates them;prompt()waits for the full response. Run both side-by-side and measure the perceived latency difference — time-to-first-token vs total completion time.
why it shipped
Server-side AI inference requires an API key, a network request, latency, and ongoing per-token costs. For use cases that don't need the full power of cloud models — local spell-check, content summarization, form auto-fill, privacy-sensitive user data analysis — a local model is strictly better. Chrome ships with Gemini Nano, a small language model optimized for device execution. The Prompt API exposes it through a standardized JavaScript interface: check availability, create a session with optional system prompt and temperature, send prompts, stream responses. The API is designed to match the emerging W3C Web AI specification so that other browsers can implement the same interface.