The AI Landscape for Web Developers — AI Web

Web developers use an AI model (a program trained on a very large number of examples) by calling it, not training it. There are three ways. First, your server…

The Bookshop, the online shop this track uses as its example, doesn't start its own courier company just to send parcels. Its program calls the courier's API and gives it the address, and the shop pays postage per parcel. An API is a door that a service opens so that other programs can ask it for something over the internet.

You use AI the same way. Here the courier is an AI model: a program that was trained on a very large number of examples until it could do one kind of task, such as writing an answer. As a web developer you almost never train an AI model. You call it. Your program sends an HTTP request with some text to a provider's server, the server sends an answer back, and the provider bills you for what you use. Three words in that sentence:

The unit you pay for is the token: a small piece of text, covered in the next lesson.

The example we build across the track

We continue the Bookshop API from the API track (https://api.bookshop.test). Across this AI track the Bookshop gets a Bookshop assistant: customers can ask about stock in their own words, ask for book recommendations based on each book's synopsis, and chat in a chat window. The book data:

id Title Author Price Stock One-line synopsis
1 The Rainbow Troops Andrea Hirata $18 12 Ten children from poor families on Belitung attend a Muhammadiyah primary school that is about to be closed, guided by their teacher, Mrs. Mus.
2 This Earth of Mankind Pramoedya Ananta Toer $25 0 Minke, a native youth at the HBS school in Surabaya at the end of the 19th century, falls in love with Annelies, daughter of Nyai Ontosoroh, under an unjust colonial law.
3 Beauty Is a Wound Eka Kurniawan $22 5 The story of Dewi Ayu and her descendants in the fictional town of Halimunda, from Dutch colonial times to after 1965, told in a magical realist style.

A fourth book joins later: The Dancer by Ahmad Tohari, with the synopsis "Srintil becomes a ronggeng, a traditional dancer, in the small hamlet of Dukuh Paruk, and her life is swept up in the political upheaval of 1965."

Three ways a web developer uses AI

  1. Calling a model over HTTP. Your server sends text to a provider, and the provider sends answer text back. This is the most common way: answering stock questions, summarising reviews and drafting product descriptions. The model is called an LLM (Large Language Model): a model trained on a very large amount of text until it can understand and write language.
  2. Embeddings. A model turns text into a list of numbers (called an embedding, or a vector). Two texts with similar meanings get numbers that are close together. The Bookshop uses embeddings for recommendations. Each book's synopsis is turned into numbers once. When a customer asks for "a novel about a school in a village", that request is turned into numbers too, and the search finds the synopsis whose numbers are closest. Embeddings are also called over HTTP, and are very cheap.
  3. On the user's device (on-device). A small model runs inside the user's browser. So the text never leaves the device, and there is no bill per call. Examples are Chrome's built-in Translator API and Summarizer API. The downsides: the models are smaller, must be downloaded on first use, and only some browsers have them (the Translator API, for example, is only in desktop Chrome).

The first way has one variation: open-weight models, for example Gemma, Qwen and Llama. Their weights (the numbers inside a model that training produces) may be downloaded, so you can run the model on your own server with a program called Ollama. There is no bill per token, but you pay for and maintain the server and its GPU (the processor that runs the model) yourself.

One request to a model

This is a request for the first way, from the Bookshop's server to OpenAI. It has the same shape as a request to the Bookshop API. The last line is its content, written as JSON (a data format that looks like a JavaScript object):

POST /v1/responses HTTP/1.1
Host: api.openai.com
Authorization: Bearer sk-...secret...
Content-Type: application/json

{"model": "gpt-6-luna", "instructions": "You are the Bookshop assistant. Answer only from the stock data.", "input": "Is The Rainbow Troops still in stock?\n\nStock data: The Rainbow Troops 12, This Earth of Mankind 0, Beauty Is a Wound 5"}

What AI does, and what stays plain code

A customer asks the Bookshop assistant, "Is The Rainbow Troops still in stock?", and gets the answer "Yes, we have 12." Where does the 12 come from: from the AI model, or from the Bookshop database (where the shop stores its data)? Guess first, then follow the question from start to finish:

Step Who AI?
1. The browser sends the question to POST /api/assistant Plain code No
2. The server fetches the stock: SELECT title, stock FROM books Plain code (an SQL query) No
3. The server sends the question plus the stock data to the model The AI model Yes: understands free-form wording, writes the answer
4. The server sends the answer back to the browser Plain code No

The 12 comes from the database. In step 2, the server fetches it with an SQL query, which is a command that gets data from a database. The model doesn't know what is in your warehouse. If the stock data is not sent, the model can still answer confidently, but the number is made up. A made-up answer that sounds confident is called a hallucination.

So AI has two roles in modern web development. First, AI is automating repetitive work that used to need a person to read text: answering the same question hundreds of times, summarising reviews, writing drafts. Second, AI is making the user experience nicer (searching in your own words, recommendations, chat). AI doesn't replace all of a developer's work. AI is also no substitute for code whose result must be exactly right: SQL queries, routing (choosing the code that handles each address) and price calculations.

Providers and models, as of November 2026

Model names and prices change very quickly. The figures below were checked on 15 November 2026 on each provider's own pages. Each cell holds two prices per 1 million tokens: the input price (the text you send, also called the prompt), then the output price (the text the model answers with):

Provider Budget model Model suggested to start with Source
OpenAI gpt-6-luna: $0.10 / $0.50 gpt-6-astra: $10 / $50 the "Pricing" and "Models" pages, developers.openai.com
Anthropic claude-haiku-5-5: $0.10 / $0.50 (prompts up to 100,000 tokens) claude-opus-5-5: $4 / $20 the "Pricing" and "Models overview" pages, platform.claude.com
Google gemini-3.5-flash-lite: $0.30 / $2.50 gemini-4-hydrogen: $1.50 / $7.50 (released 12 November 2026). The previous generation, gemini-3.8-flash: $0.75 / $3.75 until 31 December 2026, then $1.50 / $7.50 the "Gemini Developer API pricing" and "Models" pages, ai.google.dev
Open-weight through Ollama gemma4, qwen3, llama3.2, gpt-oss free per token, your own server ollama.com/library

For embeddings, OpenAI's model text-embedding-3-small costs $0.02 per 1 million tokens (OpenAI's "Pricing" page, October 2026). The Translator API, Language Detector API and Summarizer API are in stable Chrome since Chrome 138 (Chrome's "Built-in AI APIs" page, checked October 2026).

The Bookshop assistant uses gpt-6-luna. OpenAI calls it its most efficient model for focused tasks done in large numbers. Calculate the cost. One question uses roughly 400 input tokens and 40 output tokens. With gpt-6-luna, one question costs (400 × 0.10 + 40 × 0.50) / 1,000,000 = $0.00006. With 10,000 questions a day, that is $0.60 a day. With gpt-6-astra the same maths gives $60 a day, 100 times as much.

⚠️ Shop data, API keys, price and privacy

TL;DR: Web developers use an AI model (a program trained on a very large number of examples) by calling it, not training it. There are three ways. First, your server sends an HTTP request (a message over the internet) with some text to a provider, the company that owns the model: POST + JSON + an API key (the secret key used for billing) in a header (a line of details at the start of the request). Second, embeddings: text is turned into a list of numbers so it can be searched by meaning. Third, a small model runs on the user's device. AI automates repetitive text work and makes the user experience nicer. SQL queries (commands to the database), routing (choosing the code for each address) and price calculations stay plain code. The model doesn't know your shop's data, so send the data in the request. If you don't send it, the model makes up an answer (hallucination). The API key may only be on the server. As of October 2026, prices per 1 million tokens (small pieces of text), for the text you send / the answer text: OpenAI gpt-6-luna $0.10 / $0.50, Anthropic claude-haiku-5-5 $0.10 / $0.50, Google gemini-3.5-flash-lite $0.30 / $2.50. Prices and model names change fast, so always check the official pages.

⚡ Called, not trained

Meaning: A web developer almost never trains an AI model (a program that learns from a very large number of examples). You call a model that is already trained: your server sends an HTTP request (a message over the internet) with some text to a provider (the company that owns the model, such as OpenAI, Anthropic or Google). The provider sends an answer back, then bills you per token (a small piece of text).

⚡ One request to a model

Write:

POST /v1/responses HTTP/1.1
Host: api.openai.com
Authorization: Bearer sk-...secret...
Content-Type: application/json

{"model": "gpt-6-luna", "instructions": "You are the Bookshop assistant. Answer only from the stock data.", "input": "Is The Rainbow Troops still in stock?\n\nStock data: The Rainbow Troops 12, This Earth of Mankind 0, Beauty Is a Wound 5"}

Meaning: This is a request to OpenAI for an answer. model picks the model, instructions holds your rules, and input holds the customer's question plus the stock data. The Authorization line carries the API key: a secret key that decides who gets billed. Anyone can read code in the browser, so the API key may only be on the server.

⚡ Where does the 12 come from?

Guess first: a customer asks "Is The Rainbow Troops still in stock?" and gets "Yes, we have 12." Does the 12 come from the AI model or from the Bookshop database, where the shop stores its data?

From the database. The server fetches it with the SQL query SELECT title, stock FROM books (a command to the database), then sends it to the model inside input. The model doesn't know what is in your warehouse. Without the stock data the model still answers confidently, but the number is made up (hallucination).

Meaning: AI handles free-form text: understanding the question, writing the answer. SQL queries, routing (choosing the code that handles each address) and price calculations stay plain code, because their result must be exactly right.

⚡ A cheap model for a simple job

Meaning: One stock question uses roughly 400 input tokens (the text you send) and 40 output tokens (the answer text). With the budget model gpt-6-luna, 10,000 questions a day cost $0.60. With a stronger model, gpt-6-astra, the cost is $60 a day, 100 times as much.

What you will learn