SerpAPI
features and configurations head to the API reference.
Overview
Integration details
Class | Package | PY support | Version |
---|---|---|---|
SerpAPI | @langchain/community | ✅ |
Setup
The integration lives in the@langchain/community
package, which you can install as shown below:
Credentials
Set up an API key here and set it as an environment variable namedSERPAPI_API_KEY
.
Instantiation
You can import and instantiate an instance of theSerpAPI
tool like this:
Invocation
Invoke directly with args
You can invoke the tool directly like this:Invoke with ToolCall
We can also invoke the tool with a model-generatedToolCall
, in which case a ToolMessage
will be returned:
Chaining
We can use our tool in a chain by first binding it to a tool-calling model and then calling it:Agents
For guides on how to use LangChain tools in agents, see the LangGraph.js docs.API reference
For detailed documentation of allSerpAPI
features and configurations head to the API reference.