Your local LLM returned garbage. The response is valid JSON, correct shape, proper finish reason. But the content is wrong. The summary ignores half the input. The translation is in the wrong language. The function call has the wrong arguments. Was the prompt malformed? Did the system message get truncated? Was the temperature set to 2.0 instead of 0.2? You can't tell from the output alone. You need to see what was actually sent.

Cloud APIs have dashboards for this. OpenAI shows your request history in the playground. Anthropic's console logs your calls. But when you run a local LLM through ToolPiper's API gateway, the request goes to localhost and the payload vanishes after the response comes back. If something went wrong, you're adding console.log and re-running. Or worse, you're guessing.

LogPiper, the log bus inside ToolPiper, closes that gap, and the catch is worth knowing up front: it doesn't intercept traffic. A body is in the log because something posted it there. Two sources do that on their own: the ModelPiper web app when it runs on your Mac, and ToolPiper's cloud proxy when a streaming call fails. For everything else, including your own app's calls to a local model, you post the request and response yourself, which takes a few lines of code, and LogPiper stores them whole. After that, one query pulls them back.

What Does HTTP Body Capture Actually Mean?

Most logging systems capture metadata: URL, status code, duration, maybe a few headers. That's fine for knowing that a request happened. It's useless for knowing why it failed.

LogPiper stores the payload. The JSON your app assembled and sent. The JSON the model returned. When a cloud API rejects your request, the error message in the response body tells you exactly what went wrong. When a local model produces bad output, the prompt in the request body tells you exactly what it was working with.

ToolPiper itself logs events, not payloads: auth decisions, backend output and crashes, the MCP tools an assistant called. It does not log the request or response body of a local model call it serves. So the payload has to come from the side that holds it, the client. The ModelPiper web app does this for its own calls. Your code can do the same with one POST per call.

What Gets Captured Automatically?

Two sources write bodies without any setup.

The ModelPiper web app, when it runs locally. Loaded from localhost or 127.0.0.1, the web app logs its own HTTP calls under the source app. The hosted app at modelpiper.com logs nothing. Four event types cover the request lifecycle:

  • http.request: method, url, toolId (which tool or feature initiated the request) and requestBody, the payload the app sent
  • http.response: status, contentType and responseBody, with durationMs on the entry
  • http.error: method, url, status and the responseBody the server sent back, not a generic status
  • http.cancel: a request that timed out or was cancelled before it finished

Bodies are cut at 8,000 characters, with a note giving the full length. JSON fields with credential names (apiKey, token, authorization and similar) are replaced with [REDACTED]. Binary responses like audio or images show type and size instead of raw bytes. Streaming responses log the status, not the body.

ToolPiper's cloud proxy. Calls routed through the proxy leave cloud.proxy.* entries: cloud.proxy.request with the URL, method and whether the call streams, then cloud.proxy.response when it finishes. When a streaming call comes back with a 400 or higher, cloud.proxy.error carries the provider's error body in responseBody, up to 8,192 characters. Non-streaming calls log the status and response size only, and a successful response body is never logged.

ToolPiper also logs the arguments of each MCP tool call (mcp.tools.call, with credential keys masked), but not what the tool returned.

Capturing Bodies From Your Own Code

Your app's calls to a local model aren't in the log until your app puts them there. That's one POST to http://127.0.0.1:9998/v1/logs per call, and it needs no token from the same Mac. Wrap your HTTP client once:

import time, requests

LOGPIPER = "http://127.0.0.1:9998/v1/logs"

def logged_post(url, payload, **kwargs):
    start = time.time()
    r = requests.post(url, json=payload, **kwargs)
    failed = r.status_code >= 400
    try:
        requests.post(LOGPIPER, json={
            "source": "my-app",
            "event": "http.error" if failed else "http.response",
            "level": "error" if failed else "info",
            "message": f"POST {url} {r.status_code}",
            "durationMs": round((time.time() - start) * 1000),
            "data": {"url": url, "requestBody": payload,
                     "status": r.status_code, "responseBody": r.text},
        }, timeout=2)
    except requests.RequestException:
        pass  # logging must never break the app
    return r

Call logged_post wherever you called requests.post. Headers pass straight through and aren't logged, so a key in Authorization stays out of the log. The payload is logged as is, so keep secrets out of the body. Bodies you post aren't truncated: there's no per-entry cap, only a 25 MB limit per request. Using the web app's event names means the HTTP queries below work for both; add source=my-app to see only yours.

Every field is optional. level must be debug, info, warn or error. Any other value, warning included, fails the whole request with a 400. You can also send an array of entries in one POST, and one bad entry rejects the batch.

Debugging a Bad Chat Completion

Here's a scenario that happens weekly if you're building against a local model. You send a chat completion request. The model responds. The response is structurally valid but the content is wrong.

Query the logs:

curl "http://127.0.0.1:9998/v1/logs?event=http&limit=10"

The response is a JSON array, oldest first. Find the entry for your chat completion call and look at requestBody: an http.request entry if the web app made the call, or the entry your wrapper posted. The messages array is right there. (The All Logs view in ToolPiper's main window shows the same entries; select one to see its data payload.) Now you can see the problem.

Scenario 1: Silent variable substitution failure. The system prompt reads "You are a helpful assistant" instead of your custom prompt. The template variable didn't resolve. Your code passed the raw template string to the API. Without body capture, you'd have spent twenty minutes swapping prompts and re-running. With body capture, you see the literal text that was sent and the bug is obvious.

Scenario 2: Model name typo. The http.error entry shows {"error":{"message":"Model 'llama-3.2-3' not found. Available models: ...","type":"model_not_found","status":404}}. You typed llama-3.2-3 instead of llama-3.2-3b. The error response body from ToolPiper told you exactly what happened, but your app's HTTP client swallowed it and threw a generic "request failed" exception. LogPiper has the original.

Scenario 3: Wrong parameter value. The requestBody shows "temperature": 2.0. You meant 0.2. A config file had a missing decimal point. The model did what you asked, technically. It generated text with maximum randomness. The output looked like garbage because the input told it to be chaotic.

Each of these is a one-query diagnosis. Without body capture, each one is a multi-round guessing game where you change things, re-run, check the output, and hope you changed the right thing.

Debugging Cloud API Proxy Errors

ToolPiper proxies cloud API requests to OpenAI, Anthropic, and Gemini, injecting API keys from your macOS Keychain so they never touch your code or environment variables. When a proxied request fails, the cloud provider's error response contains the diagnosis. But most HTTP client libraries throw an exception with the status code and discard the body.

For streaming calls, LogPiper keeps the body.

curl "http://127.0.0.1:9998/v1/logs?event=cloud.proxy.error&limit=5"

The responseBody field contains the actual error message from the provider. "Invalid API key" means the Keychain entry is wrong or expired. "Rate limited" means you've hit your quota. "The model 'gpt-4-turbo' does not exist" means OpenAI renamed the model and your code has a stale identifier. These error messages are specific and actionable, but only if you can read them. LogPiper makes sure you can.

Non-streaming proxy calls log the status and response size, not the body. If the web app made the call, its own http.error entry has the body. If your code made it, log the response yourself.

This is particularly useful during provider API changes. Cloud providers deprecate model names, change rate limits, modify response formats. The first sign is usually an opaque error in your application. The responseBody in LogPiper tells you what changed.

Using Duration to Find Performance Problems

Every http.response entry from the web app includes durationMs, and entries you post can carry it too (the wrapper above sets it). For a buffered request it's the round-trip time, and it tells you things that no amount of prompt tweaking will reveal. For the web app's streaming calls it's the time until the response headers arrived, not until the last token.

curl "http://127.0.0.1:9998/v1/logs?event=http.response&limit=50"

Scan the durationMs values. Patterns emerge quickly.

If your first chat completion takes 12,000ms but subsequent ones take 800ms, the model is loading into memory on first use. That's normal behavior for local inference, but if your app doesn't account for the cold-start delay, users see a long hang on the first request. Now you know to add a warm-up call at startup.

If every request takes 45,000ms regardless of prompt length, the model might be too large for your available memory. ToolPiper serves models through llama.cpp, and when a model exceeds available RAM, the system pages to disk and inference grinds. The fix is to use a smaller quantization or a smaller model. The durationMs field is the signal that tells you to look.

If requests to a cloud proxy take 3,000ms on average but spike to 15,000ms intermittently, you're hitting provider-side load balancing or rate limit backoff. The timing data in LogPiper shows the pattern without requiring a dedicated profiling tool.

Streaming Response Detection

Chat streaming is the default for most AI applications. ToolPiper serves SSE and NDJSON streams for token-by-token output. LogPiper handles these differently from regular request/response pairs.

When the web app streams a response, it logs the request body as usual, then an http.response entry as soon as the headers arrive, with the status, the content type and isStreaming: true. There's no response body and no chunk count: the tokens are never logged. If the server refuses the call before streaming starts, the http.error entry carries the error body.

When you need to see what a stream produced, record it yourself. Have your stream handler post one entry when the stream ends, with the assembled text, the chunk count and the finish reason. A low chunk count might mean the model hit a stop sequence early. An unexpectedly high count might mean the model is rambling past your max_tokens limit (some backends soft-cap instead of hard-cutting). If the count is zero, the stream connected but produced no data, which usually means the model failed to load or ran out of memory mid-generation.

Post one entry per stream, not one per chunk. Every entry shares a 5,000-entry buffer, and a busy streaming session would push everything else out in seconds.

The Debugging Workflow

Four commands. Run them in order.

# 1. Clear old entries so you're working with a clean slate
#    (needs a token; the Clear Logs button in All Logs works too)
curl -X POST http://127.0.0.1:9998/v1/logs/clear \
  -H "Authorization: Bearer tp_your_token"

# 2. Make the API call that's failing
# (run your app, hit the endpoint, trigger the bug)

# 3. Check what happened
curl "http://127.0.0.1:9998/v1/logs?event=http&limit=20"

# 4. Narrow to errors if needed
curl "http://127.0.0.1:9998/v1/logs?event=http.error&limit=10"

Clearing needs a bearer token with the system:control scope, even from the same Mac. Create one in ToolPiper's Security pane, or skip the command and use the Clear Logs button in the All Logs view. Reading and posting need no token from the same Mac, so any terminal, script or AI assistant on your Mac can query the log without managing credentials. The token-free path is for callers on your Mac only.

If you need to keep logs from a debugging session before clearing, POST /v1/logs/export (same token) writes the current buffer to a JSON file under ~/Library/Application Support/ToolPiper/exports/ and returns its path. Export before you quit ToolPiper, too: the buffer lives in memory, and nothing survives a restart.

Hand It to Your AI Assistant

The real power of structured HTTP body capture isn't reading the logs yourself. It's handing them to an AI coding assistant.

When Claude Code, Cursor, or any assistant that can run a shell command is debugging your API integration, the logs are one command away. Tell the assistant:

"Query LogPiper for HTTP errors: curl "http://127.0.0.1:9998/v1/logs?event=http.error&limit=10""

The assistant runs the command, reads the structured JSON, and sees the request body that caused the error and the response body that explains it, whichever the web app or your wrapper logged. It doesn't need to guess what your code sent. It doesn't need to add print statements and re-run. The data is there, in a format it already understands.

There's no MCP tool for reading the log. Plain HTTP is the interface, and it needs no token from the same Mac, so every coding assistant can already use it.

One query. One diagnosis. One fix. Compare that to the typical cycle: the assistant guesses at the problem, rewrites the code, you run it, it fails again, the assistant guesses differently. Three rounds of inference when one round of observation would have been enough.

What HTTP Body Capture Doesn't Cover

LogPiper doesn't intercept anything. Traffic between your app and a local model, a database, a Redis instance or a separate API server isn't in the log until your code posts it. ToolPiper doesn't log the bodies of local model calls it serves, what an MCP tool returned, or a successful cloud proxy response.

The web app's bodies stop at 8,000 characters. If it sends a 50KB document as part of a RAG prompt, you'll see the first 8,000 characters and a note with the full length. Bodies you post yourself are stored whole, but every entry shares one in-memory buffer of 5,000 entries, oldest evicted first, and nothing survives a ToolPiper restart. Export what you want to keep.

Streaming content isn't stored unless you post it. The web app logs a streaming call's status, not its tokens. If you need to debug a specific token in a stream, add a log call in your streaming handler that posts to /v1/logs.

And this is macOS only. ToolPiper runs on your Mac with Apple Silicon. If you're debugging a remote server or a Linux CI pipeline, LogPiper isn't in the picture.

Try It

ToolPiper is a free download from the modelpiper.com/download. Install it and LogPiper is already running. Next time a model call returns something unexpected, skip the print statements. Log it once through the wrapper above, then query http://127.0.0.1:9998/v1/logs?event=http&limit=10 and read what actually happened.

This is part of the vibe debugging series on observability for AI-assisted development. For the full LogPiper technical overview, see LogPiper: A Universal Logging Bus That Ships Free Inside ToolPiper.