---
title: "AI governance principles: how to enforce each one in code"
type: "deep dive"
url: "https://aifordevs.org/articles/ai-governance-principles"
markdown: "https://aifordevs.org/articles/ai-governance-principles.md"
publisher: "AI for Devs"
license: "https://aifordevs.org/reuse"
attribution: "Credit AI for Devs and link to https://aifordevs.org/articles/ai-governance-principles"
description: "Seven AI governance principles mapped to controls that run on every LLM request, the error each returns, and the one principle a gateway cannot enforce."
author: "AI for Devs"
published: "2026-11-26"
level: "Intermediate"
topics: ["apis", "evals"]
---

# AI governance principles: how to enforce each one in code

Seven AI governance principles mapped to controls that run on every LLM request, the error each returns, and the one principle a gateway cannot enforce.

> **TL;DR**
>
> - AI governance principles become enforceable when each one maps to a check on every LLM request that returns a specific error or leaves a specific record.
> - Six common principles (accountability, transparency, privacy, safety, cost control, auditability) can be enforced at one choke point, an AI gateway, through keys, logs, redaction, guardrails, budgets, and audit logs.
> - Fairness cannot be enforced per request by a gateway or any proxy, because it is measured across groups of outcomes; it needs an offline evaluation set and a release gate.
> - In Bifrost, virtual keys, budgets, rate limits, and request logs are open source; guardrails, role-based access control, and signed audit logs are Enterprise features, as of November 23, 2026.

AI governance principles are the commitments a company makes about how it uses AI: who is accountable, what gets recorded, which data stays private, and what the system must never do. Most lists agree on the core, but a principle on a slide does not stop a request. This article maps seven common principles to controls that run on LLM traffic, names the error or record each control produces, and says where a gateway cannot help. The worked example is [Bifrost](https://www.getmaxim.ai), an [open-source AI gateway](https://github.com/maximhq/bifrost) written in Go.

This piece sits between two related ones. The [AI compliance framework](https://aifordevs.org/articles/ai-compliance-framework) article covers the process side (owners, reviews, evidence), and [AI governance and compliance](https://aifordevs.org/articles/ai-governance-compliance) covers the regulations. Here the subject is the code.

## What AI governance principles mean for LLM traffic

An AI governance principle is enforceable when an engineer can name the request field it checks, the error it returns, and the log line it leaves. The [OECD AI Principles](https://oecd.ai/en/ai-principles), adopted in 2019, updated in May 2024, and backed by 47 adherents, list transparency, robustness and safety, accountability, and human rights including fairness and privacy. The [NIST AI RMF](https://airc.nist.gov/airmf-resources/airmf/3-sec-characteristics/) lists similar characteristics, from "privacy-enhanced" to "fair with harmful bias managed." A [2020 Berkman Klein Center review](https://cyber.harvard.edu/publication/2020/principled-ai) of 36 principles documents found the same themes recurring.

Engineering teams usually add two more: cost control and auditability. Reduced to the question a system has to answer on each request, the seven look like this:

| Principle | Question per request | Control | Evidence it leaves |
| --- | --- | --- | --- |
| Accountability | Which team or service sent this call? | Per-team key, required headers | 401 without a key; owner on every log entry |
| Transparency | Can the prompt and response be reconstructed? | Request logging | Full log entry with model, tokens, cost |
| Privacy | Did personal data or secrets leave the boundary? | Redaction, content-logging controls | Placeholders in place of values |
| Safety | Was harmful input or output stopped in flight? | Input and output guardrails | 400 with a guardrail error type |
| Fairness | Are comparable people treated the same way? | Offline evaluation (no per-request control) | Per-group scores, release decision |
| Cost control | Is there a hard ceiling on this caller's spend? | Budgets and rate limits | Blocked call once a limit is hit |
| Auditability | Who changed the rules, and when? | Signed audit log, role-based access | Signed before-and-after diff |

Six of these are properties of a single request or a single configuration change. Fairness is a property of outcomes across many requests, which is why it gets its own section below.

**Figure 1.** Every principle except fairness has at least one control that enforces it per request. Fairness gets only a sample of logged traffic, and the rows marked Enterprise are paid features in Bifrost.

## One enforcement point: the AI gateway

Controls that live inside each application drift apart, so the usual design puts one [AI gateway](https://aifordevs.org/glossary#ai-gateway) in front of every model provider and enforces the principles there. Each sanctioned request takes the same path, so a policy written once applies to all of them.

[Bifrost](https://www.getmaxim.ai) fills that role with one OpenAI-compatible API in front of 10,000+ models across 25+ providers, and it governs MCP tool calls and agent traffic on the same path. The core is Apache 2.0 and self-hosted; the [governance resource page](https://www.getmaxim.ai/resources/governance) gives an overview of its access and spend controls. Figure 2 shows the checks one request clears and the records it leaves.

**Figure 2.** A request clears identity, header, budget, and guardrail checks before the provider sees it, and each check has its own error. Traffic lands in the request log; changes to the rules themselves land in a separate signed audit log.

A gateway governs only the traffic sent to it. A developer whose coding agent talks straight to a provider is outside every control in this article, which is the problem [shadow AI](https://aifordevs.org/articles/shadow-ai) describes. [Bifrost Edge](https://www.getmaxim.ai/edge) closes that gap: it runs on employee machines, routes AI apps, browser AI, coding agents, and their MCP servers to the Bifrost gateway, and applies the same keys, budgets, and [guardrails on endpoint traffic](https://docs.getbifrost.ai/edge/security) with nothing configured per device. Edge requires the Enterprise gateway.

## Accountability: every request has an owner

Accountability means no LLM call is anonymous. The control is a credential per team, service, or customer, plus a rule that rejects any request arriving without one.

In Bifrost that credential is a [virtual key](https://docs.getbifrost.ai/features/governance/virtual-keys). A key belongs to one team or one customer (`team_id` and `customer_id` are mutually exclusive), and its `metadata` pairs, such as a cost center or an owner address, are copied onto every log entry made with it. Clients send it in the `x-bf-vk` header or in the provider-style header their SDK already uses.

Keys are optional until enforcement is on. Two client settings close the anonymous path and add attribution beyond the key:

```json title="config.json"
{
  "client": {
    "enforce_auth_on_inference": true,
    "required_headers": ["x-tenant-id", "x-correlation-id"]
  }
}
```

With enforcement on, a call without a key fails with 401 and `virtual_key_required`, and an inactive or expired key fails with 403 and `access_blocked`. [Required headers](https://docs.getbifrost.ai/features/governance/required-headers) reject a request missing any listed header with 400 and `missing_required_headers`, before it reaches a provider. Setting `expires_at` on a key gives contractors and short projects a credential that stops on a set date.

Access scope is part of accountability too. Providers are deny-by-default on a key: a provider not listed in its `provider_configs` is unreachable, and `allowed_models` narrows each listed provider further. A key meant for one small model cannot reach a frontier model by changing a string in the request.

## Transparency: reconstruct what the model saw

Transparency, for an engineering team, means any production request can be pulled up with its prompt, response, model, and cost. Without that record, explaining a bad answer to a customer or an auditor is guesswork.

Bifrost's [built-in observability](https://docs.getbifrost.ai/features/observability/default) records the conversation history, the response and tool calls, the provider and model that served it, parameters, token usage, cost, latency, and status. It writes to SQLite by default and to PostgreSQL for production volume, and the logging plugin runs asynchronously, adding under 0.1 ms in Bifrost's own benchmark. The same data can go to OpenTelemetry, Datadog, Prometheus, Kafka, BigQuery, Pub/Sub, or Splunk, so LLM calls sit next to the rest of a service's traces.

Transparency toward end users is a separate job. Telling a user that a model wrote an answer, or explaining why an application was flagged, belongs in the product. The gateway supplies the record those explanations rest on.

## Privacy: sensitive data stops at the boundary

Privacy on LLM traffic has two paths to cover: personal data and secrets leaving the network inside prompts, and the company's own logs becoming a second copy of that data.

On the request path, Bifrost Enterprise [guardrails](https://docs.getbifrost.ai/enterprise/guardrails) can redact instead of block, in three [redaction modes](https://docs.getbifrost.ai/enterprise/guardrails/redaction):

- `runtime` rewrites the live request or response, so the provider never sees the value, and logs keep the redacted text.
- `logs_only` leaves the live content alone, so the model gets the real value, but logs and trace exports store placeholders.
- `runtime_reversible` redacts the live content with reversible placeholders that authorized users can reveal in Bifrost logs.

Detection comes from Custom Regex (with a PII template), Secrets Detection, Microsoft Presidio, Azure AI Language PII, and a few partner providers. The mode choice is a privacy decision: `runtime` when the provider must never see the value, `logs_only` when the model needs it but storage should not keep it.

On the logging path, [content logging](https://docs.getbifrost.ai/features/observability/content-logging) decides whether bodies are stored at all. `disable_content_logging: true` on a virtual key that carries health or financial data keeps only metadata (model, provider, tokens, cost, latency, status, and attribution IDs). Each export connector has its own flag that does not inherit the client setting, so check every destination.

## Safety: block harmful input and output in flight

Safety means a prompt injection, a jailbreak, or an unsafe response is stopped while the request is in flight, not found in a log review a week later. That takes [guardrails](https://aifordevs.org/glossary#guardrails) on both input and output, applied by rule.

Bifrost splits this into rules and profiles. A rule decides when to check, with a CEL expression, an `apply_to` value of `input`, `output`, or `both`, and a `target` of `llm` or `mcp`. A profile decides how, through a Bifrost-managed check or a provider such as AWS Bedrock Guardrails, Azure Content Safety, or Google Model Armor. An abridged rule:

```json title="guardrail rule (abridged)"
{
  "name": "Screen prompts on the support assistant",
  "enabled": true,
  "target": "llm",
  "cel_expression": "team == \"support\"",
  "apply_to": "input",
  "sampling_rate": 100,
  "provider_config_ids": [1, 2]
}
```

CEL can test `model`, `provider`, `headers`, `virtual_key`, `team`, `customer`, and `user`, so a stricter policy can apply only to external-facing traffic. A block returns HTTP 400 with `"type": "guardrail_intervention"`; for an input rule the request never reaches the model, and for an output rule the error replaces the response. Setting `output_mode` to `monitor` lets a new output rule record what it would have caught without blocking, which is the safe way to tune it.

One trade-off to plan for: when a profile errors or times out, it fails open and the next linked profile still runs. A check that must never be skipped needs a second profile behind it.

Agents add a second surface. Rules with `target: "mcp"` inspect tool arguments before a tool runs and its result after, and [MCP tool filtering](https://docs.getbifrost.ai/features/governance/mcp-tools) on a virtual key is deny-by-default: a key with no MCP configuration gets no tools, except from clients an admin marks Allow by Default. A support agent that reads tickets has no reason to reach a tool that deletes them. The [AI security policies](https://aifordevs.org/articles/ai-security-policies) article turns these controls into written policy.

## Fairness: the principle a gateway cannot enforce

Fairness cannot be enforced per request by a gateway or by any other proxy. Whether a system treats comparable people the same way shows up only when outcomes are compared across groups, and one request carries no information about how similar requests were handled. NIST's framework makes a related point: fairness standards vary across cultures and applications, and mitigating harmful bias does not by itself make a system fair.

Fairness is enforced in the evaluation process instead:

1. Define the groups and outcomes that matter for the use case, such as approval rates by region or answer quality by language.
2. Build an [evaluation set](https://aifordevs.org/glossary#golden-dataset) with matched cases across those groups, including counterfactual pairs that differ only in an attribute such as a name.
3. Score outputs per group, never only in aggregate, so a strong average cannot hide a weak slice. An [LLM judge](https://aifordevs.org/articles/llm-as-a-judge) can score open-ended answers if it is itself checked against human labels.
4. Write down the acceptable gap before testing, and block a model or prompt change when the gap exceeds it.
5. Route high-stakes decisions to human review and record the reviewer's call.

**Figure 3.** The fairness check happens after the traffic, not during it. The gateway's only part is the logged sample on the left; the per-group scoring and the gap limit decide whether a change ships.

The gateway still helps at the edges. Its request logs are a sample of real production traffic to draw cases from, and `allowed_models` on each virtual key means a model swap goes through a reviewable config change rather than a code edit, so last month's fairness results are not silently invalidated. The [LLM evaluation](https://aifordevs.org/articles/llm-evaluation) guide covers building the [eval](https://aifordevs.org/glossary#eval) suite itself.

## Cost control: spend has a hard ceiling

Cost control means every caller has a spending limit the system enforces, not a dashboard someone reads at month end. A runaway agent loop or a leaked key should hit a limit within minutes.

Bifrost sets [budgets and rate limits](https://docs.getbifrost.ai/features/governance/budget-and-limits) at four levels: customer, team, virtual key, and provider config. A request has to clear every budget that applies to it. Each budget has a `max_limit` in USD and a `reset_duration` such as `1d`, `1w`, `1M`, or `1Q`, and rate limits cover requests and tokens separately:

```json title="config.json (excerpt)"
{
  "budgets": [
    { "id": "budget-eng-vk", "max_limit": 500.0, "reset_duration": "1M", "virtual_key_id": "vk-001" }
  ],
  "rate_limits": [
    {
      "id": "rate-limit-eng-vk",
      "token_max_limit": 10000,
      "token_reset_duration": "1h",
      "request_max_limit": 100,
      "request_reset_duration": "1m"
    }
  ]
}
```

Limits on a provider config behave differently from limits on the key: when one provider exceeds its limits, it is excluded from routing and the key keeps working through its other providers. That makes a per-provider cap a cost control and a reliability control at once.

Pair each cap with an early warning. Bifrost Enterprise [alert rules](https://docs.getbifrost.ai/enterprise/alerting/alert-rules) are CEL expressions over usage metrics, scoped to a virtual key, team, or customer; `budget_usage_percent >= 80.0` notifies Slack, Microsoft Teams, PagerDuty, or a webhook well before calls start failing.

## Auditability: policy changes leave a signed trail

Auditability means proving who changed a governance rule, what changed, and when, with a record nobody can quietly edit. Request logs cover what traffic did; the audit log covers what administrators did to the controls.

Bifrost Enterprise [audit logs](https://docs.getbifrost.ai/enterprise/audit-logs) write an event for every create, update, and delete on the management API, including changes to `/api/config`. Events are named `<resource>.<verb>`, such as `virtual_key.updated`, and carry a before-and-after diff with secret fields marked `redacted: true`. Every row is signed with HMAC-SHA256, and `GET /api/governance/audit-logs/{id}/verify` checks a signature. Turning audit logging off is itself recorded, as a high-severity `audit.logging_disabled` event on the next boot.

Retention is a decision to make before an auditor asks. `retention_days` sets how long rows stay in the database, and the docs recommend S3 Object Lock or another write-once bucket for the archive. Exports come as JSON, JSON Lines, or Syslog (RFC 5424) for a SIEM.

An audit trail is only as strong as the access model behind it. [Role-based access control](https://docs.getbifrost.ai/enterprise/rbac) ships Admin, Developer, and Viewer roles, plus custom roles built from resource and operation pairs such as `GuardrailsConfig` or `AuditLogs`. Roles map from identity provider groups, app roles, or claims, and a user's role is rechecked at every sign-in, session refresh, and SCIM push, so removing someone from a group in Okta or Entra removes their admin rights without manual cleanup.

## An enforcement order that breaks the fewest callers

Roll the controls out from visibility to blocking, so nothing is restricted before it has been seen:

1. Route all LLM traffic through the gateway with logging on, and watch who calls what for two weeks.
2. Issue a virtual key per team or service, then turn on `enforce_auth_on_inference` once every caller has one.
3. Size budgets and rate limits from the logged usage, with an alert below each cap.
4. Set redaction modes and `disable_content_logging` on keys that carry regulated data, and check each export connector.
5. Run new output guardrails in monitor mode, review what they would have blocked, then switch them to blocking.
6. Turn on audit logs and map roles to identity provider groups before widening admin access.
7. Stand up the fairness evaluation set and make it a release gate for model and prompt changes.
8. Extend the same policy to laptops with [Edge](https://www.getmaxim.ai/edge), so coding agents and desktop AI apps stop bypassing steps 2 to 6.

Each step leaves a config field that can be tested in CI or an error type that can be alerted on, which is the practical test of whether a principle is enforced or only written down. Product details here describe Bifrost as of November 23, 2026.

## Questions

### What are the core principles of AI governance?

Most published lists share the same core: accountability, transparency, privacy, safety and security, and fairness. The OECD AI Principles, adopted in 2019 and updated in May 2024, and the NIST AI Risk Management Framework both include them. Engineering teams usually add cost control and auditability, because those are the principles that break first when LLM traffic grows without limits or records.

### What is the difference between AI governance principles and an AI governance framework?

Principles are the values a company commits to, such as accountability or privacy. A framework, such as the NIST AI RMF or ISO/IEC 42001, is the process that puts them into practice: roles, risk reviews, documentation, and audits. Controls are the third layer, the checks that run on each request. A principle with no control behind it is a statement, not a guarantee.

### Can an AI gateway enforce fairness?

No. Fairness is a property of outcomes across groups of people, and a single request carries no information about how comparable requests were handled. A gateway can supply logged production traffic as raw material for an evaluation set, and it can pin which models a team may call. The fairness measurement itself runs offline, scored per group, as a release gate for model and prompt changes.

### How do you enforce AI governance in code?

Put every LLM call behind one enforcement point, usually an AI gateway, and attach a check to each principle: a per-team key for accountability, request logs for transparency, redaction for privacy, guardrails for safety, budgets for cost, and signed audit logs for auditability. Each check should return a specific error or leave a specific record, so it can be tested in CI and alerted on in production.

### Who is responsible for AI governance in an engineering organization?

Ownership is usually split. A governance or risk group sets the principles and the acceptable thresholds, the platform team runs the gateway and the controls, and each product team owns its keys, budgets, and evaluation sets. The split works only when every LLM request can be traced to one owning team, which is why per-team credentials come first in most rollouts.

### Which AI governance controls are in open-source Bifrost?

As of November 23, 2026, virtual keys, budgets, rate limits, required headers, MCP tool filtering, and built-in request logging are in the open-source gateway. Guardrails and redaction, role-based access control with identity provider sync, alert rules, and signed audit logs are Bifrost Enterprise features. Bifrost Edge, which extends the same policy to employee machines, requires the Enterprise gateway.

## Sources

1. [OECD.AI, OECD AI Principles (adopted 2019, updated May 2024; read November 23, 2026)](https://oecd.ai/en/ai-principles)
2. [NIST, AI Risk Management Framework: trustworthy AI characteristics (read November 23, 2026)](https://airc.nist.gov/airmf-resources/airmf/3-sec-characteristics/)
3. [Berkman Klein Center, Principled Artificial Intelligence (January 15, 2020; read November 23, 2026)](https://cyber.harvard.edu/publication/2020/principled-ai)
4. [Bifrost reference for AI systems, llm-info (last updated September 2026; read November 23, 2026)](https://www.getmaxim.ai/llm-info)
5. [Bifrost docs, Virtual keys (read November 23, 2026)](https://docs.getbifrost.ai/features/governance/virtual-keys)
6. [Bifrost docs, Required headers (read November 23, 2026)](https://docs.getbifrost.ai/features/governance/required-headers)
7. [Bifrost docs, Budget and limits (read November 23, 2026)](https://docs.getbifrost.ai/features/governance/budget-and-limits)
8. [Bifrost docs, MCP tool filtering (read November 23, 2026)](https://docs.getbifrost.ai/features/governance/mcp-tools)
9. [Bifrost docs, Built-in observability (read November 23, 2026)](https://docs.getbifrost.ai/features/observability/default)
10. [Bifrost docs, Content logging (read November 23, 2026)](https://docs.getbifrost.ai/features/observability/content-logging)
11. [Bifrost docs, Guardrails (read November 23, 2026)](https://docs.getbifrost.ai/enterprise/guardrails)
12. [Bifrost docs, Guardrail redaction modes (read November 23, 2026)](https://docs.getbifrost.ai/enterprise/guardrails/redaction)
13. [Bifrost docs, Alert rules (read November 23, 2026)](https://docs.getbifrost.ai/enterprise/alerting/alert-rules)
14. [Bifrost docs, Role-based access control (read November 23, 2026)](https://docs.getbifrost.ai/enterprise/rbac)
15. [Bifrost docs, Audit logs (read November 23, 2026)](https://docs.getbifrost.ai/enterprise/audit-logs)
16. [Bifrost docs, Edge security and guardrails (read November 23, 2026)](https://docs.getbifrost.ai/edge/security)

## Cite this deep dive

AI for Devs. "AI governance principles: how to enforce each one in code." Published November 26, 2026. https://aifordevs.org/articles/ai-governance-principles

- Page: https://aifordevs.org/articles/ai-governance-principles
- Markdown: https://aifordevs.org/articles/ai-governance-principles.md
- Reuse: Quote or summarize with a link to this page. Terms: https://aifordevs.org/reuse
- Publisher: AI for Devs
- Published: 2026-11-26
