langchain-serpex-python
This package contains the LangChain integration with Serpex (Python).
Installation
pip install langchain-serpex-python
What is Serpex?
Serpex is the web search API and extract API for AI agents. Search returns ranked web results (title, URL, snippet), optionally with page content as markdown; Extract turns known URLs into clean markdown. It's built for AI agents, LLM tools and RAG pipelines.
Features
- Web search: ranked results for any query, optionally with page content as markdown
- One search engine: nothing to configure — no engine to pick
- LangChain-native: a drop-in
BaseToolfor 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
# Also fetch page content (markdown) for the top 5 or 10 results
tool = SerpexSearchResults(
api_key="your-serpex-api-key",
include_content=True,
content_results=5,
)
results = tool.invoke("best restaurants")
print(results)
Deprecated parameters
Serpex is one search engine, so there is nothing to select. engine,
category and time_range are deprecated and ignored by the Serpex API; they
are still accepted so existing code keeps working, emit a DeprecationWarning,
and are not sent. They will be removed in 0.3.0.
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)include_content(bool): Also fetch page content (markdown) for the top results (default:False). Best-effort: a page that can't be extracted shows itscontent_errorinstead.content_results(int): How many top results get content,5or10(default:5)timeout(float): Request timeout in seconds (default: 60, or 100 withinclude_content)engine,category,time_range: Deprecated — ignored by the Serpex API and not sent; removed in 0.3.0
Documentation
For more detailed documentation, visit:
Support
For issues and questions:
- GitHub Issues: langchain-serpex issues
- SERPEX Support: support@serpex.dev
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.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 | |
|---|---|---|---|
| langchain_serpex_python-0.2.0.tar.gz | 135.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_serpex_python-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 143.5 kB
Release files / langchain_serpex_python-0.2.0.tar.gz
| Download URL | langchain_serpex_python-0.2.0.tar.gz |
|---|---|
| Size | 135.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4721dfaae383cf6a8ac6d7ffd0bd5458793dd6556cba1ad26aedb97cd3b46da
|
|
BLAKE2b-256 checksum How to use checksums |
4a4dfbf8218c24f315264ad1dc2e188533c85b41db3d19b02e64717b685678f6
|
| 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.2.0-py3-none-any.whl
| Download URL | langchain_serpex_python-0.2.0-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cdfe49663dbc109eb15efbb628d924033dce96498321a3d2a701f8f3841d406f
|
|
BLAKE2b-256 checksum How to use checksums |
2e53cfc8867107880519beba9ee9fb968f01c27411a6e56a51acd477b6f742ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|