Skip to main content

Official Python SDK for PromptWall — runtime governance for LLM apps (verify, chat, events, tools) + multi-step trace observability.

Project description

promptwall

Official Python SDK for PromptWall — multi-step LLM observability (events / traces / spans).

pip install promptwall-sdk

Zero runtime dependencies — uses stdlib urllib for HTTP.

Quick start

import promptwall

pw = promptwall.PromptWall(api_key="pk_live_…")

# Datadog-style multi-step trace
with pw.trace("req-abc-123", mode="chat") as tr:

    with tr.span("retrieval") as s:
        s.metadata(chunks=5)
        # … your retrieval code …

    with tr.span("tool_call") as s:
        s.metadata(tool="calendar")
        # … your tool invocation …

    with tr.span("llm_call") as s:
        # … your LLM call …
        s.tokens(prompt=1200, completion=500)
        s.cost_usd(0.018)

# On exit of the trace context, the SDK batches all spans and
# POSTs them to /v1/events as one event.

Configuration

The SDK reads credentials in this order:

  1. Constructor arg: PromptWall(api_key="...")
  2. Env var: PROMPTWALL_API_KEY

Optional env vars:

Name Default
PROMPTWALL_BASE_URL https://api.prompt-wall.com
PROMPTWALL_TIMEOUT 5.0 (seconds)

Span DSL

Inside a with tr.span(...) as s: block, chain any of these:

Method What it does
s.metadata(**kv) Merge structured fields into metadata_json
s.summarize(text) Short human-readable line (summary column)
s.tokens(prompt=N, completion=N, total=N) Per-stage token counts
s.cost_usd(amount) Per-stage USD cost
s.retries(n) Per-stage retry count
s.error(code, summary?) Mark stage as failed (status='error')
s.skip(reason?) Mark stage as skipped

status='error' is also auto-set if the with block raises.

Direct event posting

When the context manager doesn't fit (e.g. async pipelines that collect events into a queue), use the lower-level events.send:

pw.events.send({
    "request_id": "req-1",
    "started_at": "2026-04-27T10:00:00Z",
    "finished_at": "2026-04-27T10:00:02Z",
    "spans": [
        {"stage_name": "retrieval", "latency_ms": 120,
         "metadata": {"chunks": 5}},
        {"stage_name": "llm_call",  "latency_ms": 800,
         "prompt_tokens": 1200, "completion_tokens": 500,
         "cost_usd": 0.018},
    ],
})

Send up to 500 events in one POST via the batch shape:

pw.events.send({"events": [event1, event2, ...]})

Errors

try:
    pw.events.send(...)
except promptwall.AuthError:
    # 401/403 — bad / revoked / wrong-scoped API key
except promptwall.NetworkError:
    # transport error — retry-eligible
except promptwall.PromptWallError:
    # base for everything SDK-raised

Observability is best-effort — most apps should swallow errors at the call site so a temporary outage at PromptWall doesn't break the customer-facing request path.

Versioning

Semver. The 0.x line accepts breaking API changes between minor versions; 1.0 will pin the public surface.

License

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

promptwall_sdk-0.5.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

promptwall_sdk-0.5.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file promptwall_sdk-0.5.0.tar.gz.

File metadata

  • Download URL: promptwall_sdk-0.5.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for promptwall_sdk-0.5.0.tar.gz
Algorithm Hash digest
SHA256 408d3d0a37607d167c77a7c7c4f63b7068632d2c814486fa3086e5c4ea5cb781
MD5 ccdb426493019703e80faae213d7cbc7
BLAKE2b-256 039b8221fe820a097cf6b91168bd0f7af64afbe069bf25550e602aec39cf715b

See more details on using hashes here.

File details

Details for the file promptwall_sdk-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: promptwall_sdk-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for promptwall_sdk-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4ae61a692427a39130f6681e323d3b284134e73f7d4f8af38a2a1df8881d3f46
MD5 766a5cd17105888cb743cf90ba2a3dd8
BLAKE2b-256 1503fcfc5659710606056366c090b4b9d05b6e58ea910f538e8c93413eb8dccf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page