Search1APIDocs

LangChain

Give LangChain agents live web search, agentic search, news, and page content with the official search1api-langchain toolkit.

search1api-langchain is the official Search1API integration for LangChain. It exposes web search, agentic search, news search, and page crawling through LangChain's standard tool interface, and relies 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 package maintained by Search1API.

Install

pip install search1api-langchain

Create a key in the dashboard, then export it:

export SEARCH1API_API_KEY="your-api-key"

SEARCH1API_KEY is also accepted, so the same environment works for the Search1API CLI.

Use the whole toolkit

Search1APIToolkit returns every tool at once, ready to hand to an 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 toolkit provides search1api_search, search1api_news, search1api_crawl, and search1api_ask. Each tool is also importable on its own when an agent should only receive one capability.

Every tool supports asynchronous invocation:

from search1api_langchain import Search1APISearchTool

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

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

from search1api_langchain import Search1APISearchTool

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

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

search1api_search returns ranked web results for a query.

from search1api_langchain import Search1APISearchTool

search = Search1APISearchTool()

results = search.invoke(
    {
        "query": "latest LangChain agent releases",
        "max_results": 5,
        "time_range": "month",
    }
)

Each result carries title, link, and snippet. Setting crawl_results also fills content with the readable page text, and image queries return an images list. search_service selects the upstream engine when a specific one is required.

See Search for the full request and response contract.

search1api_ask accepts only query (1-500 characters). Search1API chooses the sources, search query, and time range. It costs five credits per request and uses a separate 45-second timeout (Search1APIToolkit(ask_timeout=45)).

from search1api_langchain import Search1APIAskTool

result = Search1APIAskTool().invoke(
    {"query": "What are developers discussing about Bun on GitHub this week?"}
)

The response includes query, intent, results, and optional errors; results keep their source and relevance. See Ask.

News

search1api_news returns recent news articles for a query, with the same result shape as search.

from search1api_langchain import Search1APINewsTool

news = Search1APINewsTool()

articles = news.invoke({"query": "AI regulation", "time_range": "day"})

See News for supported sources and parameters.

Crawl

search1api_crawl reads a known URL and returns clean, readable content. It fetches and extracts page content; it does not drive a browser session.

from search1api_langchain import Search1APICrawlTool

crawl = Search1APICrawlTool()

page = crawl.invoke({"url": "https://example.com/article"})

Pass a URL returned by search when an agent needs the full article rather than a snippet. See Crawl for the full contract.

Credits

Search and news requests cost one credit each. Setting crawl_results asks Search1API to read the top result pages and costs one additional credit for each page crawled successfully, so the tools default it to 0. A crawl request costs one credit. Agentic search costs five credits per request.

New accounts receive 100 credits without a credit card or expiration date. See Credits and limits for current rates.

Search filters and result fields

Version 0.2.0 supports all 19 search engines and all six news sources, including Bing China, Yandex, Grokipedia, and Reuters. time_range supports day, week, month, and year; page supports search pagination. These filters apply to search/news; agentic search accepts only query.

Engine-specific result fields live in optional metadata: GitHub search exposes metadata.kind, metadata.stars, metadata.language, and metadata.num_comments; Hacker News search exposes metadata.story_url, metadata.points, and metadata.num_comments. Optional published_date stays at the result top level. The response-level searchParameters describes the executed request. These paths apply to search/news; trending keeps its separate response shape.

Source

github.com/superagents-lab/search1api-langchain · PyPI

On this page