Overview

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

Steps

Follow the steps below to integrate Langtrace with your Django application:

  • Install the Langtrace SDK. Initialize django project and add this inside the init.py file
Python
from langtrace_python_sdk import langtrace
from openai import OpenAI


langtrace.init(api_key="<LANGTRACE_API_KEY>")
client = OpenAI()

client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Say this is a test three times"}],
    stream=False,
)