Search the Web with DuckDuckGo
LlamaIndex tool that lets an agent search DuckDuckGo for instant answers or full results.
Why it matters
Leverage the DuckDuckGo search engine to retrieve instant answers or full search results for your queries. This tool empowers agents to access up-to-date information directly from the web.
Outcomes
What it gets done
Perform instant searches for quick answers.
Conduct comprehensive web searches for detailed information.
Integrate web search capabilities into AI agents.
Retrieve and parse search results for further processing.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/li-tool-tools-duckduckgo | bash Overview
DuckDuckGo Search Tool
The DuckDuckGo Search Tool wires the duckduckgo_search package into a LlamaIndex agent as two callable functions: an instant-answer query and a full search-results query, both with no account or API key required. Use it when an agent needs quick web search results without any account or API key setup. It follows the underlying duckduckgo_search library's behavior rather than a documented API contract.
What it does
The DuckDuckGo Search Tool lets an agent search and retrieve results from the DuckDuckGo search engine. It uses the duckduckgo_search package under the hood, which either fetches instant query answers from DuckDuckGo or runs a full search and parses the results. It exposes two functions: duckduckgo_instant_search (queries the DuckDuckGo API for an instant answer) and duckduckgo_full_search (queries DuckDuckGo for full search results).
When to use - and when NOT to
Use it when an agent needs quick web search results without setting up any account or API key -- for example fielding questions like "What's going on with the superconductor lk-99" or "what are the latest developments in machine learning." It relies on the duckduckgo_search package's own instant-answer and full-search behavior rather than an official, documented DuckDuckGo API, so results follow whatever that library returns rather than a versioned API contract.
Inputs and outputs
Given a text query, duckduckgo_instant_search returns a quick instant answer while duckduckgo_full_search returns full search results. Attach it to an agent via to_tool_list():
from llama_index.tools.duckduckgo import DuckDuckGoSearchToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
tool_spec = DuckDuckGoSearchToolSpec()
agent = FunctionAgent(
tools=DuckDuckGoSearchToolSpec.to_tool_list(),
llm=OpenAI(model="gpt-4.1"),
)
print(await agent.run("What's going on with the superconductor lk-99"))
print(await agent.run("what are the latest developments in machine learning"))
Who it's for
Developers building LlamaIndex agents that need free, no-signup web search results without setting up a paid search API key.
Source README
DuckDuckGo Search Tool
This tool enables agents to search and retrieve results from the DuckDuckGo search engine. It utilizes the duckduckgo_search package, which either fetches instant query answers from DuckDuckGo or conducts a full search and parses the results.
Usage
This tool has a more extensive example usage documented in a Jupyter notebook here
Here's an example usage of the DuckDuckGoSearchToolSpec.
from llama_index.tools.duckduckgo import DuckDuckGoSearchToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
tool_spec = DuckDuckGoSearchToolSpec()
agent = FunctionAgent(
tools=DuckDuckGoSearchToolSpec.to_tool_list(),
llm=OpenAI(model="gpt-4.1"),
)
print(await agent.run("What's going on with the superconductor lk-99"))
print(await agent.run("what are the latest developments in machine learning"))
Available tool functions:
duckduckgo_instant_search: Make a query to DuckDuckGo api to receive an instant answer.duckduckgo_full_search: Make a query to DuckDuckGo search to receive a full search results.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.