Summarizer API for Headlines and Meta Descriptions

▶ Watch (6:01)

The Trail Blazers blog editor uses the summarizer API (shipped in Chrome 138) to generate headlines and SEO meta descriptions. The code creates a summarizer instance with input and output languages set to English, summary type set to headline or teaser, and a preference for speed. It provides context to avoid clickbait. Calling summarize streams the result back chunk by chunk. A real-world partner, the Drupal AI team, uses the same API in their CKEditor for AI-driven content generation.

Prompt API: Tags and Image Captions

▶ Watch (8:19)

For tag generation, the prompt API enforces a JSON schema that limits the model to a predefined list of tags. The response is a JSON object with a tags array. The code creates a language model session, sends a prompt with the blog post text, and passes the schema as a response constraint. The same approach handles multimodal input for image captions: the session includes expectedInputs with an image type, and the prompt includes the image data. Drupal CMS and Cafe24 have implemented similar tag and caption systems in production.

Writer and Rewriter APIs for Draft and Tone

▶ Watch (13:27)

The writer API expands bullet-point notes into a full blog post draft. The code creates a writer instance with shared context, then calls writeStream and iterates over the readable stream. The rewriter API changes tone or shortens text. Options include markdown format, more casual tone, and shorter length. Both APIs are available as a dev trial in desktop Chrome. CyberAgent’s Ameba blogging platform uses a similar rewrite feature for sentence-level suggestion.

Translate API for Multilingual Content

▶ Watch (18:19)

The blog editor uses the translate API to produce Spanish and Japanese drafts from English text. The code creates a translator object with source and target languages, then calls translate. The machine translation is reviewed by native speakers before publishing. The Policybazaar team in India uses a similar pattern: they translate English content into Kannada or Hindi based on the user’s location selection (e.g., Bengaluru → Kannada). The translate API is available in Chrome 138 and Edge.

Comment Moderation with Structured Output

▶ Watch (19:47)

The Trail Blazers blog adds a comment section and uses the prompt API with structured output to flag harmful, illegal, or abusive comments. The JSON schema defines a classification field (safe/illegal/harmful/language) and a reason string. The session system prompt tells the model to act as a comment moderator. If the classification is not safe, an error message is shown. Yahoo Japan’s knowledge search platform uses an identical approach to classify questions for manual moderation.

Key Takeaways

  • Chrome’s built-in AI APIs (summarizer, prompt, writer, rewriter, translate) run entirely on device, keeping data private.
  • The summarizer and translate APIs are stable in Chrome 138; writer and rewriter are dev trial only.
  • The prompt API with JSON schema enforces structured responses, enabling tag generation, image captions, and comment moderation.
  • Firebase AI Logic Hybrid SDK provides polyfills for unsupported platforms like mobile.

Notable Quotes

For us, multimodal was not just an additional feature, it was the key result to quality. Group leader of product generation group at Cafe24 · ▶ Watch (11:15)

We extended the LMT base blog by the Built Awesome team. Thomas Steiner · ▶ Watch (25:20)

If you start building with the built-in AI APIs, a quick reminder that we maintain TypeScript types for all APIs. Thomas Steiner · ▶ Watch (26:33)