Drop-in TraceRazor-instrumented OpenAI client. Zero-friction token efficiency auditing.
Project description
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
pip install tracerazor-openai
You'll also need the tracerazor binary on your PATH (or a running tracerazor-server).
Use
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tracerazor_openai-0.2.0.tar.gz.
File metadata
- Download URL: tracerazor_openai-0.2.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3670165458f1378d5942ff89fae605225e4b98207545f8aa99af62d1b18d38dd
|
|
| MD5 |
cc0abd0e1e33f6c8125e4f1d637e1a5e
|
|
| BLAKE2b-256 |
e1121657f5c572f3dfbfef433d0779aac3243bb092988bfb3e1d3f33b8b6f237
|
File details
Details for the file tracerazor_openai-0.2.0-py3-none-any.whl.
File metadata
- Download URL: tracerazor_openai-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdff203d878ca45a93db8aa54311092cdbad5d41fc83996c55332f9f037bddb4
|
|
| MD5 |
512c52ad2ad2cdc60e73a4a799652bb3
|
|
| BLAKE2b-256 |
f36ff1f5d04a40ec83e3a412b675ce029ebf791d8df57967d0e018a92264a7ab
|