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-search1apipackage on PyPI is an independent third-party project.search1api-langchainis 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_searchfor discovering ranked web sources;search1api_newsfor recent news articles;search1api_crawlfor reading a known URL as clean content; andsearch1api_askfor automatic source routing and relevance ranking.
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
Current API capabilities
Search supports bingcn, yandex, and grokipedia; the removed sogou
engine is no longer offered. Search and news support day, week, month,
and year time ranges. Search also accepts page on engines with native
pagination.
Agentic Search (ask) accepts only a natural-language query. The server
chooses the engines and time window and returns query, intent, ranked
results, and errors. Each Ask result includes its source and relevance.
It returns search results, not a generated answer, and costs 5 credits per
call. Use regular search when the engine and keywords are already known.
Search/news engine-specific attributes live inside each result's optional
metadata: GitHub uses kind, stars, language, and num_comments;
Hacker News news results use story_url, points, and num_comments.
published_date remains optional at the result top level. Numeric zero counts
are preserved; unavailable attributes are omitted. When displaying Grokipedia
results, credit them as "Powered by xAI".
from search1api_langchain import Search1APIAskTool
result = Search1APIAskTool().invoke({"query": "recent papers on speculative decoding"})
The toolkit includes search1api_ask by default. ask_timeout defaults to
45 seconds independently of the other tools' timeout. Both synchronous and
asynchronous invocation are supported. Requires search1api>=0.4.
Metadata
Release files for search1api-langchain 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| search1api_langchain-0.2.0.tar.gz | 11.7 kB | With provenance | Details for search1api_langchain-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| search1api_langchain-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for search1api_langchain-0.2.0-py3-none-any.whl |
Total release size: 19.9 kB
Release files / search1api_langchain-0.2.0.tar.gz
| Download URL | search1api_langchain-0.2.0.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
335867f027f81d773a8578a3f1cb81c27898343873dcc07e93228b91d167d3e9
|
|
BLAKE2b-256 checksum How to use checksums |
255f60fc848cc346e232273c33e630f3b339adebeb43b47ce69b72d019a25ff9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 12, 2026.
Transparency logRelease files / search1api_langchain-0.2.0-py3-none-any.whl
| Download URL | search1api_langchain-0.2.0-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
91808a6582996c97257d7f5b91c4a6c88ed11a9d9e5b7edab6dcaa6a8776fa6c
|
|
BLAKE2b-256 checksum How to use checksums |
5964cb560d424a0af6fb394096efd707e876dd2ca18df191c3fe2a56e0264f2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 12, 2026.
Transparency logSecurity for search1api-langchain 0.2.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.
Attestation for search1api_langchain-0.2.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 Oct 12, 2026.
Transparency logA 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.