Default WorkspaceGuides
429 fallback, coding agents & gateway comparisons

Use SentioGate with Langfuse: Trace Export and the OpenAI Wrapper

· Published · Facts and limits are dated; check the linked sources.

Langfuse is an LLM observability and tracing platform. There are two ways to get your SentioGate requests into it, and you can use either or both:

  1. SentioGate's Langfuse export. Turn it on in the dashboard and SentioGate sends a trace for each chat request to your own Langfuse project. No code changes.
  2. Langfuse's OpenAI SDK wrapper. Wrap the OpenAI client in your app and point it at SentioGate. Your app sends the traces, so they can sit inside your own spans and traces.

As of 2026-10-30, checked against Langfuse's OpenAI Python and OpenAI JS/TS integration docs.

Option 1: the built-in Langfuse export

Set it up

  1. In Langfuse, open your project's settings and create an API key pair. You get a public key (pk-lf-...) and a secret key (sk-lf-...).
  2. In SentioGate, open the Vault and find Langfuse export.
  3. Pick your Langfuse region (EU, US, JP or HIPAA cloud) or enter the https URL of your self-hosted Langfuse.
  4. Paste both keys and click Save and turn on.
  5. Click Test connection to check that Langfuse accepts the keys.

Send a request through SentioGate and it shows up in Langfuse as a generation named sentiogate.chat.

What is sent

By default, only metadata is sent, with no prompt or answer text:

  • the model and provider that answered;
  • token usage and cost, when known;
  • latency, and time to first token for streamed responses;
  • status (ok or error) and the HTTP status code;
  • your session id, if you sent one (see below).

Turn on Include prompts and answers if you also want the request messages and the answer text in Langfuse. It is off by default. Content is sent only to your own Langfuse project and SentioGate does not keep a copy of the export.

Your Langfuse secret key is stored encrypted, and the dashboard and API never show it again after you save it. You can turn the export off, or remove the keys, at any time.

Sessions

Send the same X-Session-ID header (or a session_id field in the request body) on every request of a conversation or agent run, and Langfuse groups those traces into one session:

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.sentiogate.dev/v1",
    api_key=os.environ["SENTIOGATE_API_KEY"],
    default_headers={"X-Session-ID": "support-ticket-1234"},
)

resp = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Draft a short reply to this ticket."}],
)
print(resp.choices[0].message.content)

Good to know

  • The export runs after your response is sent. If Langfuse is slow or down, your requests are not affected; that trace is simply not recorded.
  • It covers chat completion requests (/v1/chat/completions) made with your SentioGate API keys.

Option 2: the Langfuse OpenAI wrapper

If you already use Langfuse in your app, its drop-in OpenAI wrapper works with SentioGate. Point it at SentioGate's base URL and give it your SentioGate key.

Python

pip install langfuse openai
export LANGFUSE_PUBLIC_KEY="pk-lf-..."
export LANGFUSE_SECRET_KEY="sk-lf-..."
export LANGFUSE_BASE_URL="https://cloud.langfuse.com"  # or your region / self-hosted URL
export SENTIOGATE_API_KEY="sg_live_..."
import os
from langfuse import get_client
from langfuse.openai import OpenAI

client = OpenAI(
    base_url="https://api.sentiogate.dev/v1",
    api_key=os.environ["SENTIOGATE_API_KEY"],
)

resp = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Give me three names for a coffee shop."}],
    metadata={"langfuse_session_id": "session_123"},
)
print(resp.choices[0].message.content)

get_client().flush()  # in short-lived scripts, send queued traces before exit

JavaScript and TypeScript

The JS wrapper sends traces through OpenTelemetry, so register the Langfuse span processor once at startup:

npm install @langfuse/openai @langfuse/otel @opentelemetry/sdk-node openai
import { NodeSDK } from "@opentelemetry/sdk-node";
import { LangfuseSpanProcessor } from "@langfuse/otel";
import OpenAI from "openai";
import { observeOpenAI } from "@langfuse/openai";

// Reads LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY and LANGFUSE_BASE_URL from the environment.
const sdk = new NodeSDK({ spanProcessors: [new LangfuseSpanProcessor()] });
sdk.start();

const openai = observeOpenAI(
  new OpenAI({
    baseURL: "https://api.sentiogate.dev/v1",
    apiKey: process.env.SENTIOGATE_API_KEY,
  }),
  { sessionId: "session_123" },
);

const res = await openai.chat.completions.create({
  model: "auto",
  messages: [{ role: "user", content: "Give me three names for a coffee shop." }],
});
console.log(res.choices[0].message.content);

With the wrapper, the model shown in Langfuse is the one you asked for (for example auto). With the built-in export it is the model that answered.

Which one to use

Built-in exportOpenAI wrapper
Code changesNoneWrap the client
Model shownThe model that answeredThe model you asked for
Prompts and answersOff by default; one toggleAlways sent by the wrapper
Nest inside your own tracesNo, one trace per requestYes
Works for every app using your keyYesOnly apps you instrument

If you use both, each request appears twice in Langfuse, once from each source.

Troubleshooting

  • Test connection fails with "Langfuse rejected these keys": the keys belong to another region or project. Check the host matches where the project lives.
  • No traces appear: make sure Export traces to Langfuse is on, and that you are calling SentioGate with an API key from the same account.
  • Self-hosted Langfuse: the URL must use https and be reachable from the public internet.

Sources

All accessed 2026-10-30.