Skip to main content

langchain-sofya

LangChain tools for Sofya: live web search, any page or document as clean markdown, AI extraction from a page, and multi-source research with citations. One API key for all four.

Install

pip install -U langchain-sofya

Get an API key at sofya.co/dashboard and set it:

export SOFYA_API_KEY="sofya_live_..."

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

Tools

Tool Name the model sees What it does Credits
SofyaSearch sofya_search Web search. Results with the text of each page, or snippets only, plus an optional short AI answer. Filter by domain, topic (general or news) and freshness. 2 (basic), 1 (snippets), +2 for the answer
SofyaFetch sofya_fetch Up to 10 URLs as clean markdown. Web pages plus PDF, Word, Excel, PowerPoint, OpenDocument, EPUB and more. 1 per URL, failed URLs free
SofyaExtract sofya_extract Reads one page and answers a prompt about it. 10
SofyaResearch sofya_research Splits a question into several searches, reads the sources and writes a report with citations. 50

A credit is $0.0025. Pricing: sofya.co/pricing.

Use

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 per call (for example max_results, include_domains or freshness).

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?"})

Every tool also has an async version through ainvoke.

With an agent

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?"}]})

Errors (invalid key, out of credits, rate limits) come back to the model as a tool message instead of raising, so an agent can tell the user what happened.

Settings

Argument Env var Default
api_key SOFYA_API_KEY required
base_url SOFYA_BASE_URL https://sofya.co
timeout - 120 seconds (research can take up to a minute)

License

MIT

Metadata

Release files for langchain-sofya 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-sofya 0.1.0
File Size Uploaded Provenance Actions
langchain_sofya-0.1.0.tar.gz 9.5 kB With provenance Details for langchain_sofya-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-sofya 0.1.0
File Interpreter ABI Platform Actions
langchain_sofya-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_sofya-0.1.0-py3-none-any.whl

Total release size: 18.4 kB

Release files / langchain_sofya-0.1.0.tar.gz

Download URL langchain_sofya-0.1.0.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0d4c81ec7e0ed099160e536995db252d5e379239468c26ba48779a978cd82d20
BLAKE2b-256 checksum
How to use checksums
df00e22b4e8d2df824e683e841a08bf4590bb2c72803f5eb4ab48f64d4f9f69c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / langchain_sofya-0.1.0-py3-none-any.whl

Download URL langchain_sofya-0.1.0-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87a0633185e81a220023c9d046789d255c4ffeeb6e3c3974db4097ca621afbf5
BLAKE2b-256 checksum
How to use checksums
76bd73aa8975235fbed687be3e8dff7ccc01581e3d2b0c579e2b5173b2f5ab33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for langchain-sofya 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_sofya-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page