DEV Community

Andrew
Andrew

Posted on

1

Create Your Own Local AI Using Browser APIs

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!

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay