Skip to main content

Official Search1API tools for LangChain

Project description

Search1API for LangChain

Official Search1API tools for LangChain agents. The package exposes live web search, news search, and page crawling through LangChain's standard tool interface while relying on the official Search1API Python SDK for authentication, retries, timeouts, and API errors.

The similarly named langchain-search1api package on PyPI is an independent third-party project. search1api-langchain is the official package maintained by Search1API.

Install

pip install search1api-langchain

Set an API key:

export SEARCH1API_API_KEY="your-api-key"

SEARCH1API_KEY is also accepted for compatibility with the Search1API CLI. Create a key in the Search1API dashboard.

Use all tools

from search1api_langchain import Search1APIToolkit

tools = Search1APIToolkit().get_tools()

search = tools[0]
result = search.invoke(
    {
        "query": "latest LangChain agent releases",
        "max_results": 5,
        "time_range": "month",
    }
)
print(result)

The toolkit returns:

  • search1api_search for discovering ranked web sources;
  • search1api_news for recent news articles; and
  • search1api_crawl for reading a known URL as clean content.

Pass the returned list directly to a LangChain agent:

from langchain.agents import create_agent
from search1api_langchain import Search1APIToolkit

agent = create_agent(
    model="openai:gpt-5.4",
    tools=Search1APIToolkit().get_tools(),
)

response = agent.invoke(
    {"messages": [{"role": "user", "content": "What changed in LangChain this month?"}]}
)

The agent example also requires the langchain package and the integration package for the selected model.

Use tools individually

from search1api_langchain import (
    Search1APICrawlTool,
    Search1APINewsTool,
    Search1APISearchTool,
)

search = Search1APISearchTool()
news = Search1APINewsTool()
crawl = Search1APICrawlTool()

search.invoke({"query": "agent observability", "search_service": "google"})
news.invoke({"query": "AI regulation", "time_range": "day"})
crawl.invoke({"url": "https://example.com/article"})

Every tool supports LangChain's asynchronous invocation:

result = await search.ainvoke({"query": "async Python agents"})

An explicit key and client settings can be supplied when environment-based configuration is not appropriate:

tool = Search1APISearchTool(
    api_key="your-api-key",
    timeout=45,
    max_retries=3,
)

API keys use Pydantic's secret type and are excluded from model serialization.

Credits

Plain Search and News requests cost one credit. Setting crawl_results asks Search1API to read the top result pages and costs one additional credit for each successful crawl. The tools therefore default crawl_results to 0.

A Crawl request costs one credit. See Credits and limits for current details.

Development

python -m venv .venv
. .venv/bin/activate
python -m pip install -e ".[dev]"
ruff format --check .
ruff check .
mypy src/search1api_langchain
pytest
python -m build

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

search1api_langchain-0.1.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

search1api_langchain-0.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file search1api_langchain-0.1.0.tar.gz.

File metadata

  • Download URL: search1api_langchain-0.1.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for search1api_langchain-0.1.0.tar.gz
Algorithm Hash digest
SHA256 60ca806affa0ead52541d85a69abf5da38913e233c7002aa87cacdffd7e02b80
MD5 253f8c80ab23178c5361d3ebd0c69cbf
BLAKE2b-256 c845795a6bc194e3b24b9c8fc23d91099a4dcd96ad0db7ae0e079bebf698aa3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for search1api_langchain-0.1.0.tar.gz:

Publisher: publish.yml on superagents-lab/search1api-langchain

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file search1api_langchain-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for search1api_langchain-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4e7b24de73980d43a39a9aba025b96d84aada31fe696d1d56a72b0b95c6a672
MD5 f5c57ddb7b7ad2ee6296947189759c59
BLAKE2b-256 64af3e22c49add712beac3d5aa4de975412529921b8904a7b24992f2d6fc3303

See more details on using hashes here.

Provenance

The following attestation bundles were made for search1api_langchain-0.1.0-py3-none-any.whl:

Publisher: publish.yml on superagents-lab/search1api-langchain

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page