> SpecStream is the live web data engine for teams and agents. This is the Markdown copy of https://specstream.ai/docs/langchain. Every page, with what SpecStream does and costs: https://specstream.ai/llms.txt

# LangChain

Give a LangChain agent the live web. The `langchain-specstream` package adds four tools and a retriever: the Search API finds pages, the Extract API reads them (web pages, PDF, Word and Excel), and Deep Search returns the finished list. For a list, the agent asks in plain words, like “dental clinics in Lisbon with online booking”, and gets back every matching row, each with its source URL. You set what one list may cost, in code. The model can’t raise it.

## Install

Terminal

```bash
pip install -U langchain-specstream
export SPECSTREAM_API_KEY=ss_live_...
```

Create the key under **Agents & API** in your workspace ([more on keys](https://specstream.ai/docs/account.md#keys)). A free account comes with $10 of credit and needs no card: [sign up](https://specstream.ai/signup). The package works with LangChain 0.3 and 1.x on Python 3.10 or later.

## An agent that finds lists

Python

```python
from langchain.agents import create_agent
from langchain_specstream import specstream_tools

agent = create_agent(
    "anthropic:claude-sonnet-5-5",
    tools=specstream_tools(max_price_usd=5),
)
agent.invoke({"messages": [{"role": "user", "content":
    "Find US startups that raised $5M or more in a Form D filed after October 8, 2026. Which industries lead?"}]})
```

The agent writes the request and picks how many rows. You decide what one list may cost.

| Tool | The model gives | What happens |
| --- | --- | --- |
| `specstream_find_list` | `request`, `max_results` | Reads the request, prices it, starts it only within `max_price_usd`, waits up to seven minutes and returns every row. You pay per row that matches. |
| `specstream_get_list_results` | `list_id` | Every row found so far, for a list that was still running. Free. |

When the price is above your maximum, nothing runs: the tool returns the price, so the agent can ask for fewer rows or tell the user. When a request is too vague to price (“clinics”), it returns how SpecStream read it, so the agent can add the place or the conditions.

Use the classes directly when you want different settings per tool:

Python

```python
from langchain_specstream import (
    SpecStreamWebSearch, SpecStreamExtractPages, SpecStreamFindList, SpecStreamGetListResults,
)

search = SpecStreamWebSearch()      # Search API, $5 per 1,000 searches of up to 10 results
extract = SpecStreamExtractPages()  # Extract API, $0.80 per 1,000 pages
find = SpecStreamFindList(max_price_usd=20, wait_seconds=600)
results = SpecStreamGetListResults()
```

## What comes back

One flat row per match: the list’s own columns, then where the row was read. This is a real row from the request above.

JSON

```json
{
  "list_id": "fnd_gk5y3d0r97bvyz0t08zzh75kr6",
  "position": 26,
  "Organization": "RapidCanvas Inc",
  "Published address": "801 BARTON SPRINGS RD, AUSTIN, TEXAS, 78704",
  "Source industry classification": "Other Technology",
  "Amount sold (USD)": "28999988",
  "Funding filing date": "2026-10-14",
  "source_url": "https://www.sec.gov/Archives/edgar/data/2052031/000205203126000006/primary_doc.xml",
  "checked_at": "2026-10-14T19:56:02.016693Z",
  "list_link": "https://specstream.ai/workspace/collections/fnd_gk5y3d0r97bvyz0t08zzh75kr6"
}
```

Columns follow the request. Ask for breweries with their website and the rows carry the brewery and its website instead. A fact a source doesn’t publish comes back empty, never guessed. The `list_link` opens the same list in your workspace, where you can map it, export it or keep it current.

## Research reports

`SpecStreamResearch` answers a question in plain words with a written report from the live web. Each cited sentence links to a page read in that run, with its read time. Use it when the answer needs many pages read and compared, not a table of rows.

Python

```python
import json
from langchain_specstream import SpecStreamGetResearch, SpecStreamResearch

research = SpecStreamResearch(depth="quick")  # $0.10 a report; "standard" is $0.30, "deep" is $1.00
report = json.loads(research.invoke({"input": "How do the EU and the US regulate stablecoin reserves in 2026?"}))

report["content"]    # the report in Markdown, with [1] markers
report["citations"]  # the page, read time and passage of each cited sentence

tools = [research, SpecStreamGetResearch()]  # for an agent
```

`depth` lives on the tool, in your code, so the model can’t choose a higher price: $0.10 for `quick`, $0.30 for `standard`, $1.00 for `deep`. A report is charged once, when it is delivered. `SpecStreamGetResearch` reads a report that was still running by its `research_id`, free. Needs `langchain-specstream` 0.3.0 or later.

## As a retriever

Python

```python
from langchain_specstream import SpecStreamRetriever

retriever = SpecStreamRetriever(max_price_usd=3, max_results=25)
docs = retriever.invoke("Breweries in Portland, Oregon that host events, with their website")

docs[0].page_content            # "Business location: Occidental Brewing Company\nPublished business website: ..."
docs[0].metadata["source_url"]  # the page that row was read from
```

One document per row, its facts as text and its source in the metadata, so a chain can cite every claim. Above the maximum, the retriever raises `SpecStreamError` and nothing runs.

## Money, plainly

-   `max_price_usd` lives on the tool, in your code. The model never sees it and can’t change it.
-   You pay for rows that match. Candidates SpecStream couldn’t confirm are left out and aren’t billed.
-   A retried step asking for the same list within the hour gets the list it already started, not a second bill.
-   Rates and plans: [pricing](https://specstream.ai/pricing.md). How charges work: [billing](https://specstream.ai/docs/billing.md).

## Every tool over MCP

The package covers finding a list and reading it. For everything else (schedules, exports, sharing, enrichment of your own list), load the whole [MCP server](https://specstream.ai/docs/mcp.md) with `langchain-mcp-adapters`:

Python

```python
import os
from langchain_mcp_adapters.client import MultiServerMCPClient

client = MultiServerMCPClient({
    "specstream": {
        "transport": "streamable_http",
        "url": "https://api.specstream.ai/mcp",
        "headers": {"Authorization": f"Bearer {os.environ['SPECSTREAM_API_KEY']}"},
    }
})
tools = await client.get_tools()
```

Source and issues: [GitHub (opens in a new tab)](https://github.com/specstream/specstream-tools/tree/main/packages/langchain-specstream). Package: [PyPI (opens in a new tab)](https://pypi.org/project/langchain-specstream/).

## SearxSearchWrapper on the Search API

For code that already uses `SearxSearchWrapper` from `langchain-community`: it searches with the Search API once you change `searx_host`, or the `SEARX_HOST` environment variable. Use either value, with [your key](https://specstream.ai/workspace/search?route=searxng&utm_source=langchain&utm_medium=howto) in place of `YOUR_SPECSTREAM_KEY`:

searx\_host, key in the query

```text
https://api.specstream.ai/searxng/search?key=YOUR_SPECSTREAM_KEY
```

searx\_host, key as the password

```text
https://:YOUR_SPECSTREAM_KEY@api.specstream.ai/searxng/search
```

The address then holds your key, so keep it in a secret or an environment setting.

To check it, run one search. It prints a title and a link for each result, and `search.run()` returns the snippets as one string for a chain:

Python

```python
from langchain_community.utilities import SearxSearchWrapper

search = SearxSearchWrapper(searx_host="https://api.specstream.ai/searxng/search?key=YOUR_SPECSTREAM_KEY")

for result in search.results("latest SEC rule on climate disclosure", num_results=3):
    print(result["title"], result["link"])
```

## TavilySearch on the Search API

For code that uses `TavilySearch` from `langchain-tavily`: set `api_base_url` to `https://api.specstream.ai/tavily` and pass [your key](https://specstream.ai/workspace/search?route=tavily&utm_source=langchain&utm_medium=howto) as `tavily_api_key`. The tool returns the results as a dictionary, each with a title, URL, and content:

Python

```python
import os
from langchain_tavily import TavilySearch

search = TavilySearch(
    max_results=5,
    tavily_api_key=os.environ["SPECSTREAM_API_KEY"],
    api_base_url="https://api.specstream.ai/tavily",
)

print(search.invoke({"query": "latest SEC rule on climate disclosure"}))
```

## ExaSearchRetriever on the Search API

For code that uses `ExaSearchRetriever` from `langchain-exa`: set `exa_base_url` to `https://api.specstream.ai/exa` and pass [your key](https://specstream.ai/workspace/search?route=exa&utm_source=langchain&utm_medium=howto) as `exa_api_key`. It returns one document per result:

Python

```python
import os
from langchain_exa import ExaSearchRetriever

retriever = ExaSearchRetriever(
    k=5,
    exa_api_key=os.environ["SPECSTREAM_API_KEY"],
    exa_base_url="https://api.specstream.ai/exa",
)

for doc in retriever.invoke("latest SEC rule on climate disclosure"):
    print(doc.metadata["title"], doc.metadata["url"])
```

## BraveSearchWrapper on the Search API

For code that uses `BraveSearchWrapper` from `langchain-community`: set `base_url` to `https://api.specstream.ai/res/v1/web/search` and pass [your key](https://specstream.ai/workspace/search?route=brave&utm_source=langchain&utm_medium=howto) as `api_key`. Set a `count`: without one, Brave asks for 20 results and each search is priced as a search of 20 results.

Python

```python
import os
from langchain_community.utilities import BraveSearchWrapper

search = BraveSearchWrapper(
    api_key=os.environ["SPECSTREAM_API_KEY"],
    base_url="https://api.specstream.ai/res/v1/web/search",
    search_kwargs={"count": 10},
)

print(search.run("latest SEC rule on climate disclosure"))
```

## BingSearchAPIWrapper on the Search API

For code that uses `BingSearchAPIWrapper` from `langchain-community`: set `bing_search_url` to `https://api.specstream.ai/v7.0/search`, or the `BING_SEARCH_URL` environment variable, and pass [your key](https://specstream.ai/workspace/search?route=bing&utm_source=langchain&utm_medium=howto) as `bing_subscription_key`:

Python

```python
import os
from langchain_community.utilities import BingSearchAPIWrapper

search = BingSearchAPIWrapper(
    bing_subscription_key=os.environ["SPECSTREAM_API_KEY"],
    bing_search_url="https://api.specstream.ai/v7.0/search",
    k=5,
)

for result in search.results("latest SEC rule on climate disclosure", 5):
    print(result["title"], result["link"])
```

Each search is one Search API call. A drop-in call runs the fast search, at $1 per 1,000 searches of up to 10 results. A call that asks for an answer or the tool's thorough mode runs the default search, at $5 per 1,000. It comes out of your balance, with no quote and no approval. [Search API](https://specstream.ai/docs/search-api.md) has the details.

[Get your key](https://specstream.ai/workspace/search?route=searxng&utm_source=langchain&utm_medium=howto) on the Search API screen of your SpecStream workspace. New accounts start with $10 of credit, no card.

The same setting works in other tools too: [Search API by one setting](https://specstream.ai/docs/integrations/drop-in-search.md).
