MCPcopy Index your code
hub / github.com/CassiopeiaCode/TransformVetter

github.com/CassiopeiaCode/TransformVetter @v1.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.1 ↗ · + Follow
1,183 symbols 3,192 edges 40 files 4 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

TransformVetter

AI API gateway for protocol translation, inline moderation, streaming parity, and local moderation training.

Tests GHCR workflow GHCR image Release binaries Repository License

Rust 2021 Rust toolchain Linux amd64 Axum TLS Protocols SSE Moderation Training Coverage focus

TransformVetter transforms AI API requests and responses across OpenAI, Claude, and Gemini-compatible formats, then vets request content with keyword rules, smart moderation, local models, and optional LLM review before forwarding upstream.

Note: TransformVetter was previously published as PrismGuard and, earlier, GuardianBraidge.

It is built for production proxy work, not only raw forwarding. The codebase keeps protocol behavior explicit across HTTP routing, request format detection, JSON response conversion, SSE event conversion, moderation error envelopes, history reuse, and training scheduling.

Use it when you need one front door for mixed LLM clients, but still want request moderation before traffic reaches the upstream provider.

Contents

Why TransformVetter

Most LLM proxy setups solve either API compatibility or moderation. TransformVetter does both in the same request path:

Need What TransformVetter does
Mixed client protocols Accepts OpenAI, Claude, Gemini, and OpenAI Responses-style traffic.
Upstream format conversion Rewrites supported requests and responses into the target API shape.
Streaming behavior Preserves SSE-style streaming while translating deltas and terminal events.
Inline safety checks Runs keyword moderation, profile-based smart moderation, and optional LLM review before forwarding.
Local review models Uses profile-selected local runtimes for confident decisions and falls back when uncertain.
Training feedback loop Stores moderation history and can retrain profile-local models from collected samples.

Highlights

  • Protocol bridge: OpenAI Chat Completions, OpenAI Responses, Claude Messages, and Gemini GenerateContent request families.
  • Streaming parity: SSE decoding and re-emission with text deltas, tool-call deltas, final events, usage metadata, and single [DONE] handling.
  • Inline moderation: keyword moderation plus smart moderation with cache/history reuse, local model decisions, LLM fallback, retry logic, and concurrency limiting.
  • Local runtimes: hashlinear, bow, and fasttext moderation paths selected per profile.
  • Training loop: profile-aware sample RPC, training subprocess mode, cooldown decisions, and scheduler support.
  • Debug surface: health, OpenAPI stub, URL config parsing, profile inspection, model metrics, and storage inspection routes.

Fit

TransformVetter is a good fit if you:

  • route multiple AI client formats through one service;
  • need moderation before an upstream LLM API receives the request;
  • care about stream-compatible protocol conversion, not only non-stream JSON;
  • want profile-specific moderation behavior and locally trained review models;
  • prefer explicit proxy configuration over hidden global routing rules.

It is not designed to be a full API management platform with billing, tenant dashboards, or hosted policy authoring UI.

Install

Fastest Path

Use the published container image when you only want to try the proxy:

docker run --rm -p 8000:8000 --env-file .env ghcr.io/cassiopeiacode/transformvetter:latest
curl -s http://127.0.0.1:8000/healthz

Use the release binary when you want a single executable:

gh release download --repo CassiopeiaCode/TransformVetter v1.0.0 --pattern 'TransformVetter-linux-amd64.tar.gz'
tar -xzf TransformVetter-linux-amd64.tar.gz
chmod +x TransformVetter-linux-amd64
./TransformVetter-linux-amd64

Container Image from GHCR

The default image is published to GitHub Container Registry:

docker pull ghcr.io/cassiopeiacode/transformvetter:latest
docker run --rm -p 8000:8000 --env-file .env ghcr.io/cassiopeiacode/transformvetter:latest

Common tags:

Tag Meaning
latest Latest successful build from the default branch.
master Latest successful build from master.
sha-<commit> Immutable image for a specific commit.
<version> Release image from a v* Git tag, for example 1.2.3.

Package page:

https://github.com/CassiopeiaCode/TransformVetter/pkgs/container/transformvetter

Precompiled Binary from GitHub Releases

Tagged releases publish a Linux amd64 binary and checksum:

gh release download --repo CassiopeiaCode/TransformVetter --pattern 'TransformVetter-linux-amd64.tar.gz'
gh release download --repo CassiopeiaCode/TransformVetter --pattern 'TransformVetter-linux-amd64.tar.gz.sha256'
sha256sum -c TransformVetter-linux-amd64.tar.gz.sha256
tar -xzf TransformVetter-linux-amd64.tar.gz
chmod +x TransformVetter-linux-amd64
./TransformVetter-linux-amd64

Release page:

https://github.com/CassiopeiaCode/TransformVetter/releases

Build from Source

git clone https://github.com/CassiopeiaCode/TransformVetter.git
cd TransformVetter
cargo build --release
./target/release/TransformVetter

How It Works

flowchart LR
    Client[Client request] --> Route[Axum route]
    Route --> Config[URL or env proxy config]
    Config --> Format[format.rs request plan]
    Format --> Extract[moderation text extraction]
    Extract --> Basic[basic moderation]
    Basic --> Smart[smart moderation]
    Smart --> Upstream[Upstream LLM API]
    Upstream --> Response[JSON response transform]
    Upstream --> Stream[SSE stream transcoder]
    Response --> Client
    Stream --> Client

    Smart --> History[(history.rocks)]
    History --> Train[train-profile subprocess]
    Train --> Model[local model artifacts]
    Model --> Smart

Request flow:

  1. The catch-all proxy route receives a request whose path contains {config}${upstream} or !ENV_KEY${upstream}.
  2. src/routes.rs parses the proxy configuration and real upstream URL.
  3. src/format.rs optionally detects and transforms the request into a target API format.
  4. src/moderation/extract.rs derives the text that should be reviewed.
  5. basic_moderation can block immediately from keywords.
  6. smart_moderation can reuse history, run a local model, or call an LLM reviewer.
  7. src/proxy.rs forwards the request to the upstream API only after moderation passes.
  8. src/response.rs transforms non-stream JSON responses when needed.
  9. src/streaming.rs transcodes SSE streams when the source and target protocols differ.

Supported Protocols

format_transform supports these request format names:

Format name API family
openai_chat OpenAI-compatible Chat Completions
openai_responses OpenAI-compatible Responses API
claude_chat Anthropic Claude Messages
gemini_chat Gemini GenerateContent

The transformation layer handles normal messages, system/instruction fields, multimodal content blocks, tool declarations, tool calls, tool results, stream flags, and path rewrites for target APIs. The response layer includes both JSON conversion and SSE conversion paths, with the broadest coverage in the HTTP proxy and stream tests.

Quick Start

Requirements

  • Linux or another Unix-like environment.
  • Rust toolchain compatible with edition 2021. The Dockerfile currently installs Rust 1.89.0.
  • clang and libclang when building dependencies that need native compilation.
  • Optional: systemd-run and CPU affinity tools for the scheduler-style workflows.

Run Locally

cd TransformVetter
cargo run

By default the service reads .env from the repository root, listens on 0.0.0.0:8000, and exposes:

curl -s http://127.0.0.1:8000/healthz

Expected shape:

{
  "ok": true,
  "service": "TransformVetter",
  "host": "0.0.0.0",
  "port": 8000,
  "debug": true
}

Build a Release Binary

cargo build --release
./target/release/TransformVetter

The bundled start.sh expects a .env file and a release binary:

nice -n 19 cargo build --release -j 1
./start.sh

Docker Build

docker build -t transformvetter .
docker run --rm -p 8080:8080 transformvetter

The Docker image builds the default feature set. Storage debug routes and sample RPC service code require the explicit storage-debug feature, described below.

Publishing

The repository uses two publishing workflows.

.github/workflows/ghcr.yml publishes the container image. On every push to master, it builds and pushes:

  • ghcr.io/cassiopeiacode/transformvetter:latest
  • ghcr.io/cassiopeiacode/transformvetter:master
  • ghcr.io/cassiopeiacode/transformvetter:sha-<commit>

On v* tags, the same workflow also publishes semver image tags such as :1.2.3, :1.2, and :1.

.github/workflows/release.yml publishes GitHub Releases. On v* tags, it builds a Linux amd64 binary, creates or updates the release, and attaches:

  • TransformVetter-linux-amd64
  • TransformVetter-linux-amd64.tar.gz
  • TransformVetter-linux-amd64.tar.gz.sha256

Manual publishing is available from GitHub Actions:

gh workflow run ghcr.yml --repo CassiopeiaCode/TransformVetter --ref master
gh workflow run release.yml --repo CassiopeiaCode/TransformVetter --ref master -f tag=v1.2.3

Proxy Configuration

TransformVetter does not use a single static upstream route. The proxy route is encoded as:

/{config}${upstream-url}

or, preferably for real deployments:

/!ENV_KEY${upstream-url}

The env form keeps long JSON configs out of client URLs. ENV_KEY must contain JSON.

Example .env entry:

CLAUDE_TO_OPENAI='{"format_transform":{"enabled":true,"strict_parse":true,"from":"claude_chat","to":"openai_chat","delay_stream_header":true},"basic_moderation":{"enabled":true,"keywords_file":"configs/keywords.txt","error_code":"BASIC_MODERATION_BLOCKED"},"smart_moderation":{"enabled":true,"profile":"default"}}'

Example request shape:

curl -sS \
  -H 'content-type: application/json' \
  -H "authorization: Bearer $UPSTREAM_API_KEY" \
  --data '{"model":"claude-3-5-sonnet-latest","max_tokens":64,"messages":[{"role":"user","content":"Hello"}]}' \
  'http://127.0.0.1:8000/!CLAUDE_TO_OPENAI$https://api.openai.com/v1/chat/completions'

You can validate config parsing without calling an upstream:

curl -G http://127.0.0.1:8000/debug/url-config \
  --data-urlencode 'value=!CLAUDE_TO_OPENAI$https://api.openai.com/v1/chat/completions'

format_transform

{
  "format_transform": {
    "enabled": true,
    "strict_parse": true,
    "from": "claude_chat",
    "to": "openai_chat",
    "delay_stream_header": true
  }
}

Important fields:

Field Meaning
enabled Enables request planning and format conversion.
strict_parse Returns a structured moderation-style error when the source format cannot be detected or is disallowed.
from Source format, array of formats, or auto-style detection when omitted.
`to

Extension points exported contracts — how you extend this code

InternalSink (Interface)
(no doc) [4 implementers]
src/streaming.rs

Core symbols most depended-on inside this repo

ok
called by 38
src/sample_rpc.rs
process_request
called by 37
tests/format_runtime.rs
as_str
called by 34
src/format.rs
with_code
called by 32
src/routes.rs
encode_rocksdict_string
called by 27
src/storage.rs
history_rocks_path
called by 20
src/profile.rs
get_u64
called by 18
src/storage.rs
encode_json_sse_with_event
called by 17
src/streaming.rs

Shape

Function 948
Method 126
Class 94
Enum 14
Interface 1

Languages

Rust89%
Python11%

Modules by API surface

tests/http_proxy_request_tests.rs122 symbols
src/profile.rs77 symbols
src/format.rs71 symbols
tests/http_proxy_stream_tests.rs68 symbols
tests/format_runtime.rs63 symbols
tests/http_proxy_response_tests.rs55 symbols
src/proxy.rs53 symbols
tests/training_tests.rs49 symbols
src/routes.rs49 symbols
src/moderation/smart.rs49 symbols
src/streaming.rs48 symbols
src/storage.rs46 symbols

For agents

$ claude mcp add TransformVetter \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact