Requirements
Patched methods
openai._base_client.SyncAPIClient.requestopenai._base_client.AsyncAPIClient.request
Usage with ActGuard runtime
Streaming behavior
For/chat/completions streaming calls, ActGuard injects:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
| Requirement | Version |
|---|---|
openai SDK | >=1.76.0 |
| Python | >=3.9 |
pip install "openai>=1.76.0"
openai._base_client.SyncAPIClient.requestopenai._base_client.AsyncAPIClient.requestimport actguard
import openai
client = actguard.Client.from_env()
oai = openai.OpenAI()
with client.run(user_id="alice", run_id="run-openai"):
with client.budget_guard(usd_limit=0.10) as guard:
response = oai.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}],
)
print(guard.tokens_used, guard.usd_used)
/chat/completions streaming calls, ActGuard injects:
{"stream_options": {"include_usage": true}}
