Skip to main content

OmegaEngine Logo

openai-omega

OpenAI Integration with OmegaEngine Governance

PyPI License

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)      # "ALLOW" | "BLOCK" | "ESCALATE"
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

Release files for openai-omega 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openai-omega 0.3.0
File Size Uploaded
openai_omega-0.3.0.tar.gz 15.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openai-omega 0.3.0
File Interpreter ABI Platform
openai_omega-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.9 kB

Release files / openai_omega-0.3.0.tar.gz

Download URL openai_omega-0.3.0.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a4ec8e6b982ccdaa1b266c3abf550f2eac5affa8e769b3e3a8a5aeb67eda4335
BLAKE2b-256 checksum
How to use checksums
6141328929bea2a39ea6fb059e035ae558c5454f80d0d4cbe56d18cd7bbb8e36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / openai_omega-0.3.0-py3-none-any.whl

Download URL openai_omega-0.3.0-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7f8e28b6a789b96b46bdb5148a9c9068176ed9a0a22f296e2e17d3629a143a73
BLAKE2b-256 checksum
How to use checksums
b11614eda49ca132c433cd2abbb0b54d560bdda463d6038349325ee76346b7eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page