# How Bridle works

One line of config. Everything your agents do, on a leash. Bridle is a gateway that sits between your agents and their model providers. You change a base URL. We meter, cap, log, and when needed, stop them.

## The integration is a base URL swap

Your agent already calls OpenAI, Anthropic, or Gemini. Point that client at the gateway and add your Bridle key. Your provider key stays in its usual header; it passes through and is never stored.

```python
# before
client = OpenAI()

# after
client = OpenAI(
  base_url="https://api.agentbridle.com/gateway/openai/v1",
  default_headers={
    "X-Bridle-Key": "bk_...",
    "X-Bridle-Run-Id": "nightly-invoices-042",
  },
)
# same for Anthropic (/gateway/anthropic) and Gemini (/gateway/gemini)
```

## What happens on every call

1. Identify: the Bridle key maps the call to a named agent and a run.
2. Check: is the agent active, is the run under budget. If not, the call never leaves the building.
3. Forward: the request goes to the provider unchanged, streaming included, with single digit milliseconds of overhead.
4. Meter: token counts are priced against the model's real rates and added to the run, live.

## Budgets that actually stop things

Every agent gets a dollar cap per run. When a run crosses it, the run is killed and further calls get HTTP 402 with error "run_terminated". Your agent finds out immediately, in code, mid job.

## Approvals and the audit trail

For risky actions the agent asks first: one API call raises an approval request, the run holds, and a person approves or denies it from the dashboard, with a Slack ping. Every call, decision, and decider is logged against the agent identity and exportable.

## Common questions

- Latency: edge proxy, no buffering, streaming passes straight through.
- Provider keys: transit the proxy in headers, never written to disk or logs.
- Runs: pass a run id header for per job budgets; without it each call is its own run.
- Providers: OpenAI, Anthropic, and Gemini, current model lineups included. Unknown models are billed at a conservative rate.

Join the beta: https://agentbridle.com/#waitlist
