Integration capabilities
Before you start
Set the credentials
TRUSTGATE_URL to the MCP host that data plane is published on: the
NeuralTrust cloud does not serve that gateway.In Python, you can check the Langfuse credentials before sending anything:Create the traced client
Build the OpenAI client from the values the TrustGate SDK resolves, and let
Langfuse wrap it.The SDK wraps nothing: it hands the base URL and key to OpenAI’s own client, so
Langfuse’s integration sees a standard OpenAI client.
Send a call
model depends on how the application routes: "auto" when it
load-balances, otherwise a model name. See
What goes in model.Langfuse sends traces in the background. Flush before a short-lived process
exits, or its last traces are lost.Attribute calls to a user and a session
The application key identifies the application, not the person using it, so
neither tool knows the user until your code names one. Send the same id to
both, so a person has the same identity in each: Langfuse reads it from the
call’s metadata, and TrustGate from the
X-NeuralTrust-End-User header. For
TrustGate the header is attribution only: it lands on the trace and in
Activity, and grants nothing.What each tool sees
Langfuse traces in the client, TrustGate in the request path, so each sees the call from its own side.
Because Langfuse records the prompt before TrustGate sees it, sensitive data
that TrustGuard redacts still reaches Langfuse. If that data must not leave your
process, mask it in Langfuse’s client as well.
For a streamed call, pass
stream_options={"include_usage": True} to get token
usage. The usage arrives in a final chunk with an empty choices list, so check
chunk.choices before indexing it.