### Install and Start Flowise Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/no-code/flowise.mdx Use these commands to install Flowise globally and then start the application. ```sh # install npm install -g flowise # start npx flowise start ``` -------------------------------- ### Start Local Development Server with pnpm Source: https://github.com/langfuse/langfuse-docs/blob/main/AGENTS.md Starts the local development server on port 3333. This is the preferred default command after installation. ```bash pnpm dev ``` -------------------------------- ### Start Local MinIO Container with Docker Source: https://github.com/langfuse/langfuse-docs/blob/main/content/self-hosting/deployment/infrastructure/blobstorage.mdx Use this command to run a local MinIO instance with Docker, exposing ports 9000 and 9001, and setting root credentials. This setup uses an ephemeral volume. ```bash docker run --name minio \ -p 9000:9000 \ -p 9001:9001 \ -e MINIO_ROOT_USER=minio \ -e MINIO_ROOT_PASSWORD=miniosecret \ minio/minio server /data --console-address ":9001" ``` -------------------------------- ### Verify Docker Installation (VM) Source: https://github.com/langfuse/langfuse-docs/blob/main/content/self-hosting/deployment/docker-compose.mdx Verifies that Docker has been correctly installed on the VM by running the 'hello-world' container. ```bash sudo docker run hello-world ``` -------------------------------- ### Install Project Dependencies (pnpm) Source: https://github.com/langfuse/langfuse-docs/blob/main/README.md Run this command to install all necessary project dependencies using pnpm. ```bash pnpm i ``` -------------------------------- ### Install Dependencies Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/developer-tools/kiro-cli.mdx Navigates to the `hooks` directory within your project and installs the necessary Node.js dependencies. ```bash cd your-project/hooks && npm install ``` -------------------------------- ### Running a BeeAI ReAct Agent Example Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/frameworks/beeai.mdx This example demonstrates how to initialize a BeeAI ReAct agent with an LLM and tools, then execute it with a specific prompt and configuration. ```python import asyncio from beeai_framework.agents.react import ReActAgent from beeai_framework.agents.types import AgentExecutionConfig from beeai_framework.backend.chat import ChatModel from beeai_framework.backend.types import ChatModelParameters from beeai_framework.memory import TokenMemory from beeai_framework.tools.search.wikipedia import WikipediaTool from beeai_framework.tools.weather.openmeteo import OpenMeteoTool # Initialize the language model llm = ChatModel.from_name( "openai:gpt-4o-mini", # or "ollama:granite3.3:8b" for local Ollama ChatModelParameters(temperature=0.7), ) # Create tools for the agent tools = [ WikipediaTool(), OpenMeteoTool(), ] # Create a ReAct agent with memory agent = ReActAgent( llm=llm, tools=tools, memory=TokenMemory(llm) ) # Run the agent async def main(): response = await agent.run( prompt="I'm planning a trip to Barcelona, Spain. Can you research key attractions and landmarks I should visit, and also tell me what the current weather conditions are like there?", execution=AgentExecutionConfig( max_retries_per_step=3, total_max_retries=10, max_iterations=5 ), ) print("Agent Response:", response.result.text) return response # Run the example response = await main() ``` -------------------------------- ### Run a BeeAI ReAct Agent Example Source: https://github.com/langfuse/langfuse-docs/blob/main/cookbook/integration_beeai.ipynb This example demonstrates how to initialize a BeeAI ReAct agent with an LLM and tools, then execute it with a specific prompt to generate traces. ```python import asyncio from beeai_framework.agents.react import ReActAgent from beeai_framework.agents.types import AgentExecutionConfig from beeai_framework.backend.chat import ChatModel from beeai_framework.backend.types import ChatModelParameters from beeai_framework.memory import TokenMemory from beeai_framework.tools.search.wikipedia import WikipediaTool from beeai_framework.tools.weather.openmeteo import OpenMeteoTool # Initialize the language model llm = ChatModel.from_name( "openai:gpt-4o-mini", # or "ollama:granite3.3:8b" for local Ollama ChatModelParameters(temperature=0.7), ) # Create tools for the agent tools = [ WikipediaTool(), OpenMeteoTool(), ] # Create a ReAct agent with memory agent = ReActAgent( llm=llm, tools=tools, memory=TokenMemory(llm) ) # Run the agent async def main(): response = await agent.run( prompt="I'm planning a trip to Barcelona, Spain. Can you research key attractions and landmarks I should visit, and also tell me what the current weather conditions are like there?", execution=AgentExecutionConfig( max_retries_per_step=3, total_max_retries=10, max_iterations=5 ), ) print("Agent Response:", response.result.text) return response # Run the example response = await main() ``` -------------------------------- ### Install Dependencies for Langchain RetrievalQA Source: https://github.com/langfuse/langfuse-docs/blob/main/content/guides/cookbook/integration_langchain.md Installs necessary Python packages for the Langchain RetrievalQA example, including unstructured, selenium, and langchain-chroma. ```python %pip install unstructured selenium langchain-chroma --upgrade ``` -------------------------------- ### Start LiteLLM Proxy with Configuration File Source: https://github.com/langfuse/langfuse-docs/blob/main/content/guides/cookbook/integration_litellm_proxy.mdx Executes the LiteLLM CLI command to start the proxy, loading model configurations from the specified `litellm_config.yaml` file. ```bash litellm --config litellm_config.yaml ``` -------------------------------- ### Install Langfuse SDK v2 Source: https://github.com/langfuse/langfuse-docs/blob/main/content/guides/cookbook/langfuse_sdk_performance_test.md Installs the Langfuse Python SDK version 2, which is used throughout this performance test guide. ```python %pip install "langfuse<3.0.0" --upgrade ``` -------------------------------- ### Install Required Python Dependencies Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/frameworks/agno-agents.mdx Installs the necessary Python packages for Agno, OpenAI, Langfuse, yfinance, and OpenLIT, which are essential for running the examples. ```python %pip install agno openai langfuse yfinance openlit ``` -------------------------------- ### Start LiteLLM Proxy with Configuration Source: https://github.com/langfuse/langfuse-docs/blob/main/content/guides/cookbook/js_integration_litellm_proxy.mdx Executes the LiteLLM proxy using a specified configuration file. This command starts the proxy server, making configured models available. ```bash litellm --config litellm_config.yaml ``` -------------------------------- ### Run Langflow with Docker Compose Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/no-code/langflow.mdx Navigate to the `docker_example` directory and start the Langflow service using Docker Compose, building the image if necessary. ```sh cd docker_example docker-compose up --build ``` -------------------------------- ### Install Langfuse Observability Plugin for Claude Code Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/developer-tools/claude-code.mdx Use these commands to install the Langfuse Observability Plugin directly from the Claude Code plugin marketplace. After installation, restart Claude Code to complete the setup. ```bash claude plugin marketplace add langfuse/Claude-Observability-Plugin claude plugin install langfuse-observability@langfuse-observability ``` -------------------------------- ### Optional Pre-fetching of Prompts on Startup Source: https://github.com/langfuse/langfuse-docs/blob/main/content/docs/prompt-management/features/caching.mdx Demonstrates how prompts can be pre-fetched during application startup to populate the SDK cache, ensuring it is warm before runtime requests and minimizing initial latency. ```mermaid sequenceDiagram participant App as Application participant SDK as Langfuse SDK participant Cache as SDK Cache participant API as Langfuse API participant Redis as Redis Cache App->>SDK: Prefetch prompts SDK->>API: GET /api/public/prompts/:name API->>Redis: Check/populate cache Redis-->>API: Cached prompt API-->>SDK: Return prompt SDK->>Cache: Populate cache Note over Cache: Cache now warm for runtime ``` -------------------------------- ### Start All Services with Docker Compose Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/other/agentic-data-stack.mdx Starts all services defined in the Docker Compose setup in detached mode, including LibreChat, Langfuse, and supporting databases. ```bash docker compose up -d ``` -------------------------------- ### Install Python Dependencies for LlamaIndex Workflows Source: https://github.com/langfuse/langfuse-docs/blob/main/content/guides/cookbook/integration_llamaindex_workflows.mdx Install the necessary Python packages, including Langfuse, OpenAI, LlamaIndex Workflows, and OpenInference instrumentation, to run the example. ```python %pip install langfuse openai llama-index-workflows llama-index-core llama-index-llms-openai openinference-instrumentation-llama_index llama-index-instrumentation ``` -------------------------------- ### Start LiteLLM Proxy with Configuration Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/gateways/litellm.mdx Run the LiteLLM proxy using the specified configuration file to activate Langfuse logging. ```bash litellm --config /path/to/litellm_config.yaml ``` -------------------------------- ### Run Interactive Setup Script Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/other/agentic-data-stack.mdx Executes an interactive script to generate secure credentials for all services and configure LLM API keys. ```bash ./scripts/prepare-demo.sh ``` -------------------------------- ### Install Kong AI Tracing Plugin via LuaRocks Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/gateways/kong-ai-plugin.mdx Installs the Kong Langfuse Tracing plugin using LuaRocks, the recommended method for quick setup. ```bash luarocks install kong-plugin-ai-tracing ``` -------------------------------- ### Example Self-Hosted Redis Sentinel Configuration Source: https://github.com/langfuse/langfuse-docs/blob/main/content/self-hosting/deployment/infrastructure/cache.mdx This example demonstrates a typical environment variable setup for a self-hosted Redis deployment using Sentinel, including specific IP addresses for Sentinel nodes and Redis authentication. ```bash REDIS_SENTINEL_ENABLED=true REDIS_SENTINEL_NODES=10.0.1.10:26379,10.0.1.11:26379,10.0.1.12:26379 REDIS_SENTINEL_MASTER_NAME=langfuse-master REDIS_AUTH=your-redis-password ``` -------------------------------- ### Start Local Development Server (pnpm) Source: https://github.com/langfuse/langfuse-docs/blob/main/README.md Execute this command to start the development server, typically accessible on localhost:3333. ```bash pnpm dev ``` -------------------------------- ### Create and Run an Agent with OpenAIResponsesClient Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/frameworks/microsoft-agent-framework.mdx This snippet demonstrates how to initialize an agent using OpenAIResponsesClient, define a custom tool, and execute a query to receive an agent's response. ```python from agent_framework.openai import OpenAIResponsesClient from typing import Annotated from pydantic import Field from random import randint def get_weather( location: Annotated[str, Field(description="The location to get the weather for.")], ) -> str: """Get the weather for a given location.""" conditions = ["sunny", "cloudy", "rainy", "stormy"] return f"The weather in {location} is {conditions[randint(0, 3)]} with a high of {randint(10, 30)}°C." async def main(): async with OpenAIResponsesClient().create_agent( instructions="You are a helpful assistant.", tools=get_weather, ) as agent: query = "What's the weather in Tokyo?" print(f"User: {query}") result = await agent.run(query) print(f"Agent: {result}\n") await main() ``` -------------------------------- ### Clone Langflow Repository for Docker Setup Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/no-code/langflow.mdx Clone the official Langflow GitHub repository to prepare for a Docker-based installation and configuration. ```sh git clone https://github.com/logspace-ai/langflow.git cd langflow ``` -------------------------------- ### LLM Evaluation Workflow Steps Source: https://github.com/langfuse/langfuse-docs/blob/main/content/blog/2025-03-04-llm-evaluation-101-best-practices-and-challenges.mdx Illustrates a cyclical workflow for getting started with LLM evaluation, from data collection to closing the loop with feedback. ```mermaid flowchart LR A[Collect Data] --> B[Experiment with Different Methods] B --> C[Set Baselines] C --> D[Pick Your Environment] D --> E[Close the Loop] E --> A classDef boxes fill:#000,color:#fff,stroke:#fff,stroke-width:2px,rx:15px,ry:15px class A,B,C,D,E boxes ``` -------------------------------- ### Run Redis in Docker Container Source: https://github.com/langfuse/langfuse-docs/blob/main/content/self-hosting/deployment/infrastructure/cache.mdx Start a Redis container with a password and the 'noeviction' memory policy. This setup is not recommended for production due to lack of redundancy. ```bash docker run --name redis \ -p 6379:6379 \ redis --requirepass myredissecret --maxmemory-policy noeviction ``` -------------------------------- ### Create a new VoltAgent project Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/frameworks/voltagent.mdx Use the VoltAgent CLI to scaffold a new project. ```bash npm create voltagent-app@latest ``` -------------------------------- ### Initialize Langfuse Client with Python SDK Source: https://github.com/langfuse/langfuse-docs/blob/main/content/docs/observability/sdk/overview.mdx Demonstrates how to initialize the Langfuse client in Python, either using environment variables or by passing configuration directly to the constructor. ```python from langfuse import get_client langfuse = get_client() # Verify connection if langfuse.auth_check(): print("Langfuse client is authenticated and ready!") else: print("Authentication failed. Please check your credentials and host.") ``` ```python from langfuse import Langfuse langfuse = Langfuse( public_key="your-public-key", secret_key="your-secret-key", base_url="https://cloud.langfuse.com", # # Other Langfuse data regions include ) ``` -------------------------------- ### Download Multi-modality Test Files Source: https://github.com/langfuse/langfuse-docs/blob/main/content/guides/cookbook/example_multi_modal_traces.md Downloads example image, audio, and PDF files from the Langfuse GitHub repository to a local 'static' directory for use in multi-modality examples. ```python import os from urllib.request import urlretrieve from urllib.error import URLError REPO_URL = "https://github.com/langfuse/langfuse-python" download_path = "static" os.makedirs(download_path, exist_ok=True) test_files = ["puton.jpg", "joke_prompt.wav", "bitcoin.pdf"] raw_url = f"{REPO_URL}/raw/main/{download_path}" for file in test_files: try: urlretrieve(f"{raw_url}/{file}", f"{download_path}/{file}") print(f"Successfully downloaded: {file}") except URLError as e: print(f"Failed to download {file}: {e}") except OSError as e: print(f"Failed to save {file}: {e}") ``` -------------------------------- ### Instrumenting generate_text with Langfuse in AI SDK C++ Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/frameworks/ai-sdk-cpp.mdx This example demonstrates how to set up the Langfuse tracer, configure an LLM client, start a trace, and use `ai::langfuse::generate_text` to automatically record LLM calls and tool invocations. ```cpp #include #include #include #include #include int main() { // 1. Create a Tracer once and reuse it for all traces. ai::langfuse::Tracer tracer({ .host = std::getenv("LANGFUSE_HOST") ? std::getenv("LANGFUSE_HOST") : "https://cloud.langfuse.com", .public_key = std::getenv("LANGFUSE_PUBLIC_KEY"), .secret_key = std::getenv("LANGFUSE_SECRET_KEY"), .environment = "ai-sdk-cpp-example", }); if (!tracer.is_valid()) { std::cerr << "Langfuse tracer not configured.\n"; return 1; } // 2. Configure the LLM client and tools as usual. auto client = ai::openai::create_client(); ai::GenerateOptions options; options.model = ai::openai::models::kGpt4oMini; options.system = "You are a concise assistant. Use the available tools when helpful."; options.prompt = "Look up alice and tell me the weather where she lives."; options.max_steps = 4; options.temperature = 0.0; // options.tools = ... ; // register your ai::ToolSet here // 3. Start a trace and attach input/metadata. auto trace = tracer.start_trace("langfuse_tracing_example"); trace->set_input(options.prompt); trace->set_metadata({{"example", "langfuse_tracing"}, {"sdk", "ai-sdk-cpp"}}); // 4. Run generate_text via the Langfuse wrapper. auto result = ai::langfuse::generate_text(client, std::move(options), *trace); if (result) { std::cout << "Output: " << result.text << "\n"; trace->set_output(result.text); } else { trace->set_output(ai::JsonValue{{"error", result.error_message()}}); } // 5. Flush the batch synchronously to Langfuse. trace->end(); return result ? 0 : 2; } ``` -------------------------------- ### Define Multi-shot Prompt for Tone Evaluation Source: https://github.com/langfuse/langfuse-docs/blob/main/content/guides/cookbook/example_external_evaluation_pipelines.mdx This Python string defines a multi-shot prompt template for an LLM to identify three dominant tones in a given text. It includes examples to guide the model's output format and tone identification. ```python template_tone_eval = """ You're an expert in human emotional intelligence. You can identify with ease the tone in human-written text. Your task is to identify the tones present in a piece of with precission. Your output is a comma separated list of three tones. PRINT THE LIST ALONE, NOTHING ELSE. neutral, confident, joyful, optimistic, friendly, urgent, analytical, respectful Input: Citizen science plays a crucial role in research by involving everyday people in scientific projects. This collaboration allows researchers to collect vast amounts of data that would be impossible to gather on their own. Citizen scientists contribute valuable observations and insights that can lead to new discoveries and advancements in various fields. By participating in citizen science projects, individuals can actively contribute to scientific research and make a meaningful impact on our understanding of the world around us. Output: respectful,optimistic,confident Input: Bionics is a field that combines biology and engineering to create devices that can enhance human abilities. By merging humans and machines, bionics aims to improve quality of life for individuals with disabilities or enhance performance for others. These technologies often mimic natural processes in the body to create seamless integration. Overall, bionics holds great potential for revolutionizing healthcare and technology in the future. Output: optimistic,confident,analytical Input: Social media can have both positive and negative impacts on mental health. On the positive side, it can help people connect, share experiences, and find support. However, excessive use of social media can also lead to feelings of inadequacy, loneliness, and anxiety. It's important to find a balance and be mindful of how social media affects your mental well-being. Remember, it's okay to take breaks and prioritize your mental health. Output: friendly,neutral,respectful {text} """ ``` -------------------------------- ### Start Mastra Development Server Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/frameworks/mastra.mdx Execute this command to start the Mastra development server and access the developer playground. ```bash npm run dev ``` -------------------------------- ### Reply Template: Startup Discount Program Information Source: https://github.com/langfuse/langfuse-docs/blob/main/content/handbook/support/how-to-answer-support-questions.mdx Provide information about the startup program and direct customers to the application form. Explain how approved applicants receive and apply the discount code. ```text Hi {name}, Happy to help. Details on the program are here: https://langfuse.com/startups To apply, please fill out: https://forms.gle/eJAYjRWeCZU1Mn6j8 Once approved you'll get the discount code by email, you can apply it at checkout when upgrading or in your billing settings if you already have a subscription. Best, {you} ``` -------------------------------- ### Install Langfuse, Langchain, and Langchain-OpenAI Source: https://github.com/langfuse/langfuse-docs/blob/main/content/guides/cookbook/integration_azure_openai_langchain.md Installs the necessary Python packages for Langfuse (v2 SDK), Langchain, and Langchain-OpenAI, upgrading existing installations. ```python %pip install --quiet "langfuse<3.0.0" langchain langchain-openai --upgrade ``` -------------------------------- ### Install Hermes Agent and Langfuse Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/other/hermes.mdx Install the Hermes Agent directly from its Git repository and the Langfuse SDK using pip. The -U flag ensures packages are upgraded if already installed. ```python %pip install git+https://github.com/NousResearch/hermes-agent.git langfuse -U ``` -------------------------------- ### Install Langfuse SDK Source: https://github.com/langfuse/langfuse-docs/blob/main/content/blog/showcase-llm-chatbot.mdx Installs the Langfuse Typescript SDK as a dependency in your project. ```sh npm i langfuse ``` -------------------------------- ### Create a Mastra Project Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/frameworks/mastra.mdx Use this command to initialize a new Mastra project if you don't have one already. ```bash npx create-mastra ``` -------------------------------- ### Install LlamaIndex and Langfuse Source: https://github.com/langfuse/langfuse-docs/blob/main/content/guides/cookbook/integration_llama-index-callback.md Install the necessary Python packages for LlamaIndex and Langfuse integration. ```python %pip install llama-index "langfuse<3.0.0" --upgrade ``` -------------------------------- ### Build Production Site with pnpm Source: https://github.com/langfuse/langfuse-docs/blob/main/AGENTS.md Builds the production site. Use this to validate many pages when the dev server is too slow, but note it takes about 10 minutes. ```bash pnpm build ``` -------------------------------- ### Install Langfuse Python SDK Source: https://github.com/langfuse/langfuse-docs/blob/main/content/docs/observability/sdk/overview.mdx Use pip to install the Langfuse Python SDK. ```bash pip install langfuse ``` -------------------------------- ### Install Langfuse JS/TS SDK Source: https://github.com/langfuse/langfuse-docs/blob/main/content/docs/api-and-data-platform/features/query-via-sdk.mdx Install the Langfuse JavaScript/TypeScript SDK using npm. ```bash npm install @langfuse/client ``` -------------------------------- ### Install Langfuse and OpenAI SDK Source: https://github.com/langfuse/langfuse-docs/blob/main/content/integrations/gateways/vercel-ai-gateway.mdx Install the necessary Langfuse and OpenAI SDK packages to begin integrating with the Vercel AI Gateway. ```bash pip install langfuse openai ``` ```bash npm install langfuse openai ```