Skip to main content

langchain-serpex-python

PyPI - Version PyPI - License Twitter

This package contains the LangChain integration with Serpex (Python).

Installation

pip install langchain-serpex-python

What is Serpex?

Serpex is a real-time web search API. It returns structured JSON results (title, URL, snippet) for any query, and offers page content extraction that turns URLs into LLM-ready markdown. It's built for AI agents, LLM tools and RAG pipelines.

Features

  • Real-time web search: current results for any query
  • One search engine: nothing to configure — no engine to pick
  • LangChain-native: a drop-in BaseTool for agents and chains
  • Easy integration: API key via argument or SERPEX_API_KEY

Quick Start

Get Your API Key

Sign up at SERPEX to get your API key.

Basic Usage

from langchain_serpex_python import SerpexSearchResults

# Initialize the tool
tool = SerpexSearchResults(api_key="your-serpex-api-key")

# Perform a search
results = tool.invoke("latest AI developments")
print(results)

With Agents

from langchain_serpex_python import SerpexSearchResults
from langchain_openai import ChatOpenAI
from langchain.agents import initialize_agent, AgentType

# Initialize the search tool
search_tool = SerpexSearchResults(api_key="your-serpex-api-key")

# Initialize the LLM
llm = ChatOpenAI(temperature=0)

# Create an agent with the search tool
agent = initialize_agent(
    tools=[search_tool],
    llm=llm,
    agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
    verbose=True
)

# Run the agent
result = agent.run("What are the latest developments in quantum computing?")
print(result)

Advanced Configuration

from langchain_serpex_python import SerpexSearchResults

# Configure with advanced parameters
tool = SerpexSearchResults(
    api_key="your-serpex-api-key",
    time_range="month"
)

results = tool.invoke("best restaurants")
print(results)

The engine parameter (deprecated)

Serpex is one search engine, so there is nothing to select. engine is deprecated and ignored by the Serpex API since 2026-06; it is still accepted so existing code keeps working.

Configuration

Environment Variables

You can set your SERPEX API key as an environment variable:

export SERPEX_API_KEY="your-serpex-api-key"

Then use the tool without passing the API key:

from langchain_serpex_python import SerpexSearchResults

tool = SerpexSearchResults()  # Will use SERPEX_API_KEY from environment

Parameters

  • api_key (str): Your Serpex API key (required)
  • engine (str): Deprecated — ignored by the Serpex API (default: "auto"); still accepted
  • category (str): Search category - currently only "web" is supported (default: "web")
  • time_range (str): Time filter - "all", "day", "week", "month", "year"

Documentation

For more detailed documentation, visit:

Support

For issues and questions:

License

This package is licensed under the MIT License.

CI / Publishing

A GitHub Actions workflow is provided to publish the package to PyPI when a tag like v* is pushed or when a release is published.

Required repository secret:

  • PYPI_API_TOKEN — a PyPI API token with permission to upload the package. Set this in the repository's Settings → Secrets → Actions.

To publish a new release, create a tag vMAJOR.MINOR.PATCH and push it or create a release in GitHub; the workflow will build sdist and wheel and upload them to PyPI.

Metadata

Release files for langchain-serpex-python 0.1.7

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-serpex-python 0.1.7
File Size Uploaded
langchain_serpex_python-0.1.7.tar.gz 135.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-serpex-python 0.1.7
File Interpreter ABI Platform
langchain_serpex_python-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 142.0 kB

Release files / langchain_serpex_python-0.1.7.tar.gz

Download URL langchain_serpex_python-0.1.7.tar.gz
Size 135.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ff1038854f28aa0f026d80f084abcc1ce4e4fe6390a3efa2336547640181422d
BLAKE2b-256 checksum
How to use checksums
6ea8fcb5098e25babf0fc74dd74da83eeab3e2559399a9379ed36c7f7301d9a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / langchain_serpex_python-0.1.7-py3-none-any.whl

Download URL langchain_serpex_python-0.1.7-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8570c9f20010a4fbb30e9b8697e2c3dad82e3d2b5332ee23a1f4248404a7b744
BLAKE2b-256 checksum
How to use checksums
e2237bafd6e33123a3d28a4b6439d04364c8c993f18db9be15da9d9197345ec7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.0

2 release files

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