All articles
securitytutorial2026-02-098 min read

How to Secure AI Agent API Calls with a Policy Gateway

AI agents make HTTP calls on your behalf. Without a policy layer, a single misconfigured agent can delete production data, leak secrets, or rack up API bills. Here's how to add a security boundary.

The problem

AI agents are increasingly autonomous. They create GitHub issues, merge pull requests, send emails, and initiate payments — all without human intervention. But most agent frameworks have zero built-in security.

When your LangChain agent calls the GitHub API, nothing stops it from deleting the main branch. When your CrewAI workflow sends an email, nothing prevents it from emailing external recipients with sensitive data.

What a policy gateway does

A policy gateway sits between your agent and the APIs it calls. Every outbound HTTP request passes through the gateway, which:

  1. Identifies the action — parses the HTTP request into a structured action (e.g., github.branch.delete)
  2. Evaluates policies — checks the action against your rules (allow, deny, or require approval)
  3. Enforces the decision — blocks denied requests, holds approval-required requests, and forwards allowed requests
  4. Logs everything — creates an immutable audit trail of every action

How TameFlare implements this

TameFlare is a transparent HTTP/HTTPS proxy. You wrap your agent process with tf run, and all outbound traffic is routed through the proxy. No code changes required.

# Before: agent runs with full access
python my_agent.py

# After: agent runs through TameFlare proxy
npx tf run -- python my_agent.py

The proxy uses connectors to parse HTTP requests into structured actions. Built-in connectors support GitHub (20+ action types), OpenAI/Anthropic, Stripe, Slack, and any generic HTTP API.

Setting up policies

Policies are configured in the TameFlare dashboard. Each policy has:

  • Scope — which action types it applies to
  • Rules — conditions that must match (field, operator, value)
  • Decision — allow, deny, or require approval
  • Reason — human-readable explanation shown to the agent
  • For example, to block branch deletion:

    1. Open the TameFlare dashboard
    2. Click Policy builder
    3. Set scope to github.branch.delete
    4. Add a rule: field type equals github.branch.deleteDeny
    5. Set reason: "Branch deletion is not allowed"

    Credential isolation

    A key security benefit: your agent never sees real API keys. The proxy injects credentials into allowed requests at request time from an AES-256-GCM encrypted vault. Even if your agent is compromised, the attacker cannot extract API keys.

    Next steps

  • Install TameFlare — free tier, 3 gateways, 1,000 actions/month
  • Read the docs — full setup guide and policy reference
  • View on GitHub — source-available under ELv2
  • How to Secure AI Agent API Calls with a Policy Gateway | TameFlare