# API (Application Programming Interface)

**TL;DR:** A defined contract that lets one system call a specific function on another, with agreed inputs, outputs, and errors.

An API is a contract. It says: send a request shaped like this, to this address, with this authentication, and you'll get back a response shaped like that, or one of these documented errors. Everything else about the system on the other side is deliberately hidden. You don't know what language it's written in or what database it uses, and that opacity is the feature, because it means either side can change internally without breaking the other.

In AI systems, APIs show up in three distinct roles that are worth keeping separate. The model API is how you reach the model itself. The tool API is what an agent calls to do something in the world. And your own API is how you expose your AI product to customers. They share a shape but have different failure modes: model APIs fail with rate limits and latency spikes, tool APIs fail with permissions and stale data, product APIs fail with cost and abuse.

The comparison people ask about is MCP, and the relationship is layering rather than competition. An API is a contract between systems whose developers agreed on it ahead of time, and a human read the docs and wrote the client. MCP is a standard for exposing capabilities to a model that discovers them at runtime, reads their schemas, and decides which to call without anyone having written that specific integration. MCP servers are usually thin wrappers around existing APIs. The API is the plumbing; MCP is a uniform way to hand the plumbing to an agent.

What changes when the caller is a model rather than a program is subtle but consequential. Deterministic clients call the endpoints their developer chose, with parameters their developer validated. A model chooses endpoints itself based on a natural-language description, can call them in unanticipated orders, will occasionally retry something that already succeeded, and will confidently supply a plausible-looking parameter value it inferred rather than one it was given. That means the properties you need from an agent-facing API are different: idempotency, so accidental retries are harmless; strict validation, because inputs are generated rather than checked; narrow scoping, because the caller may misjudge; and error messages written to be readable by a model, since a good error message is the model's only path to self-correction.

Design details that were cosmetic for human developers become functional here. Descriptive operation names outperform clever ones because the model picks tools by reading their descriptions. Small, single-purpose endpoints beat one flexible endpoint with a dozen optional parameters. And response size matters in a way it never did before: every field you return consumes context window and money on every subsequent turn, so an endpoint that returns a 40-field object when the agent needed two of them is a real cost, not a stylistic complaint.

## Why it matters

Every AI system is mostly integration work. The model is a small piece of the architecture; the rest is APIs to data sources, tools, and downstream systems, and the quality of those interfaces sets the ceiling on what an agent can reliably do. Teams that treat agent-facing APIs as ordinary REST endpoints hit the same wall repeatedly: the model calls the wrong thing, retries destructively, or drowns in verbose responses. Designing for a non-deterministic caller is a distinct skill and it's now part of backend work.

## Example

A team exposes their inventory system to an agent. First attempt: one endpoint, GET /inventory, returning every SKU with 40 fields each. The agent burns 30k tokens per call, times out on large catalogs, and often can't find what it needs. Second attempt: three narrow endpoints (search_products_by_name, get_stock_level, check_restock_date), each returning under ten fields, each with a description written for a model to read, each idempotent. Same underlying database, same business logic, and the agent's task success rate roughly doubles while per-call cost drops by an order of magnitude.

## Related terms

- [MCP (Model Context Protocol)](https://www.maximem.ai/glossary/mcp)
- [Tool Use (Function Calling)](https://www.maximem.ai/glossary/tool-use)
- [Integrations](https://www.maximem.ai/glossary/integrations)
- [Structured Output](https://www.maximem.ai/glossary/structured-output)
- [Rate Limiting](https://www.maximem.ai/glossary/rate-limiting)
- [AI Agent](https://www.maximem.ai/glossary/ai-agent)

---

Source: [https://www.maximem.ai/glossary/api](https://www.maximem.ai/glossary/api)
