Create Your Own Local AI Using Browser APIs

Andrew - Sep 13 - - Dev Community

Introduction

Have you ever wanted to build your own AI without worrying about backend infrastructure? With the latest advancements in browser technology, you can now run AI directly in your browser, leveraging native APIs and hardware. What's more, this setup works offline—no internet connection required!

Here’s a quick guide to get you started with creating a local AI in Chrome:

Enable Experimental Web Features

First, you need to enable experimental web platform features in Chrome. Follow these steps:

Navigate to this URL.
Check the box for "Necessary experimental flags" (you’ll see three steps to follow).

Use the AI SDK

Once you've enabled the experimental features, you can start using the AI SDK directly in your browser’s console.

Open the console and run the following code to create a new AI session and interact with it:

// Create a new AI session
const session = await ai.createTextSession();

// Create a prompt
const response = await session.prompt("What are black holes?");

// Log the response
console.log(response);
Enter fullscreen mode Exit fullscreen mode

And there you have it! You’ve just set up a local AI running directly in your browser.

Feel free to experiment further and explore the potential of browser-based AI. Happy coding!

. . .
Terabox Video Player