Agentic Research

API (Application Programming Interface)

Also: API 是什麼 · 接口 · REST API · endpoint · API 端點

A published contract: send a request in the specified shape and get a reply in the specified shape, with no need to know how the other side works internally.

When you will meet it

Almost every step of using AI is an API call: the tool asks a model API for text, the agent asks a search API for results, your script asks a model API for an answer. Knowing the words endpoint, request, response and status code is what turns error output from noise into clues you can actually search for.

An analogy

Like a restaurant menu plus the rules for ordering: you never enter the kitchen, you order by the names on the menu, and dishes come out. How the kitchen reorganises itself is not your concern — but if a name on the menu changes, the way you used to order stops working.

Minimal example

# 需要網路。這兩行都不用登入、不用 key,可以直接跑
curl -s https://api.github.com/zen
# → 一句隨機格言,例如 Favor focus over features.

curl -s https://api.github.com/repos/ollama/ollama | head -6
# → {
#     "id": 658928958,
#     "node_id": "R_kgDOJ0Z1Pg",
#     "name": "ollama",
#     ...
#   一段 JSON

Both lines are API calls: the URL is the endpoint, and curl's request gets a reply with no identity at all. A real AI API works the same way, except that you add an API key and the reply is a large JSON document from which you must pick out the field you want.

What people get wrong

  • Imagining an API as 'a website' or 'a file'. It is a format contract: a URL, a request method, which fields to send, and what comes back. If any one of the four is wrong the call fails, and the error message usually mentions only one of them.
  • Reading 401 or 403 as 'their API is broken'. Both are almost always identity problems: no key, the wrong key, or a key without that permission. Only 5xx status codes mean the fault is on their side.

Related terms

Next