Skip to main content
Output checks run after OpenAI returns final text and before your app receives the result. The wrapper skips output checks when the model response still contains tool calls, because the turn is not finished yet.

Non-streaming Behavior

For non-streaming calls, Averta can return:
  • allow: return the original provider result
  • block: throw AvertaSdkError
  • rewrite: request a safer provider rewrite, then check that rewritten output once more
const response = await client.responses.create({
  model: process.env.OPENAI_MODEL ?? "gpt-5.4-mini",
  input: "Write a customer-safe summary of the account recovery steps.",
});

console.log(response.output_text);

Rewrite Behavior

When Averta returns rewrite, the wrapper sends a provider-specific rewrite instruction and checks the rewritten text with rewriteAttempt: 1 in JavaScript or rewrite_attempt: 1 in Python. If the rewritten output is not allowed, the wrapper throws. Rewrites do not get an unbounded retry loop.

Streaming Behavior

Streaming output checks are supported, but streaming output rewrite is not. If policy requires a rewrite during streaming, the wrapper fails closed instead of continuing to stream unsafe text. Use non-streaming calls when output rewrite is required for your product flow.

Decision Callback

client = wrapOpenAI(client, {
  onDecision(event) {
    if (event.checkpointType === "output") {
      console.log(event.decision.decision);
      console.log(event.decision.actions?.rewrite?.category);
      console.log(event.rewriteAttempt);
    }
  },
});

Debugging

SymptomCheck
No output decisionThe response may contain tool calls, or the output text may be empty.
Rewritten output still blocksInspect error.checkpointDecision on AvertaSdkError.
Streaming fails on rewriteStreaming rewrite is unsupported; use a non-streaming call.