Sofya

Search the web for full page content, fetch pages and documents as clean markdown, and run cited multi-source research with SofyaTools.

SofyaTools enable an Agent to search the web, extract page content, and run deep research using the Sofya API. Search returns extracted page content instead of snippets, extract fetches URLs as clean markdown (including PDF and DOCX), and research returns a cited multi-source report.

Prerequisites

The example requires Agno, the openai and requests packages, an OpenAI API key, and an API key from Sofya.

uv pip install -U agno openai requests
export OPENAI_API_KEY=***
export SOFYA_API_KEY=***

Example

The following agent will search the web with Sofya and print the response.

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

agent = Agent(tools=[SofyaTools()])
agent.print_response("Search for recent developments in the Model Context Protocol", markdown=True)

Search is enabled by default. To also enable extraction and research, pass all=True, or turn on the individual tools with enable_extract and enable_research.

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

agent = Agent(tools=[SofyaTools(all=True)])
agent.print_response("Write a short report on how AI agents use web search tools", markdown=True)

Toolkit Params

ParameterTypeDefaultDescription
api_keyOptional[str]NoneSofya API key. If not provided, uses the SOFYA_API_KEY environment variable.
base_urlOptional[str]NoneSofya API base URL. If not provided, uses SOFYA_BASE_URL when set, otherwise https://sofya.co.
enable_searchboolTrueEnable the search_web tool.
enable_extractboolFalseEnable the extract_url_content tool.
enable_researchboolFalseEnable the research tool.
allboolFalseEnable all available tools in the toolkit.
max_resultsint5Maximum number of search results to return. Clamped to the API range of 1-20.
search_depthLiteral['snippets', 'basic']'basic'Search depth. snippets returns result snippets, basic returns full page content.
include_answerboolTrueInclude an AI-generated answer summary in search results.
formatLiteral['json', 'markdown']'markdown'Output format for search and research results. json returns raw data, markdown returns formatted text.
timeoutint180Request timeout in seconds.

Toolkit Functions

FunctionDescription
search_webSearch the web for a query and return extracted page content. Takes an optional max_results that overrides the toolkit default for a single call.
extract_url_contentFetch urls as clean markdown regardless of format, one section per URL. Accepts a single URL or a comma-separated list and keeps the first 10. Handles web pages, PDF, and DOCX. Calls Sofya's fetch endpoint.
researchDecompose a query into sub-queries, read up to 20 sources, and return a report with citations.

Developer Resources