Skip to main content
Use this page when your agent is built on OpenAI’s Responses API. The wrappers preserve the native OpenAI method names and add Averta decisions around supported calls.

Guarded Methods

MethodJavaScriptPython
client.responses.create(...)SupportedSupported
client.responses.create({ stream: true, ... })SupportedSupported as stream=True
client.responses.stream(...)SupportedSupported

Non-streaming Request

const response = await client.responses.create({
  model: process.env.OPENAI_MODEL ?? "gpt-5.4-mini",
  input: [
    {
      role: "developer",
      content: [{ type: "input_text", text: "Be concise." }],
    },
    {
      role: "user",
      content: [{ type: "input_text", text: "Summarize this runbook." }],
    },
  ],
  tools,
});
Before calling OpenAI, Averta can:
  • normalize request input
  • extract supported image Data URLs
  • normalize tools
  • return block before the provider call
  • return restrict_tools and remove blocked tools before forwarding

Tool Loop Continuation

When the response contains function calls, execute the tools in your app and send the results through the same wrapped client.
const functionCall = response.output.find(
  (item) => item.type === "function_call"
);

if (functionCall) {
  const continuedResponse = await client.responses.create({
    model: process.env.OPENAI_MODEL ?? "gpt-5.4-mini",
    input: [
      ...response.output,
      {
        type: "function_call_output",
        call_id: functionCall.call_id,
        output: JSON.stringify({
          matches: ["Password reset links expire after 24 hours."],
        }),
      },
    ],
    tools,
  });

  console.log(continuedResponse.output_text);
}
On continuation calls, Averta evaluates new function_call_output items before OpenAI sees them.

Output Checks

If the response is final text and does not contain tool calls, Averta evaluates the output before returning it to your app. For non-streaming output:
  • allow returns the original result
  • block throws AvertaSdkError
  • rewrite asks OpenAI for a rewritten result and checks that rewritten output once more

Streaming

Responses streaming is guarded in both OpenAI wrappers:
const stream = await client.responses.create({
  model: process.env.OPENAI_MODEL ?? "gpt-5.4-mini",
  input: "Summarize password reset link expiration guidance.",
  stream: true,
});
const stream = client.responses.stream({
  model: process.env.OPENAI_MODEL ?? "gpt-5.4-mini",
  input: "Summarize password reset link expiration guidance.",
});
For streaming calls, request and tool-result checks run before the stream opens. Streaming output is checked as it is produced.

Current Limits

  • Responses streaming supports one output text stream per response.
  • Streaming output rewrite is not supported yet. If policy requires rewrite, the wrapper fails closed.
  • Rich media request preflight supports Data URL images only.
  • Remote image URLs, OpenAI file IDs, file content parts, and audio parts are rejected before preflight.

Debugging

SymptomCheck
No request decisionConfirm the OpenAI client is wrapped before responses.create(...) is called.
No tool-result decisionConfirm the continuation sends function_call_output through the wrapped client.
Missing tool after requestCheck request decision blockedTools and dashboard tool exposure policy.
Stream fails on unsafe textStreaming rewrite is unsupported; use non-streaming calls for rewrite behavior.

Tools

Learn how tool exposure filtering works.

Streaming

See streaming-specific limits.

Tool results

Screen returned tool content.

Output checks

Understand output blocks and rewrites.