Query Traces
Langfuse is open-source and data tracked with Langfuse is open. You can query/export data via: SDKs, API, and Langfuse UI.
Common use cases:
- Train or fine-tune models on the production traces in Langfuse. E.g. to create a small model after having used a large model in production for a specific use case.
- Collect few-shot examples to improve quality of output.
- Programmatically create datasets.
If you are new to Langfuse, we recommend familiarizing yourself with the Langfuse data model.
New data is typically available for querying within 15-30 seconds of ingestion, though processing times may vary at times. Please visit status.langfuse.com if you encounter any issues.
SDKs
Via the SDKs for Python and JS/TS you can easily query the API without having to write the HTTP requests yourself.
The dedicated fetch*
methods for core entities are covered by tests and semantic versioning. The methods on the langfuse.api
are auto-generated from the API reference and cover all entities.
pip install langfuse
from langfuse import Langfuse
langfuse = Langfuse(
secret_key="sk-lf-...",
public_key="pk-lf-...",
host="https://cloud.langfuse.com" # 🇪🇺 EU region
# host="https://us.cloud.langfuse.com" # 🇺🇸 US region
)
### Dedicated fetch_* methods for core entities
# Fetch list of traces, supports filters and pagination
traces = langfuse.fetch_traces()
# Fetch a single trace by ID
trace = langfuse.fetch_trace("traceId")
# Fetch list of observations, supports filters and pagination
observations = langfuse.fetch_observations()
# Fetch a single observation by ID
observation = langfuse.fetch_observation("observationId")
# Fetch list of sessions
sessions = langfuse.fetch_sessions()
### Methods on langfuse.api namespace for other entities (generated from the API reference)
# Fetch a single score by ID
langfuse.api.score.get("scoreId")
# Explore more entities via Intellisense
langfuse.api.*
Python SDK reference including all available filters:
This notebook includes a number of examples of how to use the Langfuse SDK to query data.
API
All data in Langfuse is available via the API. Refer to the API reference for more information.
Example routes:
GET /api/public/traces
GET /api/public/traces/:traceId
GET /api/public/observations
GET /api/public/observations/:observationId
GET /api/public/sessions
GET /api/public/scores
GET /api/public/scores/:scoreId
Export via UI
All filters applied to the table will be applied to the export.
Available export formats:
- CSV
- JSON
Export via Blob Storage Integration
- Hobby(Not Available)
- Core(Not Available)
- Pro(Team Add-On)(Team)
- Enterprise(Public Beta)
- Self Hosted(Pro & Enterprise)(Pro & Enterprise)
You can create schedule exports to a Blob Storage, e.g. S3, GCS, or Azure Blob Storage, for traces, observations, and scores.
Those exports can run on an hourly, daily, or weekly schedule.
Navigate to your project settings and select Integrations > Blob Storage
to set up a new export.
Select whether you want to use S3, a S3 compatible storage, or Azure Blob Storage.
Fill in the settings to authenticate with your vendor, enable the integration, and press save.
Within an hour an initial export should start and continue based on the schedule you have selected.
Read our blob storage documentation for more information on how to get credentials for your specific vendor.
Trouble exporting?
If you’re having trouble exporting data, please let us know and we’ll help you out.