Home / AI GameChanger / Building AI Apps
๐Ÿ› ๏ธ Building AI Apps

Build Your First AI App with an LLM API

Beginner โฑ 6 min read ๐Ÿ“˜ Lesson 28 of 33

You don't need to train anything to build AI products โ€” you call a hosted model over HTTP. Here is a complete, real AI feature.

The request shape (same idea across providers)

# Python โ€” using an LLM chat API
import requests

resp = requests.post("https://api.provider.com/v1/messages",
  headers={"x-api-key": API_KEY, "content-type": "application/json"},
  json={
    "model": "a-capable-model",
    "max_tokens": 500,
    "messages": [
      {"role": "system", "content": "You summarise text in 3 bullet points."},
      {"role": "user",   "content": user_text},
    ],
  })
print(resp.json()["content"])

From the browser (JavaScript)

const res = await fetch("/api/summarize", {   // call YOUR backend, not the LLM directly
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ text }),
});
const { summary } = await res.json();
Security rule #1: NEVER put your API key in frontend code โ€” anyone can steal it and run up your bill. The browser calls your backend; your backend holds the key and calls the LLM. See managing secrets.

Streaming โ€” the ChatGPT typing effect

For chat UIs, request a stream so tokens appear as they're generated instead of waiting for the whole response. It's Server-Sent Events under the hood (SSE explained) โ€” the reason ChatGPT feels fast.

Project ideas you can ship this weekend

  • Text summariser / email drafter
  • Study-notes โ†’ flashcards generator
  • Code explainer for beginners
  • Resume-to-JSON parser

Deploy free (hosting guide) and it's a portfolio piece that gets interviews.