Trace RedPill API calls with Langfuse and an explicit data boundary.
Langfuse can trace RedPill calls through its OpenAI SDK wrapper. It records latency, usage, errors,
and, by default, model inputs and outputs.
Langfuse is a separate observability destination. Traced prompts and responses leave RedPill’s
trust boundary and are subject to your Langfuse deployment, retention, and access controls.
Import OpenAI from langfuse.openai, then configure RedPill as the API endpoint:
import osfrom langfuse import get_clientfrom langfuse.openai import OpenAIclient = OpenAI( api_key=os.environ["REDPILL_AI_API_KEY"], base_url="https://api.redpill.ai/v1",)response = client.chat.completions.create( model="z-ai/glm-5.3", messages=[{"role": "user", "content": "Reply with: connected"}], name="redpill_connection_check",)print(response.choices[0].message.content)# Flush explicitly in short-lived jobs and scripts.get_client().flush()
The wrapper accepts the same streaming and async calls as the OpenAI SDK. Add trace names,
session identifiers, and low-sensitivity metadata only when they are useful for debugging or
aggregation.
Classify prompts, responses, tool arguments, retrieved documents, and metadata.
Configure Langfuse masking before those values leave the application, or omit content entirely.
Set retention and access controls for the Langfuse project.
Use a self-hosted Langfuse deployment when its data must remain inside your own boundary.
Masking changes telemetry only; it does not change the request sent to RedPill. If another
OpenTelemetry exporter is active, configure its redaction separately.
Langfuse cost estimates depend on a matching model definition. RedPill model IDs or prices may need
a custom definition under Project Settings > Models. Treat the RedPill dashboard as the billing
source of truth.Langfuse does not verify RedPill’s signed receipts. Fetch and verify a receipt separately when the
serving path is part of your security decision.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"RedPill AI","colors":{"primary":"#c96442","light":"#d97757","dark":"#b0512f"},"logo":{"light":"https://mintcdn.com/phala-47f19b07/5vRaVvmX8pi5Nukr/logo/light.svg?fit=max\u0026auto=format\u0026n=5vRaVvmX8pi5Nukr\u0026q=85\u0026s=03f8dbe12d0f593a956cccba7b18115f","dark":"https://mintcdn.com/phala-47f19b07/5vRaVvmX8pi5Nukr/logo/dark.svg?fit=max\u0026auto=format\u0026n=5vRaVvmX8pi5Nukr\u0026q=85\u0026s=dd49c6b52615b7312317e2fc353ac289"},"favicon":"https://mintcdn.com/phala-47f19b07/jUpTfTWRxXYc1F5K/favicon.svg?fit=max\u0026auto=format\u0026n=jUpTfTWRxXYc1F5K\u0026q=85\u0026s=1ac7304fa03ccc515bee40d9694e75e2","api":{"mdx":{"auth":{"method":"bearer"},"server":"https://api.redpill.ai/v1"}},"navbar":{"links":[{"href":"https://www.redpill.ai/dashboard","label":"Dashboard"}],"primary":{"type":"button","label":"Start building","href":"https://redpill.ai/start-building"}},"footer":{"socials":{"twitter":"https://twitter.com/redpill_ai","github":"https://github.com/redpill-ai","discord":"https://discord.gg/P2ukR4Z5ps"}},"fonts":{"heading":{"family":"Poppins","weight":600},"body":{"family":"Inter","weight":400}},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"metadata":{"timestamp":false},"styling":{"latex":false},"navigation":{"global":{"anchors":[{"anchor":"Community","icon":"discord","href":"https://discord.gg/P2ukR4Z5ps"},{"anchor":"GitHub","icon":"github","href":"https://github.com/redpill-ai"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"phala-47f19b07","hasAudioNarration":false,"actualSubdomain":"phala-47f19b07","customDomains":["docs.redpill.ai"],"gitSource":{"type":"github","owner":"redpill-ai","repo":"redpill-docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6aeadca45adfacbbaf537b77","collectionId":"9eb481cb-d39b-4c33-96ba-258251700e65","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6aeadca45adfacbbaf537b77"},"feedback":{"thumbs":true,"agentFeedback":true},"entitlements":{},"buildId":"6aeaec39197840cd827e97ba","clientVersion":"0.0.4054","searchFilterCounts":[{"language":"default","tag":"Documentation","count":49},{"language":"default","tag":"API Reference","count":11},{"language":"default","tag":"Use in agents","count":9},{"language":"default","tag":"Endpoints","count":8},{"language":"default","tag":"Build with the API","count":8},{"language":"default","tag":"Get started","count":7},{"language":"default","tag":"Features","count":7},{"language":"default","tag":"How it works","count":6},{"language":"default","tag":"Verify and control","count":6},{"language":"default","tag":"Providers and trust","count":4}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":true},"customCss":[{"filePath":"styles.css","content":"h1,h2,h3,h4,h5,h6{font-family:\"Poppins\",sans-serif}"}],"page":{"pagePath":"guides/integrations/langfuse","slug":"/guides/integrations/langfuse","pageMetadata":{"title":"Langfuse","description":"Trace RedPill API calls with Langfuse and an explicit data boundary.","href":"/guides/integrations/langfuse"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Trace RedPill API calls with Langfuse and an explicit data boundary.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Langfuse can trace RedPill calls through its OpenAI SDK wrapper. It records latency, usage, errors,\nand, by default, model inputs and outputs.`}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`Langfuse is a separate observability destination. Traced prompts and responses leave RedPill’s\ntrust boundary and are subject to your Langfuse deployment, retention, and access controls.`})}),`\n`,_jsx(Heading,{level:`2`,id:`configure-tracing`,children:`Configure tracing`}),`\n`,_jsx(_components.p,{children:`Install the current Python SDKs and set both services’ credentials:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`pip`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -U`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` langfuse`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` openai`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` REDPILL_AI_API_KEY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"YOUR_API_KEY\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` LANGFUSE_PUBLIC_KEY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"pk-lf-...\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` LANGFUSE_SECRET_KEY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"sk-lf-...\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` LANGFUSE_BASE_URL`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://cloud.langfuse.com\"`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Use your own `,_jsx(_components.code,{children:`LANGFUSE_BASE_URL`}),` for a self-hosted deployment.`]}),`\n`,_jsx(Heading,{level:`2`,id:`trace-a-request`,children:`Trace a request`}),`\n`,_jsxs(_components.p,{children:[`Import `,_jsx(_components.code,{children:`OpenAI`}),` from `,_jsx(_components.code,{children:`langfuse.openai`}),`, then configure RedPill as the API endpoint:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`19`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`19`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` os`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` langfuse `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` get_client`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` langfuse.openai `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAI`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`client `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAI(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` api_key`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`os.environ[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"REDPILL_AI_API_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` base_url`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://api.redpill.ai/v1\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`response `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.chat.completions.create(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"z-ai/glm-5.3\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Reply with: connected\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"redpill_connection_check\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(response.choices[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].message.content)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Flush explicitly in short-lived jobs and scripts.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`get_client().flush()`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`The wrapper accepts the same streaming and async calls as the OpenAI SDK. Add trace names,\nsession identifiers, and low-sensitivity metadata only when they are useful for debugging or\naggregation.`}),`\n`,_jsx(Heading,{level:`2`,id:`decide-what-to-export`,children:`Decide what to export`}),`\n`,_jsx(_components.p,{children:`Before enabling tracing in production:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsx(_components.li,{children:`Classify prompts, responses, tool arguments, retrieved documents, and metadata.`}),`\n`,_jsx(_components.li,{children:`Configure Langfuse masking before those values leave the application, or omit content entirely.`}),`\n`,_jsx(_components.li,{children:`Set retention and access controls for the Langfuse project.`}),`\n`,_jsx(_components.li,{children:`Use a self-hosted Langfuse deployment when its data must remain inside your own boundary.`}),`\n`]}),`\n`,_jsx(_components.p,{children:`Masking changes telemetry only; it does not change the request sent to RedPill. If another\nOpenTelemetry exporter is active, configure its redaction separately.`}),`\n`,_jsx(Heading,{level:`2`,id:`costs-and-receipts`,children:`Costs and receipts`}),`\n`,_jsxs(_components.p,{children:[`Langfuse cost estimates depend on a matching model definition. RedPill model IDs or prices may need\na custom definition under `,_jsx(_components.strong,{children:`Project Settings > Models`}),`. Treat the RedPill dashboard as the billing\nsource of truth.`]}),`\n`,_jsx(_components.p,{children:`Langfuse does not verify RedPill’s signed receipts. Fetch and verify a receipt separately when the\nserving path is part of your security decision.`}),`\n`,_jsx(Heading,{level:`2`,id:`related`,children:`Related`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`https://langfuse.com/docs/integrations/openai`,children:`Langfuse OpenAI integration`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`https://langfuse.com/docs/observability/features/masking`,children:`Langfuse masking`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`https://langfuse.com/docs/observability/features/token-and-cost-tracking`,children:`Langfuse cost tracking`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`/confidential-ai/receipts`,children:`RedPill receipts`})}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Langfuse","description":"Trace RedPill API calls with Langfuse and an explicit data boundary.","href":"/guides/integrations/langfuse"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Configure tracing","slug":"configure-tracing","depth":2,"children":[]},{"title":"Trace a request","slug":"trace-a-request","depth":2,"children":[]},{"title":"Decide what to export","slug":"decide-what-to-export","depth":2,"children":[]},{"title":"Costs and receipts","slug":"costs-and-receipts","depth":2,"children":[]},{"title":"Related","slug":"related","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"phala-47f19b07","siteName":"RedPill AI","title":"Langfuse - RedPill AI","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-25T20:50:15.051Z","originalFileLocation":"guides/integrations/langfuse.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Trace RedPill API calls with Langfuse and an explicit data boundary.\">\u003cmeta data-mint-head name=\"application-name\" content=\"RedPill AI\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/phala-47f19b07/Y9aC6lrEn-iBCXi1/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/phala-47f19b07/Y9aC6lrEn-iBCXi1/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/phala-47f19b07/Y9aC6lrEn-iBCXi1/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/phala-47f19b07/Y9aC6lrEn-iBCXi1/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/phala-47f19b07/Y9aC6lrEn-iBCXi1/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/phala-47f19b07/Y9aC6lrEn-iBCXi1/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/phala-47f19b07/Y9aC6lrEn-iBCXi1/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/phala-47f19b07/Y9aC6lrEn-iBCXi1/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/phala-47f19b07/Y9aC6lrEn-iBCXi1/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Langfuse - RedPill AI\">\u003cmeta data-mint-head property=\"og:description\" content=\"Trace RedPill API calls with Langfuse and an explicit data boundary.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"RedPill AI\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.redpill.ai/guides/integrations/langfuse\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://phala-47f19b07.mintlify.app/_mintlify/api/og/v2?division=Build+with+the+API\u0026amp;title=Langfuse\u0026amp;description=Trace+RedPill+API+calls+with+Langfuse+and+an+explicit+data+boundary.\u0026amp;theme=42df2522bd3507e897bd01fe\u0026amp;signature=ffdedbae6a819c24ecd866d199f153c47be4a0cb0acaac2a219ca02ea02900be\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Langfuse - RedPill AI\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Trace RedPill API calls with Langfuse and an explicit data boundary.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://phala-47f19b07.mintlify.app/_mintlify/api/og/v2?division=Build+with+the+API\u0026amp;title=Langfuse\u0026amp;description=Trace+RedPill+API+calls+with+Langfuse+and+an+explicit+data+boundary.\u0026amp;theme=42df2522bd3507e897bd01fe\u0026amp;signature=ffdedbae6a819c24ecd866d199f153c47be4a0cb0acaac2a219ca02ea02900be\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/phala-47f19b07/Y9aC6lrEn-iBCXi1/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"RedPill AI\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#c96442\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.redpill.ai/guides/integrations/langfuse\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/guides/integrations/langfuse.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.redpill.ai/#organization\",\"name\":\"RedPill AI\",\"url\":\"https://docs.redpill.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/phala-47f19b07/5vRaVvmX8pi5Nukr/logo/light.svg?fit=max\u0026auto=format\u0026n=5vRaVvmX8pi5Nukr\u0026q=85\u0026s=03f8dbe12d0f593a956cccba7b18115f\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.redpill.ai#website\",\"name\":\"RedPill AI\",\"url\":\"https://docs.redpill.ai\",\"publisher\":{\"@id\":\"https://docs.redpill.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.redpill.ai/guides/integrations/langfuse#webpage\",\"url\":\"https://docs.redpill.ai/guides/integrations/langfuse\",\"name\":\"Langfuse\",\"description\":\"Trace RedPill API calls with Langfuse and an explicit data boundary.\",\"dateModified\":\"2026-10-25T20:50:15.051Z\",\"isPartOf\":{\"@id\":\"https://docs.redpill.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.redpill.ai/guides/integrations/langfuse#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.redpill.ai/guides/integrations/langfuse#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Build with the API\",\"item\":\"https://docs.redpill.ai/guides/integrations/openai-sdk\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Langfuse\",\"item\":\"https://docs.redpill.ai/guides/integrations/langfuse\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.redpill.ai/guides/integrations/langfuse#article\",\"headline\":\"Langfuse\",\"name\":\"Langfuse\",\"description\":\"Trace RedPill API calls with Langfuse and an explicit data boundary.\",\"url\":\"https://docs.redpill.ai/guides/integrations/langfuse\",\"mainEntityOfPage\":{\"@id\":\"https://docs.redpill.ai/guides/integrations/langfuse#webpage\"},\"dateModified\":\"2026-10-25T20:50:15.051Z\",\"publisher\":{\"@id\":\"https://docs.redpill.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.redpill.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"RedPill AI\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"RedPill AI","nav":{"global":{"anchors":[{"anchor":"Community","icon":"discord","href":"https://discord.gg/P2ukR4Z5ps"},{"anchor":"GitHub","icon":"github","href":"https://github.com/redpill-ai"}]},"tabs":[{"tab":"Documentation","groups":[{"group":"Get started","pages":[{"title":"Get started with RedPill","sidebarTitle":"Introduction","href":"/get-started/introduction"},{"title":"Quickstart","href":"/get-started/quickstart"},{"title":"Models","href":"/get-started/models"},{"title":"Billing","href":"/get-started/billing"},{"title":"Rate limits","href":"/get-started/rate-limits"},{"title":"Account MCP","sidebarTitle":"MCP","href":"/get-started/mcp"},{"title":"RedPill CLI","sidebarTitle":"CLI","href":"/get-started/cli"}]},{"group":"Use in agents","pages":[{"title":"Use in agents","sidebarTitle":"Overview","href":"/get-started/use-in-agents"},{"title":"Private AI Proxy","href":"/get-started/private-ai-proxy"},{"title":"Claude Code","href":"/guides/integrations/coding-tools/claude-code"},{"title":"Codex CLI","href":"/guides/integrations/coding-tools/codex-cli"},{"title":"Pi","href":"/guides/integrations/coding-tools/pi"},{"title":"OpenCode","href":"/guides/integrations/coding-tools/opencode"},{"title":"Cline","href":"/guides/integrations/coding-tools/cline"},{"title":"OpenClaw","href":"/guides/integrations/runtimes/openclaw"},{"title":"Hermes","href":"/guides/integrations/runtimes/hermes"}]},{"group":"Build with the API","pages":[{"title":"OpenAI SDK","href":"/guides/integrations/openai-sdk"},{"title":"Anthropic SDK","href":"/guides/integrations/anthropic-sdk"},{"title":"Vercel AI SDK","href":"/guides/integrations/vercel-ai-sdk"},{"title":"LangChain","href":"/guides/integrations/langchain"},{"title":"Agent frameworks","description":"Run CrewAI, PydanticAI, or the OpenAI Agents SDK on RedPill through the Chat Completions API.","href":"/guides/integrations/agent-frameworks"},{"title":"Langfuse","href":"/guides/integrations/langfuse"},{"title":"Cherry Studio","description":"Chat with RedPill models in the Cherry Studio desktop app.","href":"/guides/integrations/cherry-studio"},{"title":"Migrate from OpenAI or OpenRouter","href":"/guides/migrate"}]},{"group":"Features","pages":[{"title":"Streaming","href":"/guides/streaming"},{"title":"Function calling","href":"/guides/function-calling"},{"title":"Structured outputs","href":"/guides/structured-outputs"},{"title":"Vision","href":"/guides/vision"},{"title":"Reasoning","href":"/guides/reasoning"},{"title":"Prompt caching","href":"/guides/prompt-caching"},{"title":"Error handling","href":"/guides/error-handling"}]},{"group":"How it works","pages":[{"title":"How confidential AI works","href":"/confidential-ai/how-it-works"},{"title":"Attestation report","href":"/confidential-ai/attestation-report"},{"title":"Receipts","href":"/confidential-ai/receipts"},{"title":"Verified upstreams","href":"/confidential-ai/verified-upstreams"},{"title":"End-to-end encryption","href":"/confidential-ai/e2e-encryption"},{"title":"Trust boundary","href":"/confidential-ai/trust-boundary"}]},{"group":"Verify and control","pages":[{"title":"Verify a response","href":"/guides/verify-a-response"},{"title":"Release measurements","href":"/guides/release-measurements"},{"title":"Encrypt a request","href":"/guides/e2ee-encryption"},{"title":"Zero data retention","href":"/guides/zero-data-retention"},{"title":"Attested routing","href":"/guides/attested-routing"},{"title":"TEE-only endpoint","href":"/guides/tee-endpoint"}]},{"group":"Providers and trust","pages":[{"title":"Confidential providers","href":"/confidential-ai/providers"},{"title":"Open source","href":"/confidential-ai/open-source"},{"title":"Compliance","href":"/confidential-ai/compliance"},{"title":"FAQ","href":"/confidential-ai/faqs"}]},{"group":"RedPill Chat","pages":[{"title":"Overview","href":"/chat/overview"},{"title":"Private knowledge","href":"/chat/private-knowledge"}]}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/api-reference/overview"}]},{"tab":"Changelog","pages":[{"title":"Changelog","href":"/changelog"}]}]},"basePath":"","title":"Langfuse - RedPill AI","buildId":"dpl_345ReqzYaAjzS9QpeJemsKdb7KDj","deploymentId":"dpl_345ReqzYaAjzS9QpeJemsKdb7KDj","dynamics":[],"chunks":[]}