AI Skill Report Card
Implementing Built In Browser AI
Quick Start15 / 15
Check for built-in AI support and use the Summarizer API:
JavaScript// Check if built-in AI is available if ('ai' in window && 'summarizer' in window.ai) { const summarizer = await window.ai.summarizer.create(); const summary = await summarizer.summarize(document.body.textContent); console.log(summary); } else { // Fallback to server-side API fallbackToServerAI(); }
Recommendation▾
Add a reference section with links to browser compatibility tables and API documentation
Workflow13 / 15
Progress:
- Assess use case suitability (simple tasks work best client-side)
- Check browser and API availability
- Implement feature detection and graceful fallback
- Use appropriate task-specific API (Translator, Summarizer, Writer)
- Test across device capabilities and connection states
- Set up hybrid architecture for broader compatibility
Step-by-step Process:
- Feature Detection: Always check if the specific AI API is available before using
- Task Selection: Choose the appropriate task API (Summarizer, Translator, Writer, Rewriter)
- Model Creation: Initialize the AI model for your specific task
- Processing: Execute AI operations with user data
- Fallback Handling: Implement server-side backup for unsupported browsers/devices
- Performance Monitoring: Track client-side vs server-side performance
Recommendation▾
Include performance benchmarks or guidelines for when to choose client-side vs server-side processing
Examples18 / 20
Example 1: Content Summarization
JavaScript// Input: Long article content if ('ai' in window && 'summarizer' in window.ai) { const summarizer = await window.ai.summarizer.create({ type: 'key-points', format: 'markdown', length: 'short' }); const summary = await summarizer.summarize(articleText); displaySummary(summary); }
Example 2: Translation with Fallback
JavaScript// Input: Text to translate async function translateText(text, targetLang) { if ('ai' in window && 'translator' in window.ai) { const translator = await window.ai.translator.create({ sourceLanguage: 'en', targetLanguage: targetLang }); return await translator.translate(text); } else { // Fallback to server API return await fetch('/api/translate', { method: 'POST', body: JSON.stringify({ text, targetLang }) }).then(res => res.json()); } }
Example 3: Hybrid Architecture Setup
JavaScript// Input: User preference and device capability class AIService { constructor() { this.preferLocal = localStorage.getItem('ai-preference') === 'local'; this.hasBuiltInAI = 'ai' in window; } async processContent(content, task) { if (this.hasBuiltInAI && (this.preferLocal || !navigator.onLine)) { return await this.processLocal(content, task); } return await this.processServer(content, task); } }
Recommendation▾
Add a troubleshooting section for common API failures and debugging steps
Best Practices
- Progressive Enhancement: Always implement server-side fallback for broader device support
- Task-Specific APIs: Use specialized APIs (Summarizer, Translator) rather than general Prompt API when possible
- Privacy-First: Leverage client-side processing for sensitive data that shouldn't leave the device
- Performance Testing: Compare client-side vs server-side performance for your specific use cases
- Graceful Degradation: Handle cases where models aren't available or hardware is insufficient
- Connection Awareness: Use
navigator.onLineto decide between client-side and server-side processing - User Control: Let users choose between local and cloud processing when both are available
Common Pitfalls
- Assuming Universal Support: Built-in AI APIs aren't available in all browsers or on all devices
- Ignoring Hardware Limitations: Older or low-power devices may not run models optimally
- Over-relying on Client-side: Complex tasks often require server-side models with more capabilities
- Missing Error Handling: Always handle cases where AI APIs fail or aren't available
- Not Testing Offline: Remember that offline capability is a key benefit—test it thoroughly
- Forgetting Updates: Browser-managed models update automatically, but your code should handle version changes
- Platform Assumptions: Some APIs (like Prompt API) are limited to specific platforms or contexts (Chrome Extensions only)