Ai Coding Tools

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

By BTW Team4 min read

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

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.


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

How to Improve Code Quality Using AI Tools in Just 1 Hour

How to Improve Code Quality Using AI Tools in Just 1 Hour As a solo founder or indie hacker, you're probably juggling multiple tasks while trying to maintain a high standard in you

Jun 6, 20264 min read
Ai Coding Tools

How to Master GitHub Copilot in Just 30 Minutes: A Quick Guide

How to Master GitHub Copilot in Just 30 Minutes: A Quick Guide If you’re a solo founder or indie hacker, you know that time is money. Learning new tools can feel overwhelming, espe

Jun 6, 20263 min read
Ai Coding Tools

Why GitHub Copilot is Overrated: 7 Common Myths Debunked

Why GitHub Copilot is Overrated: 7 Common Myths Debunked As indie hackers and solo founders, we often look for tools that can give us a competitive edge without breaking the bank.

Jun 6, 20264 min read
Ai Coding Tools

How to Build Your First Project with AI Coding Assistance in 2 Hours

How to Build Your First Project with AI Coding Assistance in 2 Hours Building your first project can feel overwhelming, especially if you're not a seasoned developer. But with the

Jun 6, 20264 min read
Ai Coding Tools

Why GitHub Copilot is Overrated: The Real Deal for Developers

Why GitHub Copilot is Overrated: The Real Deal for Developers As a developer, you might have heard the buzz around GitHub Copilot—its promise of drafting code, suggesting functions

Jun 6, 20264 min read
Ai Coding Tools

Bolt.new vs GitHub Copilot: The Best AI Coding Assistant for Your Workflow

Bolt.new vs GitHub Copilot: The Best AI Coding Assistant for Your Workflow As a solo founder or indie hacker, you know that every moment spent coding is precious. In 2026, the land

Jun 6, 20263 min read