Skip to main content
The SDK replaces your OpenAI or Anthropic client with one that emits structured telemetry on every call. The calling code does not otherwise change.
Not yet published to PyPI. Install from source — see below. When the package ships, pip install "prompt-shields[openai]" will be the route.

Install

Requires Python 3.11 or later.

Hello world

Note that the Anthropic surface is deliberately identical — chat.completions.create, not Anthropic’s native messages.create — so switching vendors touches one line.

Constructor arguments

One client per use case

Constructor metadata is immutable per instance and stamps every event, so a single shared global client collapses unrelated work into one meaningless registry entry.
In FastAPI, build these once at startup rather than per request.

Privacy behaviour

Detected PII categories are email, phone, ssn, credit_card, ip_address, iban, health_data, and financial_data. Detection is pattern-based and runs locally.
send_prompt_text=True ships full prompt content to your collector. It exists for narrow debugging cases and should not be enabled without a security review — it inverts the product’s central privacy guarantee.

Fail-open by design

Telemetry never blocks a model call.
  • Events buffer locally, up to 1000, and retry with exponential backoff.
  • On overflow, the oldest events drop first.
  • A collector outage degrades your discovery data. It does not degrade your application.

What else is captured