Skip to main content
Technical Enough

APIs, how systems talk to each other

Chapter 3 of 7 in The Technology Stack · 18 min

Twenty minutes into the scoping review for your support-ticket summary feature, the engineering lead is reading the integration plan your AI coding tool drafted, which you forwarded with a recommendation to build. The plan's key sentence says the feature is one POST to the provider's text-generation endpoint and the cost per request is negligible. She asks two questions before she assigns engineers to it: what exactly does each request carry, and how much does "negligible" add up to at two thousand tickets a day? The plan does not answer, and neither can you. The number you need before you approve the build is one request's price multiplied by every ticket, and to work it out you need to know what goes into one request, which you have never seen.

That request is an API call. In this chapter you read one in full, line by line, so the next time a plan like this reaches you, you can judge it and explain your decision.

What an API is

You arrive at a hotel front desk at midnight and your reservation is missing. You do not walk around the counter and fix the booking system yourself; you state your case in the form the desk expects, a name, a confirmation number, a card, and you get back a room key or a polite no with a reason. Connected software works the same way: no system reaches into another's code or database; it hands a front desk a request in an agreed form and takes what comes back. In software, that desk is an API, the way a company lets programs send it requests, and every AI feature you will ever scope depends on at least one.

An API call is one round trip of the kind you traced in the journey of a request: a request to an API and the response that comes back. Your backend usually makes the call, because the backend runs on the server that holds the API key.

An API as the front desk of a serviceA client on the left sends a request to a front desk and receives a response back. The desk is a row of doors called endpoints, each carrying a verb and an address, one door per job: a lookup, a charge, a refund. Behind the desk sits the service, the work you never see.CLIENTyour apprequestresponseFRONT DESKGET/charges/:ida lookupPOST/chargesa chargePOST/refundsa refundeach door is an endpoint: one door, one jobTHESERVICEthe workThe desk is the API. The office behind it is the service.

In the drawing, the caller, labeled CLIENT (your app; in real software this is usually your backend), hands a request to the front desk and gets a response back. Each door on the desk is an endpoint, one address for one job, written as a verb and an address: GET asks for a lookup, and POST asks for new work. GET /charges/:id looks up a charge (:id stands for the charge's ID), POST /charges makes a charge, and POST /refunds makes a refund. Behind the desk sits the service, the code, data, and machines you never enter.

The call from the plan, printed in full

Here is the request behind the plan's key sentence, sent when a support agent opens a ticket. It is written in JSON, a plain-text format of labeled fields, where each field is a name in quotes followed by its value. Nearly every API uses JSON for both requests and responses, because people and code can both read it.

POST https://api.provider.example/v1/generate
Authorization: Bearer (your API key, attached on your server)

{
  "model": "(the model you chose)",
  "instructions": "Summarize this ticket in one sentence
    for the agent picking it up.",
  "input": "Checkout fails at the payment step, two cards
    tried, order 58214 still stuck as pending.",
  "max_output_tokens": 60
}

Compare it with the hotel desk. The first line states your case: POST is the verb, the word that says what kind of request this is, and here it asks for new work, where GET would ask for a lookup. The address beside it is the endpoint, one door for one job, and this one produces text. The Authorization line is like the card you hand the desk: it carries the API key from Backend, where the real work happens, attached on your server and never in the browser.

The body, the part below those first lines, lists the job's details: model picks which of the provider's models does the work, instructions states the job in your own words, input holds the text the model works on, and max_output_tokens sets the longest reply the model may return, which also limits what the reply costs. A token is a chunk of text the provider counts and charges for, a short word or a piece of a longer one; a page of English is a few hundred tokens.

Here is what the desk hands back, also JSON:

{
  "output_text": "Checkout is failing at the payment step
    for order 58214 after two cards were tried.",
  "stop_reason": "complete",
  "usage": { "input_tokens": 61, "output_tokens": 19 }
}

output_text is the room key from the hotel desk, the result you came for: that sentence is what the support agent reads. stop_reason says why the reply ended; a reply cut short by the sixty-token cap would say so here. usage works like a meter: 61 tokens went in and 19 came out, and those two counts are all you are billed for on this call. If the request is built wrong (malformed), for example a required field is missing or the key does not belong to any account, the reply is an error status code and a reason instead: the desk's polite no, in writing.

An API is the front desk of a service: you hand in a request in the form it asks for and get back the result the service is built to return, or a refusal with a reason.

Model APIs meter the work in tokens

The usage block is the part model APIs add. Every token you send is counted as input, instructions and input text alike, and every token the model produces is counted as output. The provider prices the two directions separately, per million tokens, and output costs more. The rates change too often to print here; the provider's pricing page has the current numbers.

At this size the cost is tiny: 61 tokens in and 19 out cost a small fraction of a cent, and even a full ticket thread with instructions is only about a thousand tokens in. The bill your finance team sees is the cost of one call multiplied by every ticket, every day, for a month, which is the multiplication the engineering lead asked for.

ONE REQUESTwhat you send (ticket + instructions)~1,000 tokenswhat comes back (the summary)~50 tokenscostabout half a cent× 2,000 tickets a day× 30 daysa few hundred dollars a monthIllustrative example. Check current pricing before you ship.

The drawing shows one full ticket as a receipt: about a thousand tokens sent (the ticket and the instructions), about fifty tokens back (the summary), and then the cost of that one request multiplied by two thousand tickets a day and by thirty days. Its cost figures are an illustrative example, so check current pricing before you ship.

A model API charges for the work in tokens, counted in both directions, and the monthly bill is the cost of one call, often a fraction of a cent, multiplied by every user, every day.

The desk has one more line of small print: rate limits, caps on how much one account can send in a given time, usually counted as requests per minute and tokens per minute. If you go past a limit, the reply is a refusal that means slow down and retry. Setting a spending alert, so a runaway bill does not go unnoticed, is a pre-flight step in The pre-flight check: secrets, money, data, and the law, and you will see these token counts on a live call in Make your first model call.

The obvious objection: your tools write these calls for you

The obvious objection is that you will never type that request by hand, because Claude Code or a tool like it writes the integration (the code that connects your app to the provider's API), so reading one can feel like studying plumbing you will never touch. But the plan in your scoping review came from such a tool, and in our own builds these drafts go wrong in ways that only someone who reads them catches.

  • An endpoint that does not exist as written. The draft calls an endpoint that looks plausible, but the provider renamed it or never had it, so the first real call fails with an obvious error.
  • An expensive default. The draft picks the provider's most capable model when a mid-tier one would do, and you see no problem until the invoice arrives.
  • Missing small print. The draft sets no reply cap and does not handle the slow-down refusal, so the feature works in a demo and breaks under real traffic.

The tool writes the draft and you approve it. If you approve a call you do not understand, you repeat the mistake from the scoping review, and this time it affects every request your app sends.

Check the call against the docs page

You can check the plan by reading it against the provider's documentation; it takes no engineering. Every endpoint has a documentation page, like the sign posted at a desk, and you only need three things from it.

  • The form. The verb and address at the top, then the table of fields, with the required ones marked. Here you can spot a renamed endpoint or a missing required field.
  • The worked example. Nearly every docs page shows one complete request and response, like the pair in this chapter. Read it first: in a few seconds it shows you what the field tables take paragraphs to explain.
  • The limits. Rate limits, maximum sizes, and the link to pricing. Here you find the real numbers for the reply cap and for the cost math at your volume.

None of this was invented for AI: payment and email services publish the same kind of docs page, so the skill works for every integration your app needs.

Try it now

This drill takes about fifteen minutes, and you spend nothing on either path.

No setup: For each line of the printed request and response, write one sentence on what the feature loses if that line disappears: the address, the key, then model, instructions, input, and max_output_tokens, then output_text, stop_reason, and usage in the reply. Every answer is in this chapter. If you cannot say what the feature loses without a line, reread that part. You can use the same reading on any call your tools propose.

With your tools: Open a real provider quickstart, a provider's getting-started page, in your browser; searching "Anthropic API quickstart" or "OpenAI API quickstart" finds one. Expect a wall of code, install commands, tabs for different programming languages, and options this chapter never covered; ignore everything except two blocks: the request carrying a model name, instructions, and input, and the block showing what comes back. Ask Claude Code to match that request to the call printed in this chapter, field by field, then check its matching against your own reading. Each provider labels the fields differently, but the parts are the same. Same move in Codex or Cursor: paste the quickstart's request into the chat and ask for the field-by-field match. If nothing is installed yet, the Setup Clinic gets you running.

Chapter Summary

  • An API is the front desk of a service: you hand in a request in the form it asks for, and you get back the work or a refusal with a reason.
  • One system never reaches into another's code or database; everything arrives as a request at the desk and comes back as a reply.
  • JSON is the plain-text format of labeled fields that nearly every API uses in both directions.
  • A model call carries a verb and an address (the endpoint, one door for one job), an API key saying whose account pays, and a body with the model, your instructions, the input, and a reply cap.
  • The reply carries the result in output_text, the reason the reply ended in stop_reason, and the input and output token counts in usage.
  • A token is a chunk of text the provider counts, priced per million in both directions with output above input, and one request costs a fraction of a cent.
  • The real bill is the cost of one request multiplied by every user, every day, for a month, so run the multiplication before the build starts.
  • Rate limits cap how much one account can send in a given time; past the cap, the reply is a refusal that means slow down and retry.
  • AI tools draft these calls and you approve them, so check the provider's docs page for the form, the worked example, and the limits before saying yes.
  • Everything an API sends back has to be stored somewhere, and data, where information lives covers where.

Sources

  • Anthropic Messages API documentation and quickstart (last verified July 2026).
  • OpenAI API reference and quickstart (last verified July 2026).
  • OpenAI, Anthropic, and Google pricing pages for per-token rates (last verified July 2026).