Documentation Index
Fetch the complete documentation index at: https://docs.neuraltrust.ai/llms.txt
Use this file to discover all available pages before exploring further.
What this covers
LangChain applications and LangGraph workflows that call LLM providers throughChatOpenAI, ChatAnthropic, ChatGoogleGenerativeAI, AzureChatOpenAI, or ChatBedrock. TrustGate inspects each LLM hop independently — not the LangChain orchestration itself — so policies apply to every model call the chain or graph makes.
- Surface: Gateway
- Who is this for: Python (
langchain,langgraph) and TypeScript (@langchain/core,@langchain/langgraph) stacks.
Architecture
llm.invoke(...) becomes a discrete request in the Gateway, with its own route match and detector decisions.
Step-by-step setup
Every upstream provider your chain or graph touches is registered once as an Integration; the Gateway then exposes each one on its own Route. Your chain code never sees the provider’s native API key — only the TrustGate Gateway key.Register each provider as an Integration
Open Integrations → Add Integration and register every provider your chain calls — OpenAI, Anthropic, Azure OpenAI, Google, Bedrock, Mistral, etc. Enter the provider’s credentials on the Integration form. Give each one a name you’ll recognize (e.g.
openai-prod, anthropic-prod).Create a Gateway Integration
Integrations → Add Integration → Gateway. Pick Serverless or Dedicated, name it (e.g.
chains-prod), save, and note the Endpoint from Gateway → Overview.Default Routes for every provider Integration from Step 1 are created automatically — one for OpenAI (/v1/chat/completions), one for Anthropic (/v1/messages), one for Bedrock, and so on. Under Gateway → Routes you can add Tags (for example rag, retrieval) so you can later author tighter policies for retrieval-heavy hops without creating routes manually.Issue a Gateway API key
On the Gateway Integration’s API Keys tab, create a key. One key covers all Routes on that Gateway — chains with mixed providers use a single TrustGate key.
Point every model client at the Gateway
Swap
base_url / baseURL and api_key / apiKey on each LangChain model client. Prompts, tools, agent graphs, and runnables stay unchanged. Snippets below.Client code
LangChain (Python)
LangChain (TypeScript)
LangGraph
LangGraph nodes use the same LangChain model clients. Configure them once and pass them into your graph as usual:Tools and agents
For tool-calling agents (create_react_agent, AgentExecutor, LangGraph prebuilt agents), the LLM hop is protected by the Gateway. To also protect tool execution — for example, a tool that calls an internal HTTP API — wrap that tool’s endpoint with a separate Gateway route or an API integration.
Correlate hops into one conversation
To group hops into a single conversation in Explorer, forward a stableconversation_id header on every model client:
Policies to apply
Chains and graphs amplify whatever content flows into a model call — a single poisoned RAG document reaches every downstream hop. Because TrustGate inspects each LLM call independently, you get one policy decision per hop, and policies composed across hops stack using theblock ▶ mask ▶ log precedence described in Policies & Enforcement.
Scope policies with the Gateways or Routes filter so RAG-heavy chains and customer-facing chains can have different rules.
Block prompt injection — including indirect injection from RAG
- Where —
Gateway+ filterGateways = <your-gateway> - When —
Input·Triggers·Prompt Injection, Jailbreak - Then —
Block
Mask PII across every chain step
- Where —
Gateway+ filterGateways = <your-gateway> - When —
Input or Output·Triggers·Email Address, Phone Number, Credit Card, Social Security Number - Then —
Mask
Block credential leakage in outputs
- Where —
Gateway+ filterGateways = <your-gateway> - When —
Output·Triggers·API Key / Secret - Then —
Block
Tool-call guard for agents
- Where —
Gateway+ filterRoutes = <agent-routes> - When —
Tool Call·Triggers·Suspicious Arguments, Prompt Injection - Then —
Block
Log RAG context for audit
- Where —
Gateway+ filterRoutes = <rag-routes> - When — empty (every request in scope)
- Then —
Log
Log mode first, these five patterns give you an end-to-end view of every hop before you flip the switch to Mask or Block.
Limitations
- Per-hop inspection: detectors run on each LLM call independently. Multi-turn context is inferred from the messages you pass in; use a conversation header to correlate.
- Streaming: streamed responses are inspected once the stream completes;
MaskandBlockapply to the final consolidated payload. - Tool execution: LangChain tool calls that hit external APIs are not automatically covered. Wrap those endpoints with their own Gateway or API integration if they handle sensitive data.
- Custom runnables: anything that bypasses the standard chat models (direct
httpxcalls, custom providers) will not be inspected unless it also uses the Gateway base URL.