Skip to main content
The Averta OpenAI wrappers keep the native OpenAI SDK shape intact. After wrapping, you still call the native OpenAI methods. Averta adds decisions around supported request, tool, stream, and output paths.
import OpenAI from "openai";
import { wrapOpenAI } from "@averta-security/sdk-openai";

let client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY!,
});

client = wrapOpenAI(client);

Supported Surfaces

SurfaceJavaScriptPython
responses.create(...)YesYes
responses.create({ stream: true, ... })YesYes, as stream=True
responses.stream(...)YesYes
chat.completions.create(...)YesYes
chat.completions.create({ stream: true, ... })YesYes, as stream=True
Unsupported helpers under guarded Python namespaces fail closed. Provider surfaces not listed here are outside Averta coverage; JavaScript and Python clients may keep their native behavior there unless you add separate enforcement.

What Averta Checks

Depending on the call shape, the wrapper can:
  • evaluate request input before it reaches OpenAI
  • filter tools when policy returns restrict_tools
  • evaluate model-requested tool calls before your app executes them
  • evaluate tool results before they go back to the model
  • evaluate non-streaming final output and request a rewrite when policy allows it
  • evaluate streaming text as it is produced

Current Limits

  • Rich media support is limited to Data URL images for supported image MIME types.
  • Chat Completions streaming supports one streamed text choice.
  • Responses streaming supports one output text stream per response.
  • Output rewrites are supported for non-streaming calls.
  • Streaming output rewrite is not supported and fails closed.

Reading Path

Start with the quickstart, then read the page for the OpenAI surface your agent uses.

Quickstart

Wrap an OpenAI client and run a guarded request.

Responses API

Guard responses.create(...) and Responses tool loops.

Chat Completions

Guard chat.completions.create(...) calls.

Tools

Understand request-time tool exposure filtering.

Output checks

Understand final-answer checks and rewrites.