sofya
Integration guide

Sofya with LangChain

The langchain-sofya package gives LangChain agents four Sofya tools: web search, page and document fetch, extraction and cited research. One API key for all four.

SofyaSearch1 to 2 credits, +2 with an answer
sofya_search

Search the web and get page content, not just snippets. Optional short AI answer with include_answer.

SofyaFetch1 credit per URL
sofya_fetch

Read up to 10 URLs as clean Markdown, including PDF, Word, Excel and PowerPoint files.

SofyaExtract10 credits
sofya_extract

Read a page and return the information you ask for.

SofyaResearch50 credits
sofya_research

Run several searches, read the sources and return a report with citations.

1. Install

Terminal
pip install -U langchain-sofya

It works with langchain-core 0.3 and 1.x on Python 3.10 or newer.

2. Get an API key

Sign in at sofya.co and create a key on the dashboard. Keys look like sofya_live_.... Pay as you go from $10; GitHub accounts a year or older get free monthly credits.

Terminal
export SOFYA_API_KEY=sofya_live_...

Or pass api_key="sofya_live_..." to any tool.

3. Call a tool

Python
from langchain_sofya import SofyaSearch

search = SofyaSearch(max_results=5, include_answer=True)
result = search.invoke({"query": "latest stable Python release"})

print(result["answer"])
for r in result["results"]:
    print(r["title"], r["url"])

Arguments set on the tool are defaults. The model can override them on each call, for example max_results, include_domains, topic or freshness.

Python
from langchain_sofya import SofyaExtract, SofyaFetch, SofyaResearch

SofyaFetch().invoke({"urls": ["https://example.com/report.pdf"]})

SofyaExtract().invoke({
    "url": "https://en.wikipedia.org/wiki/Eiffel_Tower",
    "prompt": "How tall is it and when did it open?",
})

SofyaResearch(max_sources=15).invoke({"query": "How do heat pumps perform in cold climates?"})

Each tool also runs async through ainvoke.

4. Give them to an agent

Python
from langchain.agents import create_agent
from langchain_sofya import SofyaExtract, SofyaFetch, SofyaSearch

agent = create_agent(
    "anthropic:claude-sonnet-5-5",
    tools=[SofyaSearch(), SofyaFetch(), SofyaExtract()],
)
agent.invoke({"messages": [{"role": "user", "content": "What changed in the latest Node.js LTS?"}]})

Any chat model with tool calling works. The tools also plug into LangGraph's ToolNode like any other LangChain tool.

Settings

ArgumentEnvironment variableDefault
api_keySOFYA_API_KEYrequired
base_urlSOFYA_BASE_URLhttps://sofya.co
timeout-120 seconds

Notes