Ai Coding Tools

How to Build a Simple AI-Powered Web App in Under 2 Hours

By BTW Team4 min read

How to Build a Simple AI-Powered Web App in Under 2 Hours

If you’ve ever thought about building an AI-powered web app but felt overwhelmed by the complexity, you’re not alone. Many indie hackers and solo founders face the same dilemma: how to leverage AI without getting bogged down in intricate coding and long development cycles. The good news? You can build a simple AI-powered web app in under 2 hours, even if you’re not a coding wizard.

In this guide, I’ll walk you through the tools you need, the steps to take, and the common pitfalls to avoid.

Prerequisites: What You Need Before You Start

  • A basic understanding of web development: Know your way around HTML, CSS, and JavaScript.
  • An account on a cloud service like Vercel or Netlify (both free for small projects).
  • API access to an AI service: I'll recommend several options below.
  • A code editor: Visual Studio Code is a solid choice and free.

Step 1: Choose Your AI API

To power your web app, you’ll need an AI API. Here are some options to consider:

| Name | Pricing | Best For | Limitations | Our Take | |-------------------|----------------------|-------------------------------|-------------------------------------------|--------------------------------| | OpenAI GPT-3 | $0.002/1k tokens | Natural language processing | Can get expensive with heavy usage | We use it for chatbots. | | Hugging Face | Free tier + $9/mo | NLP and image processing | Limited features on free tier | Great for experimentation. | | IBM Watson | $0-200/mo | Enterprise-level AI solutions | Complexity can be daunting | We don’t use it; too complex. | | Google Cloud AI | $0-150/mo | Machine learning models | Pricing can escalate quickly | We use it for image analysis. | | Azure Cognitive Services | $0-100/mo | Various AI functionalities | Steeper learning curve | We don’t use it; prefer simpler options. |

Step 2: Set Up Your Development Environment

  1. Create a new project: Use your code editor to create a new folder for your project.
  2. Initialize with a package manager: Run npm init -y to create a package.json file.
  3. Install essential packages: Use npm install express axios dotenv for setting up a simple server and making API requests.

Step 3: Build Your Web App

  1. Create your server: In your project folder, create a file called server.js. Here’s a simple Express server setup:

    const express = require('express');
    const axios = require('axios');
    const dotenv = require('dotenv');
    dotenv.config();
    
    const app = express();
    app.use(express.json());
    
    app.post('/api/query', async (req, res) => {
        const response = await axios.post('YOUR_AI_API_URL', {
            data: req.body.input
        }, {
            headers: {
                'Authorization': `Bearer ${process.env.API_KEY}`
            }
        });
        res.json(response.data);
    });
    
    const PORT = process.env.PORT || 5000;
    app.listen(PORT, () => console.log(`Server running on port ${PORT}`));
    
  2. Create a simple frontend: In the same project folder, create an index.html file. Here’s a basic setup:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>AI Web App</title>
    </head>
    <body>
        <input id="input" type="text" placeholder="Ask me anything...">
        <button onclick="submitQuery()">Submit</button>
        <div id="response"></div>
        <script>
            async function submitQuery() {
                const input = document.getElementById('input').value;
                const res = await fetch('/api/query', {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/json' },
                    body: JSON.stringify({ input })
                });
                const data = await res.json();
                document.getElementById('response').innerText = data.response;
            }
        </script>
    </body>
    </html>
    

Step 4: Deploy Your Web App

  1. Push to GitHub: Initialize a Git repository and push your code to GitHub.
  2. Deploy using Vercel or Netlify: Both platforms allow you to connect your GitHub repo and deploy with a few clicks.

Troubleshooting: What Could Go Wrong

  • API Key Issues: Ensure your API key is valid and added to your .env file.
  • CORS Errors: If you run into CORS issues, you might need to configure your API or use a CORS proxy for development.
  • Server not starting: Check for errors in your console; ensure all required packages are installed.

What's Next?

Once your simple AI-powered web app is up and running, consider enhancing it with additional features. You could:

  • Add user authentication to personalize the experience.
  • Integrate more complex AI models for richer interactions.
  • Collect user data to improve your app over time.

Building an AI-powered web app doesn’t have to be daunting. With the right tools and a clear plan, you can create something valuable in just a couple of hours.

Conclusion: Start Here

If you’re ready to dive in, start by choosing your AI API and setting up your development environment. The tools are more accessible than ever in 2026, and your first AI web app is just a few steps away.

Follow Our Building Journey

Weekly podcast episodes on tools we're testing, products we're shipping, and lessons from building in public.

Subscribe

Never miss an episode

Subscribe to Built This Week for weekly insights on AI tools, product building, and startup lessons from Ryz Labs.

Subscribe
Ai Coding Tools

Bolt.new vs GitHub Copilot: Which AI Tool Reigns Supreme for 2026 Developers?

Bolt.new vs GitHub Copilot: Which AI Tool Reigns Supreme for 2026 Developers? As we dive into 2026, developers are bombarded with AI tools promising to revolutionize coding. But wi

Apr 29, 20263 min read
Ai Coding Tools

Lovable vs Cursor: Which AI Coding Assistant Is Better in 2026?

Lovable vs Cursor: Which AI Coding Assistant Is Better in 2026? If you're a solo founder or indie hacker in 2026, chances are you're grappling with the challenge of writing code ef

Apr 29, 20263 min read
Ai Coding Tools

Cursor vs GitHub Copilot: Which AI Tool is Best for Experienced Coders in 2026?

Cursor vs GitHub Copilot: Which AI Tool is Best for Experienced Coders in 2026? As experienced coders, we often find ourselves in a tugofwar between productivity and quality in our

Apr 29, 20263 min read
Ai Coding Tools

How to Boost Your Coding Skill with AI in 30 Days

How to Boost Your Coding Skill with AI in 30 Days If you’re like many indie hackers or solo founders, you know that coding skills can make or break your project. But let’s be real:

Apr 29, 20265 min read
Ai Coding Tools

Why Claude Code is Overrated for Seasoned Developers

Why Claude Code is Overrated for Seasoned Developers As a seasoned developer, you’ve probably seen the rise and fall of various coding tools that promise to revolutionize how we wr

Apr 29, 20264 min read
Ai Coding Tools

Why Most Developers Overlook AI Coding Tools (And They’re Doing It Wrong)

Why Most Developers Overlook AI Coding Tools (And They’re Doing It Wrong) In 2026, AI coding tools are no longer just a novelty; they’re a necessity. Yet, many developers still ove

Apr 29, 20264 min read