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



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

```ts
import OpenAI from "openai";
import { TawaGuard } from "@tawaguard/sdk";

const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const tawa = await TawaGuard.create(process.env.TAWA_API_KEY!);

const BLOCKED_ACTIONS = new Set(["block", "hard_block", "soft_block"]);

async function chat(userMessage: string) {
  const scan = await tawa.analyze(userMessage);

  if (BLOCKED_ACTIONS.has(scan.action) || scan.suggestion === "block") {
    throw new Error("Message blocked by content policy.");
  }

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

<Callout type="info">
  On Next.js with the Vercel AI SDK? The [Vercel AI SDK
  integration](/docs/typescript/integrations/vercel-ai-sdk) wraps this
  pattern for you — no manual check needed at every call site.
</Callout>
