redact_gateway/lib.rs
1// Copyright 2026 Censgate LLC.
2// Licensed under the Apache License, Version 2.0. See the LICENSE file
3// in the project root for license information.
4
5//! OpenAI-compatible AI privacy gateway that embeds `redact-core` in-process.
6//!
7//! The gateway sits between an application and a model provider. On the way
8//! out it detects sensitive values and applies the action a policy profile
9//! specifies for each entity type: allow, block, mask, replace, hash, or
10//! tokenize. On the way back it can restore tokenized values so the caller
11//! sees a complete answer while the provider only ever saw placeholders.
12//!
13//! ```no_run
14//! use redact_gateway::{config::ResolvedConfig, GatewayServer};
15//!
16//! # async fn run() -> anyhow::Result<()> {
17//! let config = ResolvedConfig::load()?;
18//! GatewayServer::new(config).await?.run().await
19//! # }
20//! ```
21//!
22//! # Subsystems
23//!
24//! | Module | Responsibility |
25//! |--------|----------------|
26//! | [`config`] | Resolved configuration from files, environment and flags |
27//! | [`policy`] | Per-entity actions and profiles |
28//! | [`packs`] | Pattern packs loaded from YAML at runtime |
29//! | [`redact`] | Detection, action application, tokens and payload traversal |
30//! | [`vault`] | Pluggable token map backends |
31//! | [`auth`] | Inbound API key and OIDC authentication |
32//! | [`telemetry`] | OpenTelemetry traces, metrics and logs |
33//! | [`audit`] | Audit records emitted as OpenTelemetry log records |
34
35pub mod audit;
36pub mod auth;
37pub mod config;
38pub mod error;
39pub mod openai;
40pub mod packs;
41pub mod policy;
42pub mod proxy;
43pub mod redact;
44pub mod routes;
45pub mod server;
46pub mod stream;
47pub mod telemetry;
48pub mod vault;
49
50pub use config::{ConfigError, ConfigHandle, ResolvedConfig};
51pub use error::GatewayError;
52pub use policy::{EntityAction, PolicySet, Profile};
53pub use server::GatewayServer;