AI agents often connect to other apps through a side door built for software, called an API. When an agent books a meeting or checks an order, it may never open the app and click around the way you would. Instead, the software running the agent sends a short, structured request through that door, and the app sends back data, a confirmation or an error.
An API, short for application programming interface, is a defined way for one program to ask another for data or an action; NIST describes it as an access point with a well-defined syntax that gives programs well-defined functionality [1]. In the designs Anthropic and OpenAI document, the language model inside the agent does not make the call itself: the model writes a structured request, the surrounding application sends it to the API, and whatever comes back, data or an error, becomes the model’s next input [2, 3]. That connection decides what an agent can reach, what it is allowed to change and what happens when something fails.
The previous guide, how AI agents use tools, showed how an ability such as “check the calendar” is offered to the model as a tool. Many of those tools are API connections underneath, and this guide opens that box. For the bigger picture, see what an AI agent is.
TL;DR
- An API is a fixed menu for software. A program can ask only for what it offers, in the form it specifies [1, 4].
- The model asks; software calls. The application, not the model, makes the actual API call [2, 3].
- Credentials and scopes set the agent’s reach. Tokens identify the caller and can limit what it may do [5, 6].
- APIs usually beat clicking through screens on speed and security, but reach only what their builders exposed [4].
What Is an API, in Plain Terms?
An API is an agreement about how to ask: a fixed set of things a program may request, each in a defined form [1]. Services can publish that agreement in a standard format such as the OpenAPI Specification, designed so both people and computers can see what a service offers without reading its code [7].
Picture, hypothetically, a service counter with a printed list: “check order status,” “cancel order.” Nothing off the list is available, and each request needs details, such as an order number. An API works the same way.
How Does an AI Agent Use an API?
The model never contacts the API itself. In Anthropic’s documented design, the model emits a structured request, the developer’s code or Anthropic’s servers run the operation, such as an HTTP call, and the result flows back [2]. The model sees only the tool’s description and the result [2]. OpenAI describes the same split: the model requests a function and the application executes it [3].
A hypothetical example: you ask an agent to book a call next Tuesday. The model writes a request to a calendar tool with a date, time and invitee. The application turns that into an API call; the calendar service checks access, creates the event and returns a confirmation, or an error the model can respond to.
The Model Context Protocol (MCP) is one open standard for building these connections; its documentation offers an agent reaching Google Calendar and Notion as an example [8]. How a connection is presented to the model is explained in the guide to agent tools.
The Parts of an API Exchange
The Request
A request names an operation and its inputs. Web APIs inherit a distinction from HTTP, the protocol behind the web: some request types, such as GET, are defined as “safe,” meaning essentially read-only, while others, such as POST and DELETE, ask the server to process new data or remove something [9]. Whether a connection only reads or can also change things is the first question to ask about it.
The Allowed Operations
An API offers only what its builders exposed. Microsoft researchers comparing agent designs note that if a feature is missing from an API, an agent using it cannot invoke that feature directly [4]. They also treat that limit as a safety feature, because the agent stays within a predefined set of operations [4].
The Returned Data
Responses usually arrive as structured data. JSON, a lightweight text format for structured data, is a common choice [10]. In OpenAI’s weather example, the tool returns a temperature and a unit, which the model turns into a sentence [3].
How Does an API Know the Agent Is Allowed In?
Each call carries a credential. The simplest is an API key. Google Cloud notes that a standard key ties a request to a project for billing and quotas but does not identify who is calling, so its access controls cannot check whether the caller is authorized; it calls unrestricted keys insecure [11].
To act on someone’s behalf, many services use OAuth. Instead of sharing your password, you approve limited access and the application receives a token with a specific scope and lifetime [5]. Shared passwords, the standard notes, give overly broad access that cannot be revoked for one application alone [5].
Scopes define reach. As documented in November 2026, Google’s Gmail API has separate scopes to send email, to view messages and settings, and to read, send and permanently delete everything, and Google advises the narrowest one that works [6]. MCP’s security guidance for its 2026-07-28 specification recommends starting with low-risk read access and requesting more only when needed [12]. OWASP adds that actions taken for a user should run with that user’s own access and minimum privileges [13]. How much an agent should hold is covered in what an agent should be allowed to access.
What Happens When an API Call Goes Wrong?
Every web response carries a three-digit status code: the 200s mean success, the 400s a problem with the request and the 500s a server failure [9]. A 401 means valid credentials were missing; a 403 means the server understood but refuses [9]. A 429 means too many requests too quickly, known as rate limiting [14]. As documented in November 2026, GitHub allows 60 requests per hour without authentication and generally 5,000 for authenticated users [15].
The MCP specification separates malformed requests from errors such as a failed API call or an invalid date, and says the latter should go back to the model so it can adjust and retry [16]. Anthropic recommends error messages that name a specific fix rather than an opaque code [17].
Retries carry their own risk: repeating a lookup is harmless, but repeating a payment is not. HTTP calls a request type idempotent when sending it again has the same intended effect as sending it once [9]. Stripe’s API offers idempotency keys so a request can be retried after a connection error without being performed twice [18].
Models can also get the request wrong. A 2023 study of API calls for machine-learning libraries found that models, including GPT-4, struggled to supply accurate inputs and tended to invent wrong API usage; a model trained to consult current documentation made fewer such errors [19]. No comparable independent figures for today’s deployed agents were found for this article.
Why Not Just Have the Agent Click Through the App?
When a stable API exists, it is usually the better connection. The Microsoft researchers argue that an API call can often finish a task in one step, while an agent operating a screen needs a series of clicks and keystrokes [4]. Each API endpoint can also be secured separately with authentication, access controls and rate limits [4].
The trade-offs are reach and visibility. API calls happen behind the scenes, so users typically see the result without knowing which calls were made [4]. Where no usable API exists, as with some legacy systems, operating the interface may be the only option [4]. Their framework is conceptual, not measured. The next guide, how an AI agent can use a computer, explains that screen-based alternative and why it is harder to control.
Where API Connections Add Risk
An API does what it is asked, so a mistaken or over-broad request goes straight through. Anthropic contrasts an ordinary function call, which behaves identically every time, with an agent that might call a tool, answer without it, ask a question or misuse it [17].
OWASP advises enforcing authorization in the systems an agent reaches rather than trusting the model to judge what is allowed [13]. Its API security list from 2023 ranks first the failure to check, on each request for a record by ID, whether the caller may access it, and separately warns about business flows such as ticket buying being abused by automated callers [20]. It was written for automated software generally, which includes agents. The MCP specification says a person should always be able to deny tool calls [16]. Responsibility stays with people: whoever connects an agent to a service, chooses its credentials and approves its scopes answers for what it does with that access. Wider failure patterns are covered in how agents fail when they can act.
Practical Takeaways
- Ask what the agent connects to. API calls happen out of sight, so find out which services it reaches [4].
- Prefer delegated access to a shared password. OAuth-style access can be limited and revoked [5].
- Choose read-only access where it will do [6, 12].
- Ask how retries work for payments and messages [18].
- Favor an API over screen operation when both exist [4].
Sources
- application programming interface (API) — Glossary. NIST Computer Security Resource Center, accessed 2026-11-09.
- How tool use works. Anthropic (Claude Platform Docs), accessed 2026-11-09.
- Function calling. OpenAI (developer documentation), accessed 2026-11-09.
- API Agents vs. GUI Agents: Divergence and Convergence. arXiv, 2025-06-23, accessed 2026-11-09.
- RFC 6749: The OAuth 2.0 Authorization Framework. IETF (RFC Editor), 2012-10, accessed 2026-11-09.
- Choose Gmail API scopes. Google for Developers, 2026-09-10, accessed 2026-11-09.
- OpenAPI Specification v3.2.1. OpenAPI Initiative (Linux Foundation), 2026-09-10, accessed 2026-11-09.
- What is the Model Context Protocol (MCP)?. Model Context Protocol (modelcontextprotocol.io), accessed 2026-11-09.
- RFC 9110: HTTP Semantics. IETF (RFC Editor), 2022-06, accessed 2026-11-09.
- RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format. IETF (RFC Editor), 2017-12, accessed 2026-11-09.
- Manage API keys. Google Cloud documentation, 2026-11-07, accessed 2026-11-09.
- Security Best Practices — Model Context Protocol Specification (version 2026-07-28). Model Context Protocol (modelcontextprotocol.io), 2026-07-28, accessed 2026-11-09.
- LLM06:2025 Excessive Agency. OWASP Gen AI Security Project, 2025, accessed 2026-11-09.
- RFC 6585: Additional HTTP Status Codes. IETF (RFC Editor), 2012-04, accessed 2026-11-09.
- Rate limits for the REST API. GitHub Docs, accessed 2026-11-09.
- Tools — Model Context Protocol Specification (version 2026-07-28). Model Context Protocol (modelcontextprotocol.io), 2026-07-28, accessed 2026-11-09.
- Writing effective tools for agents — with agents. Anthropic (Engineering), 2025-09-11, accessed 2026-11-09.
- Idempotent requests — Stripe API Reference. Stripe, accessed 2026-11-09.
- Gorilla: Large Language Model Connected with Massive APIs. arXiv, 2023-05-24, accessed 2026-11-09.
- OWASP Top 10 API Security Risks – 2023. OWASP API Security Project, 2023, accessed 2026-11-09.
