DEV Community

Shashi Kiran
Shashi Kiran

Posted on

🚀 Build Your First AI App for Free (Beginner Friendly Guide)

Getting started with AI doesn’t have to be expensive or complicated.

In this guide, we’ll build a simple AI-powered app using completely free tools.


🧠 What You’ll Build

A simple app that:

  • Takes user input
  • Sends it to an AI model
  • Returns a response

Basically your own mini ChatGPT.


🛠️ Tech Stack (Free)

  • Ollama → Run AI locally (no API cost)
  • Python + FastAPI → Backend
  • HTML → Simple frontend

⚙️ Step 1: Install Ollama

Download: https://ollama.com

Run:

ollama run llama3
Enter fullscreen mode Exit fullscreen mode

This starts your local AI model.


⚙️ Step 2: Create Backend

Create a file:

main.py
Enter fullscreen mode Exit fullscreen mode

Add this:

from fastapi import FastAPI
import requests

app = FastAPI()

@app.get("/")
def home():
    return {"message": "AI App is running"}

@app.get("/ask")
def ask_ai(question: str):
    response = requests.post(
        "http://localhost:11434/api/generate",
        json={
            "model": "llama3",
            "prompt": question
        }
    )

    data = response.json()
    return {"answer": data["response"]}
Enter fullscreen mode Exit fullscreen mode

▶️ Step 3: Run App

pip install fastapi uvicorn requests
uvicorn main:app --reload
Enter fullscreen mode Exit fullscreen mode

Open:
http://127.0.0.1:8000


🧪 Step 4: Test

Open in browser:

http://127.0.0.1:8000/ask?question=Explain Python simply
Enter fullscreen mode Exit fullscreen mode

🎨 Step 5: Simple UI (Optional)

Create index.html:

<!DOCTYPE html>
<html>
<head>
  <title>AI App</title>
</head>
<body>
  <h2>Ask AI</h2>
  <input id="q" placeholder="Type question"/>
  <button onclick="ask()">Ask</button>

  <pre id="res"></pre>

  <script>
    async function ask() {
      const q = document.getElementById("q").value;
      const res = await fetch(`/ask?question=${q}`);
      const data = await res.json();
      document.getElementById("res").innerText = data.answer;
    }
  </script>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

💡 What You Can Build Next

  • AI chatbot
  • Resume analyzer
  • Interview prep tool
  • Code assistant

⚠️ Common Issues

  • Ollama not running
  • Wrong endpoint
  • Missing dependencies

🧠 Final Thought

You don’t need expensive APIs to start with AI.

Start small → build → improve.


🚀 Try This Today

What will you build with this? 👇

Top comments (0)