OpenAI Agent Guardrails with Veto

Runtime authorization for GPT-4, GPT-4o, and GPT-5 agents. Block dangerous function calls, enforce policies, and maintain control without modifying your agent logic.

OpenAI agent guardrails for function calling

OpenAI agent guardrails intercept function calls from GPT models before execution, evaluating each action against authorization policies. Unlike prompt-based instructions, guardrails operate independently of the model's reasoning and cannot be bypassed through prompt injection or model confusion.

Why OpenAI agents need authorization

OpenAI's function calling feature lets GPT models trigger real actions in your system. An agent that can call functions without authorization is an agent that can delete data, send emails, process payments, or modify production systems based on model output. The model decides what to do, and your code executes it without question.

This architecture is convenient but dangerous. Prompt injection attacks can trick models into calling unintended functions. Misunderstood instructions lead to wrong actions. Edge cases the model wasn't trained on produce unexpected behavior. Without authorization, every function call is a potential incident waiting to happen.

GPT authorization solves this by inserting a policy layer between the model's decision and your code's execution. The model proposes an action, Veto evaluates it against your rules, and only authorized calls reach your implementation. This works regardless of what the model thinks it should do or what prompts it receives.

Prompt injection

Attackers craft inputs that trick the model into calling dangerous functions. Authorization blocks unauthorized calls regardless of input.

Scope creep

Agents expand beyond their intended purpose. Authorization keeps them within defined boundaries you control.

Audit trails

Every function call is logged with context. Know exactly what your agents did and why.

Quick integration

Wrap your OpenAI tools with Veto's protect() function. The agent code stays the same. Authorization happens automatically.

TypeScript
import OpenAI from 'openai'
import { protect } from 'veto-sdk'

const openai = new OpenAI()

// Define your tools
const tools = [
  {
    type: 'function',
    function: {
      name: 'send_email',
      description: 'Send an email to a customer',
      parameters: {
        type: 'object',
        properties: {
          to: { type: 'string' },
          subject: { type: 'string' },
          body: { type: 'string' },
        },
        required: ['to', 'subject', 'body'],
      },
    },
  },
  {
    type: 'function',
    function: {
      name: 'process_payment',
      description: 'Process a payment',
      parameters: {
        type: 'object',
        properties: {
          amount: { type: 'number' },
          currency: { type: 'string' },
        },
        required: ['amount'],
      },
    },
  },
]

// Wrap with Veto for authorization
const protectedTools = await protect(tools, {
  apiKey: process.env.VETO_API_KEY,
  policyPath: './veto/rules',
})

// Use normally with GPT-4, GPT-4o, or GPT-5
const response = await openai.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Send a welcome email' }],
  tools: protectedTools,
})

// Tool calls are now authorized before execution
const toolCall = response.choices[0].message.tool_calls?.[0]
if (toolCall) {
  // Veto already validated this action against your policies
  console.log('Authorized tool call:', toolCall.function.name)
}

Common OpenAI guardrails

Define policies for the actions your OpenAI agent can take. Block dangerous operations, require approvals for sensitive actions, and log everything for compliance.

Function allowlists

Whitelist which functions the agent can call. Block everything else by default.

Parameter validation

Restrict function arguments based on type, range, or pattern matching.

Rate limiting

Limit how often functions can be called. Prevent runaway agents.

Approval workflows

Route sensitive function calls to humans for review before execution.

Context awareness

Different rules based on user, time, environment, or session context.

Audit logging

Every function call logged with arguments, decision, and timestamp.

Policy example

Define authorization rules in declarative YAML. Version control alongside your code. Rollback, review, and audit just like any other change.

veto/rules/openai-policies.yaml
# veto/rules/openai-policies.yaml
version: "1.0"
name: OpenAI agent guardrails

rules:
  # Block emails to competitors
  - id: block-competitor-emails
    name: Block competitor email domains
    action: block
    tools: [send_email]
    conditions:
      - field: arguments.to
        operator: matches
        value: "@competitor\\.com$"
    message: "Cannot send emails to competitor domains"

  # Require approval for large payments
  - id: review-large-payments
    name: Review payments over $500
    action: require_approval
    tools: [process_payment]
    conditions:
      - field: arguments.amount
        operator: greater_than
        value: 500
    approvers: [finance-team]

  # Block payments outside business hours
  - id: block-after-hours-payments
    name: No payments outside 9-5
    action: block
    tools: [process_payment]
    conditions:
      - field: context.time.hour
        operator: less_than
        value: 9
      - field: context.time.hour
        operator: greater_than
        value: 17
    message: "Payments require business hours approval"

Getting started

1

Install the SDK

npm install veto-sdk
2

Create a policy file

Add veto/rules.yaml to your project. Define which function calls are allowed, blocked, or need approval.

3

Wrap your tools

Pass your OpenAI tools array through protect(). Everything else stays the same.

4

Deploy with confidence

Your OpenAI agent is now governed. Every function call is authorized, logged, and auditable. No more hoping the model behaves.

Supported OpenAI models

Veto works with all OpenAI models that support function calling.

GPT-4
GPT-4 Turbo
GPT-4o
GPT-4o-mini
GPT-5
o1
o1-mini
o3-mini

Related integrations

Frequently asked questions

How does Veto integrate with OpenAI function calling?
Veto wraps your tools array before passing it to the OpenAI API. When the model decides to call a function, Veto intercepts the call, evaluates it against your policies, and only allows authorized calls to execute. The integration is transparent to the model.
Does this add latency to OpenAI agent responses?
Policy evaluation happens locally and typically completes in under 10ms. This is negligible compared to model inference time. For approval workflows, the action pauses until a human responds, but standard allow/block decisions are immediate.
Can I use Veto with OpenAI Assistants API?
Yes. Veto supports both the Chat Completions API and the Assistants API. The same policy engine applies to both. Define your tools, wrap them with protect(), and use them with your assistant.
What happens when a function call is blocked?
The agent receives a configurable response you define. You can return an error message, a fallback value, or a suggestion for an alternative action. All blocked calls are logged with full context for debugging and audit.

Learn more

Secure your OpenAI agents in minutes.