# Raw OpenAI (no framework) (/docs/python/cookbook/raw-openai)



If you're calling the OpenAI client directly — no Agents SDK — screen the
prompt yourself before the call. If Tawa blocks or leans toward blocking,
the request is rejected without ever reaching OpenAI.

```python
import os
from openai import OpenAI
from tawaguard import TawaGuard

openai = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
tawa = TawaGuard(os.environ["TAWA_API_KEY"])

_BLOCKED_ACTIONS = {"block", "hard_block", "soft_block"}


def chat(user_message: str):
    scan = tawa.analyze(user_message)

    if scan.action in _BLOCKED_ACTIONS or scan.suggestion == "block":
        raise ValueError("Message blocked by content policy.")

    return openai.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": user_message}],
    )
```

<Callout type="info">
  Building a Python agent with the OpenAI Agents SDK? The [OpenAI Agents SDK
  integration](/docs/python/integrations/openai-agents-sdk) wraps this
  pattern for you — no manual check needed at every call site.
</Callout>
