Public API
Langfuse is open and meant to be extended via custom workflows and integrations. All Langfuse data and features are available via the API.
/api/public
References:
- API Reference: https://api.reference.langfuse.com
- OpenAPI spec: https://cloud.langfuse.com/generated/api/openapi.yml
- Postman collection: https://cloud.langfuse.com/generated/postman/collection.json
Authentication
Authenticate with the API using Basic Auth. The API keys are available in the Langfuse project settings.
- Username: Langfuse Public Key
- Password: Langfuse Secret Key
Example:
curl -u public-key:secret-key https://cloud.langfuse.com/api/public/projects
Access via SDKs
Both the Langfuse Python SDK and the JS/TS SDK provide a strongly-typed wrapper around our public REST API for your convenience. The API methods are accessible via the api
property on the Langfuse client instance in both SDKs.
You can use your editor’s Intellisense to explore the API methods and their parameters.
When fetching prompts, please use the get_prompt
(Python) / getPrompt
(JS/TS) methods on the Langfuse client to benefit from client-side caching, automatic retries, and fallbacks.
When using the Python SDK v3:
from langfuse import get_client
langfuse = get_client()
...
# fetch a trace
langfuse.api.trace.get(trace_id)
# async client via asyncio
await langfuse.async_api.trace(trace_id)
# explore more endpoints via Intellisense
langfuse.api.*
await langfuse.async_api.*
Ingest Traces via the API
It is recommended to use the OpenTelemetry Endpoint to ingest traces. Please refer to the OpenTelemetry docs for more information.
Alternatives
You can also export data via:
- UI - Manual batch-exports from the Langfuse UI
- Blob Storage - Scheduled automated exports to cloud storage