Ai Coding Tools

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

By BTW Team4 min read

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

In short

A step-by-step tutorial for beginner developers on building an AI-powered web application quickly using popular tools.

If you're like me, you've probably stared at a blank screen, wondering how to bring your AI web app idea to life. The good news is that with the right tools and a bit of guidance, you can build a simple AI-powered web app in just 2 hours. In this guide, I'll walk you through the process, sharing the exact tools we use, their pricing, and why they work for us.

Prerequisites: What You Need Before You Start

Before diving in, make sure you have the following:

  1. Basic coding knowledge: Familiarity with HTML, CSS, and JavaScript will help.
  2. An IDE: I recommend using Visual Studio Code (it's free).
  3. A cloud service account: We’ll use platforms like Google Cloud or AWS for hosting.
  4. APIs: Access to an AI API (like OpenAI or Hugging Face) for your app’s functionality.

Step 1: Choose Your AI API

The first step is selecting an AI API that suits your app's purpose. Below is a comparison of popular AI APIs to help you choose.

| API Name | Pricing | Best For | Limitations | Our Take | |------------------|----------------------------|--------------------------------|------------------------------|-----------------------------------| | OpenAI GPT-3 | $0.002 per token | Natural language processing | Can get expensive with high usage | We use this for text generation. | | Hugging Face API | Free tier + $10/mo for pro| NLP and image processing | Limited free tier capabilities | We don’t use it because of the limits. | | IBM Watson | Free tier + $120/mo | Language understanding | Complex setup | We skipped it due to the cost. | | Google Cloud AI | Free tier + $50/mo | Image and video analysis | Pricing can escalate quickly | We like it for image recognition. | | Azure Cognitive Services | Free tier + $50/mo | Various AI services | Complicated pricing structure | We don’t use it due to complexity. |

Step 2: Set Up Your Development Environment

  1. Create a new project in your IDE.
  2. Install necessary libraries. For a JavaScript-based app, you might need:
    • Axios for API calls: npm install axios
    • Express for server setup: npm install express
  3. Set up a simple server using Express:
const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;

app.use(express.json());

app.listen(PORT, () => {
  console.log(`Server running on port ${PORT}`);
});

Step 3: Integrate the AI API

  1. Set up your API key from the service you chose. Store it securely.
  2. Create a route to handle requests. Here’s how to set up a basic endpoint using OpenAI:
const axios = require('axios');

app.post('/api/generate', async (req, res) => {
  const { prompt } = req.body;
  const response = await axios.post('https://api.openai.com/v1/completions', {
    prompt,
    max_tokens: 100
  }, {
    headers: {
      'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`
    }
  });

  res.json(response.data);
});

Step 4: Build the Frontend

  1. Create a simple HTML form to take user input and display results:
<form id="ai-form">
  <input type="text" id="prompt" placeholder="Enter your prompt" required />
  <button type="submit">Generate</button>
</form>
<div id="result"></div>
  1. Add JavaScript to handle form submission and display results:
document.getElementById('ai-form').addEventListener('submit', async (e) => {
  e.preventDefault();
  const prompt = document.getElementById('prompt').value;
  const response = await fetch('/api/generate', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ prompt })
  });
  const data = await response.json();
  document.getElementById('result').innerText = data.choices[0].text;
});

Step 5: Deploy Your App

  1. Choose a hosting platform: For simplicity, you can use Heroku or Vercel.
  2. Follow the platform’s deployment instructions. For Heroku, it’s as simple as:
heroku create
git push heroku main

Troubleshooting: What Could Go Wrong

  • API Key Issues: Ensure your API key is valid and has the necessary permissions.
  • CORS Errors: If you encounter Cross-Origin Resource Sharing (CORS) issues, you may need to adjust your server settings.
  • Rate Limits: Be aware of the API's rate limits; exceeding them can cause your app to fail.

What's Next?

Once you've built your web app, consider enhancing its features. You could add user authentication, improve the UI, or integrate more APIs for additional functionality.

Conclusion: Start Here

If you’re looking to create a simple AI-powered web app quickly, follow these steps. Focus on choosing the right AI API that fits your budget and project needs. With the tools and framework outlined above, you can have your app up and running in just 2 hours.

What We Actually Use: For our projects, we typically use OpenAI for text generation due to its flexibility and straightforward API. We host our apps on Vercel for easy deployment and scaling.

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