Integration Langserve
title: Langserve Integration description: This guide shows how to natively integrate Langfuse with LangChain's Langserve for observability, metrics, evals, prompt management, playground, datasets. category: Integrations sidebarTitle: Langserve logo: /images/integrations/langchain_icon.png
Cookbook: Langserve Integration (SDK v2)
Langserve (Python)
LangServe helps developers deploy LangChain runnables and chains as a REST API.
This library is integrated with FastAPI and uses pydantic for data validation.
In addition, it provides a client that can be used to call into runnables deployed on a server. A JavaScript client is available in LangChain.js.
This cookbook demonstrates how to trace applications deployed via Langserve with Langfuse (using the LangChain integration). We'll run both the server and the client in this notebook.
Setup
Note: This guide uses our Python SDK v2. We have a new, improved SDK available based on OpenTelemetry. Please check out the SDK v3 for a more powerful and simpler to use SDK.
Simple LLM Call Example
Initialize the Langfuse client and configure the LLM with Langfuse as callback handler. Add to Fastapi via Langserve's add_routes().
Note: We use TestClient in this example to be able to run the server in a notebook


