Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.langtrace.ai/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Flask is a popular web framework for building APIs with Python 3.6+ based on standard Python type hints. Langtrace can be easily integrated with Flask applications with the help of the Langtrace SDK.

Steps

Follow the steps below to integrate Langtrace with your Flask application:
  • Install the Langtrace SDK in your project and initialize it inside the app.py file:
Python
from flask import Flask
from langtrace_python_sdk import langtrace
from openai import OpenAI

langtrace.init()
client = OpenAI()
app = Flask(__name__)


@app.route("/")
def main():
    client.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": "Say this is a test three times"}],
        stream=False,
    )
    return "Hello, World!"