Window.ai
How to integrate JigsawStack with the window.ai API for browser-based AI capabilities
Models
Explore our complete list of models and API references here.
Overview
The window.ai
Chrome API introduces native AI capabilities that run locally within the browser environment. While Chrome’s native implementation is still in its early stages (available in Chrome Canary) with limited capabilities, JigsawStack extends this concept by providing a comprehensive suite of powerful AI utilities through the same familiar interface.
By integrating JigsawStack with the window.ai
object, you can:
- Provide consistent AI capabilities across all browsers
- Access advanced AI features beyond what’s natively available
- Create seamless browser-based AI experiences for your users
Prerequisites
Before integrating JigsawStack with window.ai, you’ll need:
- A JigsawStack account
- Your JigsawStack Public API key
For client-side browser integration, always use your public key
instead of your secret key.
You can enhance security by restricting the public key
to specific APIs or domains.
Learn more about public vs. secret API keys.
Integration
Basic Setup
Add JigsawStack to your browser application and assign it to the window.ai object:
For script tag inclusion:
TypeScript Support
For TypeScript projects, add proper typing for the window.ai object:
Using window.ai
Once integrated, you can access all JigsawStack capabilities through the window.ai object:
Sentiment Analysis
Text Translation
Text Summarization
Image Generation
Complete Example
Here’s a complete example showing how to integrate JigsawStack with window.ai in a web application:
Fallback Strategy
To create a resilient application that works with both native window.ai (when available) and JigsawStack:
Browser Compatibility
JigsawStack’s window.ai integration works across all major browsers:
- Chrome
- Firefox
- Safari
- Edge
- Opera
This provides consistent AI capabilities regardless of native browser AI support.