Skip to main content
Use this page when your agent still uses OpenAI Chat Completions. The OpenAI wrappers guard supported chat calls without changing the native client shape.

Guarded Methods

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

Basic Request

const completion = await client.chat.completions.create({
  model: process.env.OPENAI_MODEL ?? "gpt-5.4-mini",
  messages: [
    {
      role: "user",
      content: "Summarize password reset link expiration guidance.",
    },
  ],
});

console.log(completion.choices[0]?.message.content);
Averta checks the message payload before OpenAI sees it. If the response contains final text, Averta checks that output before returning it.

Tools

const completion = await client.chat.completions.create({
  model: process.env.OPENAI_MODEL ?? "gpt-5.4-mini",
  messages,
  tools: [
    {
      type: "function",
      function: {
        name: "search_docs",
        description: "Search internal support documentation.",
        strict: true,
        parameters: {
          type: "object",
          properties: {
            query: { type: "string" },
          },
          required: ["query"],
          additionalProperties: false,
        },
      },
    },
  ],
});
For Chat Completions tools, Averta can:
  • normalize function and custom tools
  • remove blocked tools before forwarding the request
  • sanitize tool_choice when the requested tool was blocked
  • check returned tool calls before your app executes them

Tool Result Continuation

Send tool results back as tool role messages through the wrapped client.
const nextCompletion = await client.chat.completions.create({
  model: process.env.OPENAI_MODEL ?? "gpt-5.4-mini",
  messages: [
    ...messages,
    completion.choices[0]!.message,
    {
      role: "tool",
      tool_call_id: "call_123",
      content: JSON.stringify({
        matches: ["Password reset links expire after 24 hours."],
      }),
    },
  ],
  tools,
});
Averta evaluates pure tool-result continuation requests before OpenAI sees them.

Streaming

Chat Completions streaming is guarded in both OpenAI wrappers:
const stream = await client.chat.completions.create({
  model: process.env.OPENAI_MODEL ?? "gpt-5.4-mini",
  messages,
  stream: true,
});
It currently supports one streamed text choice. Requests with streaming enabled and n > 1 fail closed before provider execution.

Current Limits

  • Chat Completions streaming supports one streamed text choice.
  • Streaming output rewrite is not supported yet.
  • Rich media request preflight supports Data URL images in image_url.url.
  • Remote image URLs, file content parts, and audio content parts are rejected before preflight.

Tools

Understand OpenAI tool filtering.

Tool results

Screen tool output before continuation.