This notebook provides a quick overview for getting started with SERPGoogleScholarTool. For detailed documentation of all SERPGoogleScholarAPITool features and configurations, head to the API reference.

Overview

Integration details

ClassPackagePY supportPackage latest
GoogleScholarTool@langchain/communityNPM - Version

Tool features

  • Retrieve academic publications by topic, author, or query.
  • Fetch metadata such as title, author, and publication year.
  • Advanced search filters, including citation count and journal name.

Setup

The integration lives in the @langchain/community package.
npm install @langchain/community

Credentials

Ensure you have the appropriate API key to access Google Scholar. Set it in your environment variables:
process.env.GOOGLE_SCHOLAR_API_KEY="your-serp-api-key"
It’s also helpful to set up LangSmith for best-in-class observability:
process.env.LANGSMITH_TRACING="true"
process.env.LANGSMITH_API_KEY="your-langchain-api-key"

Instantiation

You can import and instantiate an instance of the SERPGoogleScholarAPITool tool like this:
import { SERPGoogleScholarAPITool } from "@langchain/community/tools/google_scholar";

const tool = new SERPGoogleScholarAPITool({
  apiKey: process.env.SERPAPI_API_KEY,
});

Invocation

Invoke directly with args

You can invoke the tool directly with query arguments:
const results = await tool.invoke({
  query: "neural networks",
  maxResults: 5,
});

console.log(results);

Invoke with ToolCall

We can also invoke the tool with a model-generated ToolCall:
const modelGeneratedToolCall = {
  args: { query: "machine learning" },
  id: "1",
  name: tool.name,
  type: "tool_call",
};
await tool.invoke(modelGeneratedToolCall);

API reference

For detailed documentation of all SERPGoogleScholarAPITool features and configurations, head to the API reference.