Chapter 14. Using APIs with LangChain
A system is more “agentic” the more an LLM decides how the system can behave.
Harrison Chase, LangChain creator
AI applications use LLMs as a natural language interface with users, and researchers are exploring ways to use the LLMs to perform multistep tasks. This chapter examines two important ways that APIs and LLMs are used together to create AI applications. First, you will look at calling LLMs using APIs, and then you will reverse the roles and call APIs with LLMs. You will use LangChain for both of these tasks.
LangChain and its related project, LangGraph, are open source frameworks for creating agentic applications—applications that use LLMs to control the system behavior. Although many developers build these applications by calling the LLM APIs directly and performing custom coding to interact with them, LangChain and LangGraph standardize many of the tasks required. You can think of them as frameworks that sit on top of the APIs or models.
Here are a few new terms:
- Agent
-
Harrison Chase defines an agent as “a system that uses an LLM to decide the control flow of an application.” Agents are not preprogrammed, like traditional software—they use a model to reason and decide the flow of a conversation. They can execute tool calls that are suggested by function-calling models.
- Function-calling model
-
This is a specialized type of model that considers available functions or tools and suggests when they should be used. Despite the name, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access