Repository navigation
feat: add ai-neuraltrust-guard plugin - #14309
Draft
alespignaNT wants to merge 1 commit into
Draft
alespignaNT wants to merge 1 commit into
alespignaNT wants to merge 1 commit into
Conversation
Signed-off-by: Alessandro Pignati <alessandro.pignati@neuraltrust.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds
ai-neuraltrust-guard, a new AI security plugin that integratesNeuralTrust TrustGuard with the APISIX AI gateway,
as proposed in #14308. It follows the design of
ai-lakera-guard(#13570) andbuilds on the
ai-protocolslayer.Changes
apisix/plugins/ai-neuraltrust-guard.lua,ai-neuraltrust-guard/schema.lua,ai-neuraltrust-guard/client.lua: plugin, schema and TrustGuard HTTP client.access: extracts messages withproto.get_messages()(keepingsystem/user/assistant roles) and calls
POST /v1/evaluate.lua_body_filter(direction: output|both): evaluates the LLM response,including streaming, with the same buffering state machine as
ai-lakera-guard.proto.build_deny_response(), so they match theclient's protocol (OpenAI chat, Responses, Anthropic, Bedrock).
api_keyis inencrypt_fieldsand supports$secret:///$env://.1027.apisix/cli/config.lua,conf/config.yaml.example,Makefile,t/admin/plugins.tanddocs/en/latest/config.json.t/plugin/ai-neuraltrust-guard{,-output,-chain,-secrets}.t(81 cases)against a local mock (
t/lib/neuraltrust_mock.lua) built from real API responses,so CI needs no credentials or external calls.
docs/en/latest/plugins/ai-neuraltrust-guard.md.t/e2e/ai-neuraltrust-guard/run-e2e.shruns APISIX in Dockeragainst the real TrustGuard API with
NEURALTRUST_API_KEY(not used in CI).Disclosure: I work at NeuralTrust. I validated this end to end against the
production TrustGuard API on APISIX 3.21 (benign prompt allowed, jailbreak blocked).
Payload transformation (redaction/DLP) and MCP tool-call inspection are out of
scope and could follow in separate PRs. Happy to split this PR (input first,
then output/streaming) if maintainers prefer.
Which issue(s) this PR fixes:
Fixes #14308
Checklist