Skip to main content

agenttap

Wire-level prompt introspection for LLM SDK calls. See exactly what was sent. Credentials redacted by default. Works with any httpx-based SDK (Anthropic, OpenAI, etc).

pip install agenttap

Why

Five years into the SDK era, "what was actually sent to the model?" remains a hard question. SDK debug logging is verbose, leaks API keys, and reformats payloads. Callbacks scatter across vendor-specific abstractions. agenttap taps the wire at the httpx transport layer so you see the exact request body the provider received — with Authorization, x-api-key, and known key patterns scrubbed automatically.

Quick start

Anthropic

import httpx
import anthropic
from agenttap import Tap

tap = Tap()
client = anthropic.Anthropic(http_client=httpx.Client(transport=tap.transport()))

client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=200,
    messages=[{"role": "user", "content": "Hello"}],
)

print(tap.last.url)                  # https://api.anthropic.com/v1/messages
print(tap.last.pretty_request())     # exact JSON sent
print(tap.last.response_status)      # 200

OpenAI

import httpx
import openai
from agenttap import Tap

tap = Tap()
client = openai.OpenAI(http_client=httpx.Client(transport=tap.transport()))

client.chat.completions.create(
    model="gpt-4o", messages=[{"role": "user", "content": "Hi"}]
)

print(tap.last.request_body)

Diff two requests

from agenttap import diff

# After two calls
print(diff(tap.all[0], tap.all[1]))
# - "system": "v1: be helpful"
# + "system": "v2: be concise"

What's redacted by default

  • Headers: Authorization, x-api-key, api-key, cookie, anthropic-api-key, openai-organization, x-amz-security-token, x-google-api-key
  • Body string values matching: OpenAI/Anthropic sk-…, AWS AKIA…, Google AIza…, Slack xox[baprs]-…

Override with a custom Redactor:

from agenttap import Tap, Redactor

tap = Tap(redactor=Redactor.none())   # no scrubbing
tap = Tap(redactor=Redactor(placeholder="<hidden>"))

API

Tap(redactor=None, history_size=1000)

tap.transport(parent=None)         # for httpx.Client(transport=...)
tap.async_transport(parent=None)   # for httpx.AsyncClient(transport=...)

tap.last                           # most recent TappedCall
tap.all                            # list[TappedCall]
tap.reset()
with tap.session() as sub: ...     # scoped sub-tap, results merged on exit

TappedCall.method, .url
TappedCall.request_headers, .request_body
TappedCall.response_status, .response_headers, .response_body
TappedCall.elapsed_ms
TappedCall.pretty_request()

diff(a, b)                         # unified diff of request bodies

What it doesn't do

  • Not a proxy. Not a server. No UI. No persistence (write tap.all to JSON yourself).
  • Not full observability — for traces, ship the recorded calls into Phoenix/Langfuse/OTel.
  • Doesn't normalize across providers. The whole point is to show what each provider actually received.

License

MIT

Metadata

Release files for agenttap 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agenttap 0.1.0
File Size Uploaded Provenance
agenttap-0.1.0.tar.gz 6.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for agenttap 0.1.0
File Interpreter ABI Platform
agenttap-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / agenttap-0.1.0.tar.gz

Download URL agenttap-0.1.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
29dfc88b4a7096a0362bd7330542634ea959236fe071c2edb88de037a3b1bf1a
BLAKE2b-256 checksum
How to use checksums
8d8cba15b8080b26b42d0687f2f67c51ffa95582487f66f0c960615608948153
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / agenttap-0.1.0-py3-none-any.whl

Download URL agenttap-0.1.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
afc5ada524394d8f21946e13fdee0c790b69b2c52ab865b4f79367d262c7433c
BLAKE2b-256 checksum
How to use checksums
a92e153797a5efc12270972035664337a56e99b1ee581187f6cf1dcd344f4f90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for agenttap 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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