← Back home
LESSON 018AI Development9 min

What is an API? Think of a restaurant order window between your app and an AI model

An API lets software request a capability from another service through a defined interface. Lesson 018 uses an order-window analogy to explain requests, responses and API keys.

Today’s analogya restaurant order window that accepts a defined order and returns the finished item

Suppose you build a small app that summarizes meeting notes.

You do not necessarily need to download and run a large language model on your own computer. Your app can send the text to an AI provider over the internet and receive a summary back.

The connection is usually made through an Application Programming Interface (API).

An API is a defined way for software to ask another system for something

Think of a restaurant order window.

You do not walk into the kitchen and operate the stove yourself. You submit an order in a format the restaurant understands. The kitchen performs the work and returns the result.

An API plays a similar role between programs.

Your application sends a request. The remote service performs some operation. It returns a response.

What is inside an API request?

The exact format depends on the service, but an AI request often includes:

The destination you call is often referred to as an endpoint.

What is an API key?

Many services issue an API key, a secret credential that identifies and authorizes your account or project.

It is closer to a password than to a username.

Do not paste a private API key into public GitHub code, a screenshot or a browser-side script that every visitor can inspect.

Production applications usually store secrets on the server or in a secret-management system.

The response is often structured data

An API does not need to return a web page. It often returns data in a machine-readable format such as JSON.

That allows your program to extract fields, display text, save usage information or trigger the next step automatically.

This is one reason APIs are important for automation: the result is meant to be consumed by software, not only read by a person.

API versus using a chat website

When you use a chat product, the product handles the interface, memory, account controls and many hidden instructions for you.

When you use an API, you control more of the surrounding application logic. You decide when to send requests, what context to include, how to store results and what to do next.

That extra control also creates extra responsibility for security, cost and error handling.

A minimal mental model

Your app → API request → remote service/model → API response → your app

The model may run in a data center far away, but your program can use it as a capability through this interface.

APIs are not automatically free

Most commercial AI APIs charge based on usage. Text models often meter tokens; image, audio and video services may use different units.

Lesson 019 explains how text-model API pricing works, including input tokens, output tokens, cached tokens and why “one request” is not a useful cost unit.

One thing to remember

An API is a defined interface that lets one piece of software request data or capabilities from another system.

Primary sources

Analogies build intuition; use the original sources for formal definitions and technical detail.

  1. OpenAI — API Overview ↗
  2. Google — Gemini API Quickstart ↗
← Previous017How to write AI video prompts: separate subject motion, camera motion, scene and timing
Next →019How does AI API pricing work? Read input, output and cached tokens before estimating cost
COMMUNITY

Comments

Questions, reactions and useful additions are welcome here.

0 / 1200