pydantic-ai-contextfetch
ContextFetch web search and page reading tools for Pydantic AI, as a toolset.
pip install pydantic-ai-contextfetch
export CONTEXTFETCH_API_KEY="your-api-key" # optional: without a key, requests use the keyless tier
from pydantic_ai import Agent
from pydantic_ai_contextfetch import ContextFetchToolset
agent = Agent('openai:gpt-5.2', toolsets=[ContextFetchToolset()])
result = agent.run_sync('What changed in the latest Python release?')
print(result.output)
Tools
contextfetch_search(query, include_domains?, exclude_domains?, start_published_date?): web search. Returns a list of{title, url, published_date, content}, wherecontentis the page as Markdown: by default only the parts relevant to the query.contextfetch_read(url, query?): one page as Markdown. Withquery, only the parts relevant to it. A bad or unreachable URL raisesModelRetry, so the model can correct it.
Options
ContextFetchToolset(
api_key=None, # defaults to CONTEXTFETCH_API_KEY
num_results=5, # results per search, 1 to 25
content='pruned_context', # or 'text' for whole pages
id=None, # toolset id for durable execution
)
To expose only one tool, use Pydantic AI's toolset filtering:
ContextFetchToolset().filtered(lambda ctx, tool: tool.name == 'contextfetch_search').
Tests
uv run --group test pytest tests # unit tests, no network
CONTEXTFETCH_API_KEY=... uv run --group test pytest tests/test_live.py # live, 2 credits
MIT licensed.
Metadata
Release files for pydantic-ai-contextfetch 0.1.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 | |
|---|---|---|---|---|
| pydantic_ai_contextfetch-0.1.0.tar.gz | 5.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydantic_ai_contextfetch-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.4 kB
Release files / pydantic_ai_contextfetch-0.1.0.tar.gz
| Download URL | pydantic_ai_contextfetch-0.1.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f72ba6466b0934ad4db7c160ba6099b60c3a4ac6d92432180a0b35ce3f5bc4d
|
|
BLAKE2b-256 checksum How to use checksums |
fbd592502ba700c4d21dd29483e249a9ea2577dc93195210fc9c99e50229729d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / pydantic_ai_contextfetch-0.1.0-py3-none-any.whl
| Download URL | pydantic_ai_contextfetch-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c7dff15809ae23de7eb3c2e63ff2305d4167c5af82c76d5ad328359c6240dd9c
|
|
BLAKE2b-256 checksum How to use checksums |
ee4642ea626db7c49fce1ea95a6414b58ca9db99f114af562ddb9bdcba8428ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Security for pydantic-ai-contextfetch 0.1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.