AI agent definition and how it works

developer2026-11-26

On this page

An AI agent is a program that uses a large language model (LLM) to pursue a goal by choosing actions and checking the results. It runs in a loop: the model reads its instructions and context, calls a tool, reads the output, and picks the next step. The loop stops when the task finishes, the agent reaches a step limit, or the agent asks a person for help.

How an AI agent differs from a chatbot

A chatbot answers a message and stops. An AI agent keeps working after the first answer. It holds a goal, takes actions, and measures progress against that goal.

Three parts make this possible. The model reasons about the next step. Tools act on systems outside the model. Memory stores what happened earlier, either in the context window or in an external store.

A plain chat model has only the reasoning part. It cannot check a price, send an email, or write a file. An agent can do all three when it has the right tools.

The agent loop, step by step

Most agents run the same cycle. The developer writes the cycle in code. The model chooses the actions inside it.

  • The runtime passes a goal and a system prompt that describes the agent's role and rules.
  • The model reads the goal, the tool list, and the results from earlier steps.
  • The model returns either a final answer or a tool call with named arguments.
  • The runtime executes the tool call and appends the output to the context.
  • The loop repeats until the model answers, a step budget runs out, or a guard stops the run.

Each pass consumes tokens. Long loops grow the context window. Agents need limits on steps and on output size.

Tools, APIs, and MCP servers

A tool is a named function with a description and an input schema. The model reads the description and decides when to call the tool. The schema tells the model which fields are required.

Most tools wrap an HTTP API. The tool sends a request, reads the JSON response, and returns a trimmed result. Good tool design keeps responses short. Long dumps waste context and confuse the model.

The Model Context Protocol (MCP) gives agents a standard way to discover and call tools. An MCP server lists its tools. An MCP client, usually the agent host, calls them through a defined message format. One server can expose many tools without custom glue code for each agent.

A gateway sits between agents and many upstream APIs. It handles authentication, routing, and usage limits in one place. The agent connects to one endpoint instead of one integration per provider.

Where agents run in practice

Teams use agents for three common jobs. Coding agents read a repository, edit files, and run tests. Research agents query several sources and summarise what they find. Support agents triage tickets, look up account records, and draft replies for a person to approve.

Each job depends on tools that read and write data. The model supplies judgement about which tool to call next. The tools supply the facts.

What makes an agent reliable

Reliability depends on the tools and limits as much as on the model. A clear goal, narrow tools, and strict output formats prevent most errors.

Agents fail in predictable ways. They call the wrong tool, repeat the same call, or accept a bad result without checking it. They also overspend when nothing caps the number of steps.

  • Set a maximum step count and a budget for tokens and money.
  • Validate tool arguments before the call runs.
  • Return errors as text the model can read, so it can retry or stop.
  • Log each tool call with its inputs and outputs for later review.

Test agents on a fixed set of tasks. Rerun that set after each change to the prompt or the tools.

Agents compared with fixed workflows

A workflow runs the same steps in the same order each time. An agent chooses its steps at run time. Use a workflow when the steps are known in advance. Use an agent when the path depends on what the agent finds.

Many production systems combine both. A fixed pipeline handles the stable parts. A model decides only the uncertain step.

Keep humans in the loop for risky actions

Agents make mistakes. Some actions are irreversible. Require a person to approve payments, deletions, and messages to customers.

Give each agent its own scoped credentials. Grant read access by default. Add write access only for tools the task needs.

Giving an agent API access with MCP tools

To give your agent API access, connect it to an MCP server that wraps the APIs you need. The agent discovers the tools at start and calls them as the task requires.

Start with a small tool set. Add tools only when a task needs them. Each extra tool adds description tokens to every model call.

APIbase is an MCP gateway with a large and growing catalog of tools across many categories. Many providers are reachable through one connection. Per-call prices range from 0 to 29.99 USD. Check the current listing before you plan a build, because the catalog changes often.

Live pricing — developer

Price per call, developer tools Horizontal bar chart of the price per call and the cache-hit price, in US dollars, for 12 developer tools. The same values are in the table below the chart. Price per call Cache-hit price $0.0 $0.0005 $0.001 Usage Time SeriesUsage Time Series $0.0 $0.0 Per-Tool Usage BreakdownPer-Tool Usage Breakdown $0.0 $0.0 Usage SummaryUsage Summary $0.0 $0.0 Discover ToolsDiscover Tools $0.0 $0.0 Batch Tool CallsBatch Tool Calls $0.0 $0.0 Tool Quality MetricsTool Quality Metrics $0.0 $0.0 Tool Quality RankingsTool Quality Rankings $0.0 $0.0 List Programming LanguagesList Programming Languages $0.001 $0.0001 Check CVE ID Reservation Stat…Check CVE ID Reservation Status $0.001 $0.0001 Security Advisories (deps.dev)Security Advisories (deps.dev) $0.001 $0.0001 Dependency Tree (deps.dev)Dependency Tree (deps.dev) $0.001 $0.0001 Package Info (deps.dev)Package Info (deps.dev) $0.001 $0.0001 US dollars per call
Price per call for developer tools, cheapest first.

Data source: live tool catalog snapshot, fetched 2026-11-26.

Chart data as a table
ToolPrice per callCache-hit price
Usage Time Series$0.0$0.0
Per-Tool Usage Breakdown$0.0$0.0
Usage Summary$0.0$0.0
Discover Tools$0.0$0.0
Batch Tool Calls$0.0$0.0
Tool Quality Metrics$0.0$0.0
Tool Quality Rankings$0.0$0.0
List Programming Languages$0.001$0.0001
Check CVE ID Reservation Status$0.001$0.0001
Security Advisories (deps.dev)$0.001$0.0001
Dependency Tree (deps.dev)$0.001$0.0001
Package Info (deps.dev)$0.001$0.0001
ToolProviderPrice/callCache-hit
Usage Time Seriesaccount$0$0
Per-Tool Usage Breakdownaccount$0$0
Usage Summaryaccount$0$0
Discover Toolsapibase$0$0
Batch Tool Callsplatform$0$0
Tool Quality Metricsplatform$0$0
Tool Quality Rankingsplatform$0$0
List Programming Languagesjudge0$0.001$0.0001
Check CVE ID Reservation Statuscve-mitre$0.001$0.0001
Security Advisories (deps.dev)depsdev$0.001$0.0001
Dependency Tree (deps.dev)depsdev$0.001$0.0001
Package Info (deps.dev)depsdev$0.001$0.0001

Connect via MCP

How a tool call worksAn AI agent sends a tool call to the APIbase gateway. The gateway checks payment, calls the provider API, and returns the JSON result to the agent.Your agentAPIbase gatewayProvider API1. tool call2. paid call3. JSON result flows back to the agent
Diagram: the path of one tool call.

Data source: gateway design, no measured values.

$ curl -X POST https://apibase.pro/api/v1/tools/account.timeseries/call \
  -H "Content-Type: application/json" -d '{"params": {}}'

FAQ

What is an AI agent in simple terms?

An AI agent is a program that uses a language model to reach a goal. It chooses actions, calls tools, reads the results, and continues until the task is done or a limit stops it.

Is an AI agent the same as an LLM?

No. The LLM is the reasoning part inside the agent. The agent adds the loop, the tools, and the memory that let the model act on the outside world.

How does an AI agent use tools?

The model reads each tool's description and input schema. It returns a tool call with arguments. The runtime runs the call and sends the output back to the model as new context.

What is the difference between an AI agent and an MCP server?

An MCP server exposes tools in a standard format. The agent is the client that discovers those tools and decides when to call them.

How do I stop an AI agent from running too long?

Set a maximum step count, a token budget, and a spending limit. Add a guard that ends the run when the same tool call repeats.

Is it safe to give an AI agent access to my accounts?

It can be, with limits. Use scoped credentials, grant read access by default, and require human approval for payments, deletions, and outbound messages.

  1. STEP 1/2 Connect your MCP client
  2. STEP 2/2 Browse the full catalog

Written with AI assistance from APIbase's published documentation and public data; checked automatically against them. Corrections: https://apibase.pro/

Published: 2026-11-26Source: live apibase.pro catalog snapshot