AI Learning Courses
AI Learning Courses › Chapters › Chapter 11
CHAPTER 11 OF 15

Building Applications with AI

You do not need to train your own model to build a powerful AI product. Today most AI apps are built by connecting to an existing model through an API and adding your own data, design and logic. This chapter shows you how.

▶ Watch the 12 narrated lessons Take the chapter quiz

Three ways to build with AI ▶ Watch

ApproachWho it suitsExamples of tools
No-code automationNon-programmers, quick workflowsZapier, Make, n8n with AI steps
Low-code / AI app buildersFounders, makers, prototypesPrompt-to-app builders, custom GPT-style assistants
Code with AI APIsDevelopers, full control and scaleClaude API, OpenAI API, Gemini API, open-weight models

The architecture of an AI application ▶ Watch

A typical AI application: the frontend talks to your backend, which calls the AI model and other services.
A typical AI application: the frontend talks to your backend, which calls the AI model and other services.
▶ Play this diagram as a visual lesson
  1. The user types a question in your app.
  2. The frontend (web page or mobile app) sends it to your backend.
  3. The backend adds instructions (a system prompt), maybe relevant data, and calls the AI model API using a secret API key.
  4. The model returns an answer; the backend saves it if needed and sends it to the frontend.
  5. Optional extras: a database for users and history, a vector database for your own knowledge, and tools the AI can use.

Your first AI program (Python) ▶ Watch

Most AI providers offer an official software development kit (SDK). The pattern is almost identical everywhere: create a client, send a list of messages, read the reply. Here is an example using Anthropic's Python SDK. Install it with pip install anthropic and set your key in the ANTHROPIC_API_KEY environment variable.

import anthropic

client = anthropic.Anthropic()   # reads ANTHROPIC_API_KEY

reply = client.messages.create(
    model="claude-sonnet-5-5",   # check the docs for current names
    max_tokens=500,
    system="You are a friendly tutor for beginners.",
    messages=[
        {"role": "user",
         "content": "Explain photosynthesis in 3 sentences."}
    ],
)
print(reply.content[0].text)

The OpenAI and Gemini SDKs follow the same idea with slightly different function names. Because model names change often, always copy the current model identifier from the provider's documentation.

A simple backend for a web app (Flask) ▶ Watch

from flask import Flask, request, jsonify
import anthropic

app = Flask(__name__)
client = anthropic.Anthropic()

@app.post("/ask")
def ask():
    question = request.json["question"]
    reply = client.messages.create(
        model="claude-sonnet-5-5",
        max_tokens=600,
        system="You are a helpful study assistant.",
        messages=[{"role": "user", "content": question}],
    )
    return jsonify(answer=reply.content[0].text)

Teaching AI your own knowledge: RAG ▶ Watch

A general model does not know your company's policies, your course notes or yesterday's prices. Retrieval-Augmented Generation (RAG) solves this by finding the right information first and giving it to the model together with the question.

Retrieval-Augmented Generation: prepare your documents once, then retrieve relevant passages for every question.
Retrieval-Augmented Generation: prepare your documents once, then retrieve relevant passages for every question.
▶ Play this diagram as a visual lesson

AI agents and tool use ▶ Watch

An AI agent works in a loop: plan, act with a tool, observe the result, and check whether the goal is reached.
An AI agent works in a loop: plan, act with a tool, observe the result, and check whether the goal is reached.
▶ Play this diagram as a visual lesson

With tool use (also called function calling), you describe functions to the model - for example get_weather(city) or search_orders(email). The model decides when to call them, your code runs them, and the results go back to the model. An agent repeats this loop on its own until the task is done. The Model Context Protocol (MCP) is an open standard that makes it easier to connect AI apps to tools and data sources.

Popular frameworks ▶ Watch

Costs, speed and quality ▶ Watch

ConcernPractical tip
CostAPIs charge per input and output token; use smaller models for simple tasks and keep prompts lean.
SpeedStream responses so users see text as it is generated; cache repeated prompts.
QualityWrite clear system prompts, test with real examples, and evaluate before launch.
SafetyFilter harmful input and output, limit what tools can do, and log activity.
PrivacyTell users what is sent to AI providers and check each provider's data-use terms.

Chapter summary

  • Most AI apps connect to existing models via APIs rather than training new ones.
  • Keep the API key on the backend; the frontend talks only to your server.
  • RAG gives a model your own knowledge; tools and agents let it take actions.
  • Manage cost, speed, quality, safety and privacy from day one.