Skip to main content
Langfuse ships a drop-in replacement for the OpenAI SDK — from langfuse.openai import openai — so you get full call tracing by importing that instead of openai and pointing base_url at https://api.tokios.com/v1 with an sk-tok-… key. Because the wrapper mirrors the OpenAI client’s interface, anything you already send to Tokios (chat completions, streaming, tool calls) gets traced with no change beyond the import and the base URL.

사전 요구 사항

Langfuse 계정 또는 자체 호스팅 환경

Langfuse Cloud에 가입하거나 자체 호스팅 인스턴스를 구축한 뒤 Langfuse 공개/비밀 API 키 쌍을 확보하세요.

커넥터 설치하기

Pair tokios-connector with your local backend.

배포 환경 등록하기

Choose the public name your model field will use.

API 키 생성하기

필요한 배포 환경에 맞게 sk-tok-… API 키를 생성하세요.

호출 내역 추적하기

1

두 SDK 모두 설치하기

2

Langfuse 인증 정보를 설정하세요.

Langfuse의 OpenAI 래퍼는 환경 변수에서 인증 정보를 읽어들입니다:
Langfuse Cloud를 사용하지 않는 경우 LANGFUSE_HOST 항목에 자체 호스팅된 인스턴스의 URL을 입력하세요.
3

래퍼를 임포트한 뒤 원하는 배포 환경을 호출하세요.

Import openai from langfuse.openai instead of the plain openai package, then use it exactly like the standard OpenAI client, with base_url pointed at Tokios and model set to your registered deployment name:
langfuse_tokios.py
이 클라이언트를 통한 모든 호출이 Langfuse에 기록됩니다. 호출 자체를 위해 @observe 데코레이터나 수동으로 스팬을 생성할 필요가 없습니다.
model is always the Tokios deployment name you registered in the Models tab, never your backend’s local model id, and the base URL must include /v1.

로컬 모델에 대한 비용 추적

Langfuse calculates cost from a model’s per-token price, which it knows for hosted providers like OpenAI and Anthropic. A Tokios deployment fronts your own local model, so Langfuse has no built-in price for it — traces still capture prompts, completions, latency, and token counts, but cost may show as zero or missing until you tell Langfuse how to price that model.
이 문제를 해결하려면 Langfuse의 모델 설정에서 model으로 전송되는 배포 이름과 일치하는 커스텀 모델을 정의하고 토큰당 가격을 지정하세요. 비용 산정만 원한다면 $0와 같은 가격을 설정해도 됩니다. 사용되는 절차는 Langfuse 버전에 따라 달라질 수 있으므로 비용 관련 수치를 참고하기 전에 반드시 최신 모델 가격 설정 가이드를 확인하시기 바랍니다.

이제 어디서든 추적이 가능합니다

위에서 설명한 추적 설정은 Tokios를 호출하는 클라이언트가 사용자의 노트북에 있든 팀원의 기기에 있든 동일하게 작동합니다. 커넥터는 오직 로컬 백엔드에서만 외부로 연결됩니다. 팀원이나 배포된 에이전트가 범위가 지정된 sk-tok-… API 키를 보유하게 되면, 동일한 langfuse.openai 래퍼를 통해 전송된 요청들도 같은 Langfuse 프로젝트에 기록됩니다.

호환 가능한 클라이언트

Tokios와 연동 가능한 OpenAI 및 Anthropic 호환 클라이언트 목록을 전체적으로 확인해보세요.

API 키

팀원이나 에이전트마다 별도의 범위 지정 API 키를 생성해주시기 바랍니다.

요청 로깅

전송된 내용만 확인하면 된다면 트레이싱 스택을 구축하는 대신 대시보드에서 요청 로깅 기능을 활성화하시면 됩니다.