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

# Sofya Tools

> Toggle SofyaTools between web search, markdown URL extraction, and cited deep-research report generation.

Demonstrates Sofya tools: web search, URL extraction, and deep research.

```python sofya_tools.py theme={null}
"""
Sofya Tools
=============================

Demonstrates Sofya tools: web search, URL extraction, and deep research.

Set SOFYA_API_KEY in your environment. Get a key at https://sofya.co
"""

from agno.agent import Agent
from agno.tools.sofya import SofyaTools

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

# Example 1: default SofyaTools (web search)
agent = Agent(tools=[SofyaTools()])

# Example 2: enable all Sofya tools (search + extract + research)
agent_all = Agent(tools=[SofyaTools(all=True)])

# Example 3: extraction only, fetch URLs as clean markdown
extract_agent = Agent(
    tools=[
        SofyaTools(
            enable_search=False,
            enable_extract=True,
        )
    ]
)

# Example 4: deep research only, returns a cited report
research_agent = Agent(
    tools=[
        SofyaTools(
            enable_search=False,
            enable_research=True,
        )
    ]
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response(
        "Search for recent developments in the Model Context Protocol",
        markdown=True,
        stream=True,
    )

    extract_agent.print_response(
        "Extract the main content from https://modelcontextprotocol.io/introduction",
        markdown=True,
        stream=True,
    )

    research_agent.print_response(
        "Write a short report on how AI agents use web search tools",
        markdown=True,
        stream=True,
    )
```

## Run the Example

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

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno openai requests
```

**2. Export your API keys**

```bash Mac/Linux theme={null}
export OPENAI_API_KEY="your_openai_api_key_here"
export SOFYA_API_KEY="your_sofya_api_key_here"
```

```bash Windows theme={null}
$Env:OPENAI_API_KEY="your_openai_api_key_here"
$Env:SOFYA_API_KEY="your_sofya_api_key_here"
```

**3. Run the example**

Save the code above as `sofya_tools.py`, then run:

```bash theme={null}
python sofya_tools.py
```

Full source: [cookbook/91\_tools/sofya\_tools.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/91_tools/sofya_tools.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.