Skip to main content

Overview

Langfuse can trace TokenLab calls through its OpenAI integration when the OpenAI SDK is configured with TokenLab’s /v1 base URL.
Type: ObservabilityPrimary Path: OpenAI SDK tracingSupport Confidence: Supported OpenAI-compatible tracing path

Environment

export LANGFUSE_SECRET_KEY="sk-lf-..."
export LANGFUSE_PUBLIC_KEY="pk-lf-..."
export LANGFUSE_BASE_URL="https://cloud.langfuse.com"
export TOKENLAB_API_KEY="sk-your-tokenlab-key"

Example

import os

from langfuse import observe
from langfuse.openai import openai

openai.api_key = os.environ["TOKENLAB_API_KEY"]
openai.base_url = "https://api.tokenlab.sh/v1"


@observe()
def story():
    return openai.chat.completions.create(
        model="claude-sonnet-5",
        messages=[{"role": "user", "content": "Write a short haiku."}],
    ).choices[0].message.content

Endpoint Notes

This page covers Langfuse tracing for the OpenAI SDK path. If your application uses TokenLab native Responses, Anthropic Messages, or Gemini endpoints, make sure your instrumentation captures that client call path.