<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Thordata</title>
    <description>The latest articles on DEV Community by Thordata (@thordara).</description>
    <link>https://dev.to/thordara</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4273686%2F65a877b1-a5c3-46cd-8b28-3187254eccc0.jpg</url>
      <title>DEV Community: Thordata</title>
      <link>https://dev.to/thordara</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thordara"/>
    <language>en</language>
    <item>
      <title>Build a Live-Web Research Agent with LangChain, Thordata SERP and GPT</title>
      <dc:creator>Thordata</dc:creator>
      <pubDate>Sat, 05 Dec 2026 06:43:49 +0000</pubDate>
      <link>https://dev.to/thordata-dev/build-a-live-web-research-agent-with-langchain-thordata-serp-and-gpt-3hp1</link>
      <guid>https://dev.to/thordata-dev/build-a-live-web-research-agent-with-langchain-thordata-serp-and-gpt-3hp1</guid>
      <description>&lt;p&gt;Models don't know what happened this week. They know a lot, and then they hit a cutoff date, and everything after that is guesswork. If you are building anything research-shaped — monitoring, digests, answering questions about things that happened recently — the model is the easy part. Getting live search results into it, in a shape it can actually use, is the real work.&lt;/p&gt;

&lt;p&gt;This post builds a small agent that does exactly that. It searches Google in real time through the &lt;a href="https://www.thordata.com/zh/products/serp-api/langchain-integration?op=cianna&amp;amp;from=dev" rel="noopener noreferrer"&gt;Thordata SERP API&lt;/a&gt;, reads structured results, and answers with the sources it used. The Python side is about twenty lines, and the model behind it is swappable — the same code runs on OpenAI, DeepSeek or a local model.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you need
&lt;/h2&gt;

&lt;p&gt;An API key and two packages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install langchain langchain-thordata
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;THORDATA_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"your-api-key"&lt;/span&gt;        &lt;span class="c"&gt;# Windows: set THORDATA_API_KEY=...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;langchain&lt;/code&gt; package provides the agent loop. &lt;code&gt;langchain-thordata&lt;/code&gt; provides the search tool and talks to the SERP API for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  The whole agent
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;agents&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;create_agent&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat_models&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;init_chat_model&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_thordata&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;ThorDataSearchTool&lt;/span&gt;

&lt;span class="c1"&gt;# Any chat model works here. init_chat_model supports many providers,&lt;/span&gt;
&lt;span class="c1"&gt;# so swapping to DeepSeek or a local model is a one-line change.&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;init_chat_model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"gpt-6.1-sol"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;model_provider&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"openai"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;agent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;create_agent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;ThorDataSearchTool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"messages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Find out what changed in Google's Search documentation this week. Search first, then summarize with links."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"messages"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Under the hood: the model decides it needs fresh information, calls the search tool, gets back structured organic results — title, link and snippet per row — reads them, and writes the answer. The reasoning trace comes back in the result object, so when an answer is wrong you can see exactly which search produced it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Calling the tool directly
&lt;/h2&gt;

&lt;p&gt;Sometimes you don't want an agent. Same package, no loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_thordata&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;ThorDataSearchTool&lt;/span&gt;

&lt;span class="n"&gt;tool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ThorDataSearchTool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"query"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"latest AI agent research"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"engine"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"google_news"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"country"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"us"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"language"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"en"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"num"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the version to reach for in a pipeline step: fixed query, fixed engine, no decisions left to the model.&lt;/p&gt;

&lt;h2&gt;
  
  
  One API, a family of engines
&lt;/h2&gt;

&lt;p&gt;Google is the default, and the tool accepts the rest of the engine family the API exposes: &lt;code&gt;google_news&lt;/code&gt; for monitoring, &lt;code&gt;google_shopping&lt;/code&gt; for price checks, plus &lt;code&gt;google_local&lt;/code&gt;, &lt;code&gt;google_images&lt;/code&gt;, &lt;code&gt;google_videos&lt;/code&gt;, &lt;code&gt;google_scholar&lt;/code&gt; and more. Same result shape, different slice of the results page — which is what lets one tool cover most research-shaped tasks. The full list is in the &lt;a href="https://doc.thordata.com/doc" rel="noopener noreferrer"&gt;API reference&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The honest part: limits and batches
&lt;/h2&gt;

&lt;p&gt;Whatever search provider you use, an agent that decides to search ten times in one task will find your quota faster than you expect. Three habits keep it boring:&lt;/p&gt;

&lt;p&gt;Cap the number of searches per task in the prompt itself, so the model knows the budget. Retry with backoff on 429s instead of failing the whole run. And log every query the agent actually made — when an answer is wrong, the transcript of searches is the first thing you will want to read.&lt;/p&gt;

&lt;p&gt;One more thing people hit late: batch size. A batch of five hundred short strings and a batch of twenty long paragraphs are not the same cost, and most per-request limiters cannot tell the difference. If you embed or scrape in batches, size them deliberately.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>tutorial</category>
      <category>python</category>
    </item>
  </channel>
</rss>
