> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-codex-docs-audit-20260719-0149.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# DuckDuckGo Tools

> Toggle DuckDuckGo search and news functions, plus WebSearchTools for other backends like Yandex.

```python duckduckgo_tools.py theme={null}
"""
Duckduckgo Tools
=============================

Demonstrates duckduckgo tools.
"""

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.websearch import WebSearchTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------


# Example 1: Enable specific DuckDuckGo functions
agent = Agent(
    model=OpenAIChat(id="gpt-4o"),
    tools=[DuckDuckGoTools(enable_search=True, enable_news=False)],
)

# Example 2: Enable all DuckDuckGo functions (both search and news)
agent_all = Agent(
    model=OpenAIChat(id="gpt-4o"),
    tools=[DuckDuckGoTools(enable_search=True, enable_news=True)],
)

# Example 3: Enable only news search
news_agent = Agent(
    model=OpenAIChat(id="gpt-4o"),
    tools=[DuckDuckGoTools(enable_search=False, enable_news=True)],
)

# Example 4: Use WebSearchTools for other search backends (e.g., yandex)
# Note: DuckDuckGoTools always uses duckduckgo backend.
# For other backends, use WebSearchTools directly.
yandex_agent = Agent(
    model=OpenAIChat(id="gpt-4o"),
    tools=[WebSearchTools(enable_search=True, enable_news=False, backend="yandex")],
    add_datetime_to_context=True,
)

# Test the agents

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response("What's the latest about GPT-5?", markdown=True)
    # news_agent.print_response(
    #     "Find recent news about artificial intelligence", markdown=True
    # )
    # yandex_agent.print_response("What's happening in AI?", markdown=True)
```

## Run the Example

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno ddgs openai
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `duckduckgo_tools.py`, then run:

    ```bash theme={null}
    python duckduckgo_tools.py
    ```
  </Step>
</Steps>

Full source: [cookbook/91\_tools/duckduckgo\_tools.py](https://github.com/agno-agi/agno/blob/v2.7.4/cookbook/91_tools/duckduckgo_tools.py)
