Ai Coding Tools

How to Create a Simple AI-Powered Web Application in Under 2 Hours

By BTW Team4 min read

Comparing tools? See the AI tools tested on the show.

In short

A step-by-step guide to building a basic AI-powered web application using popular tools, aimed at beginners looking to make something tangible quickly.

Building an AI-powered web application sounds daunting, especially if you're just starting out. The good news? You can actually get a simple one up and running in under two hours. In 2026, with the right tools and a bit of guidance, it's more accessible than ever. Let's dive into how you can make this happen without breaking the bank or losing your sanity.

Prerequisites: What You Need Before You Start

Before we jump into the build, here’s what you need to have:

  • Basic coding knowledge (HTML, CSS, JavaScript)
  • Node.js installed on your machine
  • A code editor (like Visual Studio Code)
  • An account with a cloud service provider (we'll use Vercel for deployment)

Step 1: Set Up Your Development Environment

First, you'll want to create a new directory for your project. Open your terminal and run:

mkdir my-ai-app
cd my-ai-app
npm init -y

This creates a new Node.js project. Next, install the necessary dependencies:

npm install express body-parser axios
  • Express: A minimal web framework for Node.js.
  • Body-parser: Middleware to handle JSON requests.
  • Axios: For making HTTP requests to AI services.

Step 2: Create Your Basic Server

In your project directory, create a file named server.js. This will house your server code. Here’s a simple setup:

const express = require('express');
const bodyParser = require('body-parser');
const axios = require('axios');

const app = express();
app.use(bodyParser.json());

app.post('/api/generate', async (req, res) => {
  const { input } = req.body;
  // Call AI API here (we'll fill this in later)
  res.json({ output: "AI response here" });
});

app.listen(3000, () => {
  console.log('Server running on http://localhost:3000');
});

Step 3: Integrate an AI API

For this tutorial, we’ll use OpenAI's API, which is straightforward and offers a free tier. Here’s how to set it up:

  1. Sign up for OpenAI: Go to OpenAI and create an account.
  2. Get your API key: After signing up, you’ll find your API key in the dashboard.

Now, update your /api/generate endpoint to call OpenAI:

app.post('/api/generate', async (req, res) => {
  const { input } = req.body;
  try {
    const response = await axios.post('https://api.openai.com/v1/chat/completions', {
      model: "gpt-3.5-turbo",
      messages: [{ role: "user", content: input }],
    }, {
      headers: { 'Authorization': `Bearer YOUR_API_KEY` }
    });
    res.json({ output: response.data.choices[0].message.content });
  } catch (error) {
    res.status(500).send('Error generating response');
  }
});

Replace YOUR_API_KEY with your actual OpenAI API key.

Step 4: Create a Simple Frontend

Create a new file named index.html in your project directory:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI Web App</title>
</head>
<body>
    <h1>AI-Powered Web App</h1>
    <input id="input" type="text" placeholder="Ask me anything...">
    <button onclick="generateResponse()">Submit</button>
    <p id="response"></p>

    <script>
        async function generateResponse() {
            const input = document.getElementById('input').value;
            const response = await fetch('/api/generate', {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify({ input }),
            });
            const data = await response.json();
            document.getElementById('response').innerText = data.output;
        }
    </script>
</body>
</html>

Step 5: Run Your Application

In your terminal, run:

node server.js

Now, you can access your application at http://localhost:3000. Type a question in the input box and hit submit. It should return an AI-generated response.

Step 6: Deploy Your Application

For easy deployment, we'll use Vercel. Here’s how:

  1. Sign up for Vercel: Go to Vercel.
  2. Connect your GitHub account.
  3. Push your code to a GitHub repository.
  4. Import your GitHub project into Vercel and follow the prompts to deploy.

Troubleshooting: What Could Go Wrong

  • API Key Issues: Ensure you’ve copied the API key correctly and that your OpenAI account is active.
  • CORS Errors: If you encounter CORS issues, you may need to set up CORS middleware in your Express app.
  • Deployment Errors: Double-check that all necessary files are included in your GitHub repo.

What's Next?

Now that you have a basic AI-powered web app, consider adding features like user authentication or a more complex frontend using React or Vue.js. You can also explore additional AI APIs for different functionalities.

Conclusion: Start Here

Creating an AI-powered web application in under two hours is entirely feasible with the right tools and setup. I recommend starting with the OpenAI API and Vercel for deployment. Remember, the key is to keep it simple at first and build from there.


Watch real AI builds every week

Built This Week is a weekly podcast where Jordan Metzner and Sam Nadler build something real with AI every episode, test new AI tools and talk with founders who build with AI.

See the tools

Watch real AI builds every week

Built This Week is a weekly podcast where Jordan Metzner and Sam Nadler build something real with AI every episode, test new AI tools and talk with founders who build with AI.

See the tools
Ai Coding Tools

3 AI Coding Tools That Are Overrated (and Why You Should Avoid Them)

3 AI Coding Tools That Are Overrated (and Why You Should Avoid Them) In the everevolving landscape of AI coding tools, it's easy to get swept up in the hype. As indie hackers and s

Nov 30, 20263 min read
Ai Coding Tools

5 Ways AI Coding Tools Can Accelerate Your MVP Development in 2026

5 Ways AI Coding Tools Can Accelerate Your MVP Development in 2026 In 2026, the landscape for indie hackers and solo founders has evolved significantly, especially with the advent

Nov 26, 20264 min read
Ai Coding Tools

5 AI Coding Tools That Make Legacy Code Feel Brand New in 2026

5 AI Coding Tools That Make Legacy Code Feel Brand New in 2026 If you’re a developer stuck maintaining legacy code, you know the frustration. It’s like navigating a maze blindfolde

Nov 23, 20264 min read
Ai Coding Tools

10 AI Coding Tools That Will Save You Hours of Debugging in 2026

10 AI Coding Tools That Will Save You Hours of Debugging in 2026 Debugging can feel like a neverending cycle of frustration. Whether you're a solo founder or an indie hacker, spend

Nov 18, 20265 min read
Ai Coding Tools

10 Common Mistakes When Using AI Coding Tools for MVP Development

10 Common Mistakes When Using AI Coding Tools for MVP Development As a founder in 2026, you’re likely aware that AI coding tools can significantly speed up the MVP development proc

Nov 16, 20264 min read
Ai Coding Tools

5 AI Coding Myths Every Beginner Developer Should Ditch in 2026

5 AI Coding Myths Every Beginner Developer Should Ditch in 2026 As a beginner developer, you’ve probably come across a ton of buzz surrounding AI coding tools. But with all the hyp

Nov 12, 20263 min read