OpenAI SDK with OmegaEngine governance - AI safety and compliance
Project description
openai-omega
OpenAI Integration with OmegaEngine Governance
Documentation • Playground • Issues
✨ Features
- 🤖 Drop-in Replacement — Same API as official OpenAI SDK
- 🛡️ Pre-flight Validation — Block unsafe prompts before sending
- 📊 Response Governance — Filter outputs against policies
- 📈 Full Audit Trail — Log every GPT-4/GPT-5 interaction
- ⚡ Streaming Support — Governed streaming responses
- 🔧 Function Call Validation — Validate tool calls before execution
- 🎯 Assistants API — Govern OpenAI Assistants
📦 Installation
Python
pip install openai-omega
🚀 Quick Start (Python)
from openai_omega import OpenAI
# Drop-in replacement for OpenAI client
client = OpenAI(
openai_api_key="your-openai-key",
omega_api_key="your-omega-key",
policy_id="gpt_policy",
)
# Same API, but governed
response = client.chat.completions.create(
model="gpt-4-turbo",
messages=[
{"role": "user", "content": "Help me with marketing"}
]
)
print(response.choices[0].message.content)
# Access governance metadata
print(response.omega_decision) # "APPROVE"
print(response.omega_audit_id) # "aud_abc123"
print(response.omega_risk_score) # 15
🛡️ Pre-flight Validation
Block unsafe prompts before they reach OpenAI:
client = OpenAI(
openai_api_key="...",
omega_api_key="...",
preflight_check=True,
block_on_deny=True,
)
try:
response = client.chat.completions.create(
model="gpt-4-turbo",
messages=[{"role": "user", "content": "...jailbreak attempt..."}]
)
except OmegaBlockedError as e:
print(f"Blocked: {e.reason}")
print(f"Risk score: {e.risk_score}")
🔧 Function Call Governance
Validate function/tool calls before execution:
response = client.chat.completions.create(
model="gpt-4-turbo",
messages=[...],
tools=[...],
omega_validate_tools=True, # Validate tool calls
)
for tool_call in response.choices[0].message.tool_calls:
if tool_call.omega_approved:
execute_tool(tool_call)
else:
print(f"Tool blocked: {tool_call.omega_reason}")
📡 Governed Streaming
with client.chat.completions.create(
model="gpt-4-turbo",
messages=[{"role": "user", "content": "Write a story"}],
stream=True,
) as stream:
for chunk in stream:
print(chunk.choices[0].delta.content, end="")
print(f"\nDecision: {stream.omega_decision}")
🤖 Assistants API Support
# Governed Assistants
assistant = client.beta.assistants.create(
name="Analyst",
model="gpt-4-turbo",
omega_policy_id="assistant_policy",
)
# All threads are governed
thread = client.beta.threads.create()
message = client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content="Analyze this data..."
)
run = client.beta.threads.runs.create(
thread_id=thread.id,
assistant_id=assistant.id,
)
# Access governance metadata
print(run.omega_audit_id)
📊 What Gets Logged
| Field | Logged |
|---|---|
| Input messages | ✅ |
| Output response | ✅ |
| Token usage | ✅ |
| Model used | ✅ |
| Latency | ✅ |
| Policy evaluation | ✅ |
| Risk score | ✅ |
| Function calls | ✅ |
| Audit trail ID | ✅ |
📄 License
Licensed under the Apache License 2.0.
Built with ❤️ by the OmegaEngine team
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 openai_omega-0.1.1.tar.gz.
File metadata
- Download URL: openai_omega-0.1.1.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77b6eaeb59f187f22c2d037370d6c85b9362ba62a3aec61d44fb7a018574b4c9
|
|
| MD5 |
dd9553f01a8d0314f1149b0a692ed140
|
|
| BLAKE2b-256 |
d6d3974c19748c8501a0073a6fefad2e6c3839f994603eaad4d6506b54fa0d8b
|
File details
Details for the file openai_omega-0.1.1-py3-none-any.whl.
File metadata
- Download URL: openai_omega-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf822c58dc914dc829ca14f9ff518f10536a67aff3a773ce137054d92ece90a0
|
|
| MD5 |
490923e029a4807254817725541db045
|
|
| BLAKE2b-256 |
de3bbe3eea0a2453b2139d38e3b468dc82311f65ee0d0e6b70e9719f640c3cae
|