Skip to main content

mesedi-curl

Transparent curl wrapper that records direct LLM API calls to Mesedi.

For the engineer who runs curl from a notebook, a bash script, or a CI job and bypasses the Mesedi SDK entirely. Wrap the call once and Mesedi sees every request, response, token count, latency, and finish reason.

The wrapper never blocks the underlying request. If Mesedi's backend is unreachable, the user-visible request and response are unaffected; a warning is printed to stderr and the call proceeds as if mesedi-curl were plain curl.

Install

pip install mesedi-curl

Or one-line install via the install script published with each GitHub release:

curl -fsSL https://get.mesedi.ai/curl-shim | bash

Configure

Export your Mesedi project API key:

export MESEDI_API_KEY=mesedi_sk_...

That's the only required variable. Optional:

MESEDI_BACKEND_URL=https://api.mesedi.ai     # default; override for self-host
MESEDI_PROJECT_ID=proj_xxxxxxxx              # usually inferred from key
MESEDI_SILENT=1                              # suppress stderr warnings

If MESEDI_API_KEY is unset the wrapper acts as a pure pass-through, which makes it safe to drop into a script without breaking anyone who has not configured Mesedi yet.

Use

Anywhere you'd run curl, swap in mesedi-curl:

mesedi-curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-opus-4-6",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello, Claude"}]
  }'

Streaming, OpenAI, Gemini, all work the same way. The wrapper detects the provider from the URL and parses tokens accordingly.

To alias curl itself in a CI image:

alias curl=mesedi-curl

…or symlink:

ln -sf "$(which mesedi-curl)" /usr/local/bin/curl

Provider support

Provider Host Streaming Token math
Anthropic api.anthropic.com Yes Yes
OpenAI api.openai.com, *.openai.azure.com Yes Yes (*)
Gemini generativelanguage.googleapis.com, Vertex AI Yes Yes
Other Any URL Yes Pass-through (no token math)

(*) OpenAI streaming emits usage stats only when the request body includes "stream_options": {"include_usage": true}. Without it, token counts in Mesedi will be zero for streaming OpenAI calls. This is an upstream API constraint, not a wrapper limitation.

What ends up in your Mesedi dashboard

Every mesedi-curl invocation creates one execution and one llm_call event under it. The execution carries:

  • request URL, method, HTTP status
  • provider + model name
  • input + output token counts
  • request latency
  • crash signature (transport-level error) or finish reason

The event carries the full request body, response (or streamed text concatenation), and per-call payload fields. Mesedi's seven failure-class detectors run against the event stream the same way they would for a call made through the Python or TypeScript SDKs.

Failure modes

The wrapper is fail-soft on the recording side:

Condition Behavior
MESEDI_API_KEY unset Silent pass-through. Acts as plain curl.
Mesedi backend unreachable Warn once on stderr, proceed with the request normally.
Backend returns 4xx (auth, quota) Warn once on stderr with the response body preview.
Backend returns 5xx Warn once on stderr, proceed.
Provider returns non-JSON or HTML Record the call with a preview of the raw body.

The underlying curl-equivalent request's exit code is never affected by Mesedi-side issues.

Supported flags

A curl-compatible subset:

-X / --request METHOD              HTTP method
-H / --header "Name: value"        Request header (repeatable)
-d / --data DATA                   Request body. @file loads from file, @- reads stdin.
--data-raw DATA                    Request body, no @-expansion.
--data-binary DATA                 Request body, no encoding mangling.
-o / --output FILE                 Write body to FILE instead of stdout.
-s / --silent                      Suppress progress meter.
-i / --include                     Include response headers in output.
-L / --location                    Follow redirects.
-k / --insecure                    Skip TLS verification.
--connect-timeout SECONDS          Connect timeout.
--max-time SECONDS                 Overall timeout.
--version                          Print mesedi-curl version.

Unsupported flags raise a usage error rather than being silently dropped.

License

MIT. See LICENSE in the repo root.

Release files for mesedi-curl 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 mesedi-curl 0.1.0
File Size Uploaded
mesedi_curl-0.1.0.tar.gz 21.6 kB Details

Built distribution (wheel)

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

Total release size: 40.4 kB

Release files / mesedi_curl-0.1.0.tar.gz

Download URL mesedi_curl-0.1.0.tar.gz
Size 21.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bea300ee7012b8021fb837befe357837e315a23e88da629e3d975af2697661aa
BLAKE2b-256 checksum
How to use checksums
6bb052d345a65cfcebc460f6dd082995116c2ff6ee548c0c1fa83231fc3a4bde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 31, 2026.

Transparency log

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

Download URL mesedi_curl-0.1.0-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
40e1e446f92098648ec4590e1bfc5e8364029b3d6930b43f6dd07234a76f01a0
BLAKE2b-256 checksum
How to use checksums
3e0e42a54b6405a85476df5011e6845d4b1642f50409c8809660ddb13690d98f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 31, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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