> For the complete documentation index, see [llms.txt](https://docs.talordata.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.talordata.com/serp-api/integration/sdk-integration/how-to-set-up-talordata-with-langchain.md).

# How to Set Up TalorData with LangChain

Integrate TalorData with LangChain to provide LLM-based agents with reliable, anonymous, and scalable web access for executing real-world data tasks, covering 195 countries and regions.

You can use the `langchain-talordata` Python package to implement this integration, which supports the following features:

* TalorSerpTool – TalorData offers a powerful SERP API that allows you to query search engines (Google, Bing, Yandex, DuckDuckGo) using geolocation and advanced customization options—features particularly useful for AI agents requiring real-time web information.

Alternatively, via [TalorData's MCP (Model Context Protocol)](/serp-api/mcp-server/introduction.md)—a local server providing various scraping and automation tools — Although it is not part of the `langchain-talordata` package, it can be manually integrated using LangChain's `Tool` or `RequestsWrapper`.

### How to integrate TalorData with LangChain

{% stepper %}
{% step %}

#### **Get your TalorData API Token**

* Log in to your [TalorData dashboard](https://dashboard.talordata.com/).
* Go to [SERP API > API Token](https://dashboard.talordata.com/scraping/serp-api/api-token). If you haven't generated an API token yet, please generate one.

{% endstep %}

{% step %}

#### **Install the TalorData integration**

Run the following command to install the TalorData integration package for LangChain:

```
pip install langchain-talordata
```

{% endstep %}

{% step %}

#### **Set environment variables**

Set your TalorData API Token as an environment variable:

```
import os
os.environ["TALOR_API_KEY"] = "your-token"
```

{% endstep %}

{% step %}

#### **Using the TaylorData + LangChain integration**

API Reference: [SERP API Documentation](/serp-api/introduction.md)

Basic Usage

```
from langchain_talordata import TalorSerpTool

search_tool = TalorSerpTool.from_env()

result = search_tool.invoke({
    "query": "LangChain tutorial",
    "engine": "google",
    "params": {
        "gl": "us",
        "hl": "en",
        "device": "desktop",
    },
})

print(result)
```

{% endstep %}

{% step %}

#### **Use within an Agent**

```
from langchain_talordata import TalorSerpTool
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)
tool = TalorSerpTool.from_env()

# Tool calling without langchain_classic agents
model_with_tools = llm.bind_tools([tool])
response = model_with_tools.invoke("Search for the latest LangChain news")
print(response)
```

{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.talordata.com/serp-api/integration/sdk-integration/how-to-set-up-talordata-with-langchain.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
