Quercle web search and URL fetch tools for Pydantic AI agents
Project description
quercle-pydantic-ai
Quercle web search and fetch tools for Pydantic AI.
Installation
uv add quercle-pydantic-ai
# or
pip install quercle-pydantic-ai
Setup
Set your API key as an environment variable:
export QUERCLE_API_KEY=qk_...
Get your API key at quercle.dev.
Quick Start
from pydantic_ai import Agent
from quercle_pydantic_ai import quercle_tools
agent = Agent(
"openai:gpt-4o",
tools=quercle_tools(),
system_prompt="You are a helpful research assistant.",
)
result = agent.run_sync("Search for the latest news about AI agents")
print(result.output)
quercle_tools() returns all 5 tools: search, fetch, raw search, raw fetch, and extract.
Direct Tool Usage
The tools are async (Pydantic AI tools are async by design). For direct usage, use the underlying SDK client:
import asyncio
from quercle import AsyncQuercleClient
async def main():
client = AsyncQuercleClient()
# Search
result = await client.search("best practices for building AI agents")
print(result.result)
# Search with domain filtering
result = await client.search(
"Python documentation",
allowed_domains=["docs.python.org"],
)
print(result.result)
# Fetch and analyze a page
result = await client.fetch(
"https://en.wikipedia.org/wiki/TypeScript",
"Summarize the key features of TypeScript",
)
print(result.result)
asyncio.run(main())
Custom API Key
tools = quercle_tools(api_key="qk_...")
Agentic Usage
Research Agent
from pydantic_ai import Agent
from quercle_pydantic_ai import quercle_tools
agent = Agent(
"anthropic:claude-sonnet-4-20250514",
tools=quercle_tools(),
system_prompt="You are a research assistant. Search the web to find "
"accurate, up-to-date information. Always cite your sources.",
)
result = agent.run_sync("What are the latest developments in WebAssembly?")
print(result.output)
Async Agent
import asyncio
from pydantic_ai import Agent
from quercle_pydantic_ai import quercle_tools
agent = Agent("openai:gpt-4o", tools=quercle_tools())
async def main():
result = await agent.run("Search for trending AI papers this week")
print(result.output)
asyncio.run(main())
Streaming
import asyncio
from pydantic_ai import Agent
from quercle_pydantic_ai import quercle_tools
agent = Agent("openai:gpt-4o", tools=quercle_tools())
async def main():
async with agent.run_stream("Summarize the latest AI news") as response:
async for text in response.stream_text():
print(text, end="", flush=True)
asyncio.run(main())
Individual Tools
from quercle_pydantic_ai import (
quercle_search_tool,
quercle_fetch_tool,
quercle_raw_search_tool,
quercle_raw_fetch_tool,
quercle_extract_tool,
)
# Use only search
agent = Agent("openai:gpt-4o", tools=[quercle_search_tool()])
# Use only fetch
agent = Agent("openai:gpt-4o", tools=[quercle_fetch_tool()])
# Combine specific tools
agent = Agent("openai:gpt-4o", tools=[
quercle_search_tool(),
quercle_raw_fetch_tool(),
quercle_extract_tool(),
])
With QuercleToolset
from pydantic_ai import Agent
from quercle_pydantic_ai import QuercleToolset
# All 5 tools with domain filtering
toolset = QuercleToolset(
search_allowed_domains=["docs.python.org", "realpython.com"],
)
# Selectively include tools
toolset = QuercleToolset(
include_raw_fetch=False,
include_raw_search=False,
include_extract=False,
)
agent = Agent("openai:gpt-4o", toolsets=[toolset])
Configuration
| Parameter | Default | Description |
|---|---|---|
api_key |
QUERCLE_API_KEY env var |
Your Quercle API key |
timeout |
None |
Request timeout in seconds |
allowed_domains |
None |
Restrict search to these domains |
blocked_domains |
None |
Exclude these domains from search |
API Reference
| Export | Description |
|---|---|
quercle_search_tool(...) |
AI-synthesized web search with citations |
quercle_fetch_tool(...) |
Fetch a URL and analyze its content with AI |
quercle_raw_search_tool(...) |
Raw web search results (markdown or JSON) |
quercle_raw_fetch_tool(...) |
Raw URL content (markdown or HTML) |
quercle_extract_tool(...) |
Extract content chunks relevant to a query from a URL |
quercle_tools(...) |
Returns all 5 tools as a list |
QuercleToolset(...) |
Composable FunctionToolset for use with toolsets= |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quercle_pydantic_ai-1.0.1.tar.gz.
File metadata
- Download URL: quercle_pydantic_ai-1.0.1.tar.gz
- Upload date:
- Size: 214.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6bc6675d5c86cbe0ab57581158ec04c05edc9831e301f90bf690714ed96a73a
|
|
| MD5 |
136eea43bf58eb4189dca643e8cfa4ba
|
|
| BLAKE2b-256 |
ed4ca16ec5839c100a359e22c5b33773fad52ebd7ff97c884678a5a571b0d3d2
|
Provenance
The following attestation bundles were made for quercle_pydantic_ai-1.0.1.tar.gz:
Publisher:
publish.yml on quercledev/quercle-pydantic-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quercle_pydantic_ai-1.0.1.tar.gz -
Subject digest:
d6bc6675d5c86cbe0ab57581158ec04c05edc9831e301f90bf690714ed96a73a - Sigstore transparency entry: 992420185
- Sigstore integration time:
-
Permalink:
quercledev/quercle-pydantic-ai@57e16f669746399b9360b3e4b75d8191f4b7c8a4 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/quercledev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@57e16f669746399b9360b3e4b75d8191f4b7c8a4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quercle_pydantic_ai-1.0.1-py3-none-any.whl.
File metadata
- Download URL: quercle_pydantic_ai-1.0.1-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb47dca34e845d7570c88f3da8049a5abc5feaede27a72594c0daa593d943906
|
|
| MD5 |
6d81f1783c94cfcdc0cc1d5c89b4e466
|
|
| BLAKE2b-256 |
95804cf91eb248dcdc7d5649ecde1b86bcde7bcd85b3e5afae7fd8a45959a313
|
Provenance
The following attestation bundles were made for quercle_pydantic_ai-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on quercledev/quercle-pydantic-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quercle_pydantic_ai-1.0.1-py3-none-any.whl -
Subject digest:
bb47dca34e845d7570c88f3da8049a5abc5feaede27a72594c0daa593d943906 - Sigstore transparency entry: 992420188
- Sigstore integration time:
-
Permalink:
quercledev/quercle-pydantic-ai@57e16f669746399b9360b3e4b75d8191f4b7c8a4 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/quercledev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@57e16f669746399b9360b3e4b75d8191f4b7c8a4 -
Trigger Event:
push
-
Statement type: