Metadata-Version: 2.4
Name: openai-omega
Version: 0.1.1
Summary: OpenAI SDK with OmegaEngine governance - AI safety and compliance
Project-URL: Homepage, https://omegaengine.ai
Project-URL: Documentation, https://omegaengine.ai/docs
Project-URL: Repository, https://github.com/TheArkhitect/Omegaengine/tree/main/open-source-repos/openai-omega
Project-URL: Issues, https://github.com/TheArkhitect/Omegaengine/issues
Author-email: OmegaEngine <team@omegaengine.ai>
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: ai-safety,audit,compliance,governance,gpt,gpt-4,llm,omegaengine,openai
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Security
Requires-Python: >=3.9
Requires-Dist: httpx>=0.24.0
Requires-Dist: openai>=1.0.0
Provides-Extra: dev
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Description-Content-Type: text/markdown

<p align="center">
  <img src="logo.png" alt="OmegaEngine Logo" width="200" height="200">
</p>

<h1 align="center">openai-omega</h1>

<p align="center">
  <strong>OpenAI Integration with OmegaEngine Governance</strong>
</p>

<p align="center">
  <a href="https://pypi.org/project/openai-omega/"><img src="https://img.shields.io/pypi/v/openai-omega?color=blue&label=PyPI" alt="PyPI"></a>
  <a href="https://github.com/TheArkhitect/Omegaengine/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue" alt="License"></a>
</p>

<p align="center">
  <a href="https://omegaengine.ai/docs">Documentation</a> •
  <a href="https://omegaengine.ai/playground">Playground</a> •
  <a href="https://github.com/TheArkhitect/Omegaengine/issues">Issues</a>
</p>

---

## ✨ 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
```bash
pip install openai-omega
```


---

## 🚀 Quick Start (Python)

```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:

```python
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:

```python
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

```python
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

```python
# 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](LICENSE).

---

<p align="center">
  Built with ❤️ by the <a href="https://omegaengine.ai">OmegaEngine</a> team
</p>
