What this covers
Any application or service that calls an LLM provider directly through an official SDK. Because you control the call, the Gateway sits in between as an HTTPS proxy and applies policies on both the request and the response.- Surface: Gateway
- Who is this for: backends and scripts using
openai,anthropic,@google/generative-ai, Azure OpenAI, the Bedrock Runtime SDK, or the Vercel AI SDK.
Architecture
Prerequisites
- A Gateway integration in the TrustGate console. See Gateway surface — Create a Gateway integration.
- At least one Route on that Gateway pointing at the LLM provider you want to protect.
- A Gateway API key issued by that Gateway integration.
https://<gateway>.neuraltrust.ai.
Wire it up
Point the SDK’sbase_url / baseURL at your Gateway and use the Gateway API key as the SDK’s API key. The provider’s native API key stays configured on the Route, not on the client.
OpenAI (Python)
OpenAI (TypeScript)
Anthropic (Python)
Azure OpenAI
Use an Azure OpenAI route on the Gateway and point the Azure SDK at it:AWS Bedrock Runtime
For direct model invocation (not Bedrock Agents), use a Bedrock route and swap the endpoint:Vercel AI SDK
Verify
- Send a test request from your app.
- Open Runtime → Explorer in the console.
- You should see the request and response, the route that matched, and any detectors that fired.
Policies to turn on first
Start with these on every route, then tune based on what you see in Explorer:- Prompt security — jailbreaks and prompt injection on the input.
- Data protection & masking — PII and secret detection on both sides.
- Content moderation — toxicity and keyword filters on outputs.
- Rate limits — token and request-per-minute limits per consumer.
Limitations
- Streaming: requests using
stream=trueare inspected as a full response once the stream completes.MaskandBlockactions take effect on the final consolidated payload, not per chunk. - Provider-specific payloads: each SDK targets its provider’s native shape. Make sure the Route type matches the SDK (OpenAI-compatible, Anthropic, Bedrock, Azure OpenAI, etc.).
- Conversation context: each call is inspected independently. To link turns in multi-turn conversations, send a stable
conversation_idheader so Explorer can thread them. - Native tool calling: tool-call arguments and outputs are inspected at the LLM boundary. Deeper inspection of downstream tool execution requires separately wrapping those tools with a Gateway or API integration.