Metadata-Version: 2.4
Name: tracerazor-openai
Version: 0.2.0
Summary: Drop-in TraceRazor-instrumented OpenAI client. Zero-friction token efficiency auditing.
Author: Zulfaqar Hafez
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/ZulfaqarHafez/tracerazor
Project-URL: Repository, https://github.com/ZulfaqarHafez/tracerazor
Keywords: ai,llm,openai,token-efficiency,tracing,audit
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: tracerazor-sdk>=0.1.0
Requires-Dist: openai>=1.0.0

# tracerazor-openai

Drop-in replacement for `openai.OpenAI` with automatic TraceRazor token-efficiency auditing. Zero friction — change one import line and every `chat.completions.create()` call is captured as a reasoning step.

## Install

```bash
pip install tracerazor-openai
```

You'll also need the `tracerazor` binary on your PATH (or a running `tracerazor-server`).

## Use

```python
from tracerazor_openai import OpenAI

client = OpenAI(agent_name="support-bot")

resp = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Refund order ORD-9182"}],
)

# ... more calls ...

report = client.audit()
print(report.summary())
```

Constructor accepts every kwarg the plain `openai.OpenAI` does plus:

| Kwarg | Default | Meaning |
|---|---|---|
| `agent_name` | `"openai-agent"` | Name used in the TraceRazor report |
| `tracer` | `None` | Append to an existing `Tracer` instead of creating one |
| `server` | `None` | URL of a running `tracerazor-server` (default: local binary) |

## How it works

The wrapper uses composition — every attribute of the underlying `openai.OpenAI` client is proxied via `__getattr__`. Only `chat.completions.create()` is intercepted to record the call as a reasoning step. If instrumentation fails for any reason (parsing, network, etc.) the original response is still returned unchanged.

## License

Apache-2.0
