Cette page n'est pas encore disponible en français, sa traduction est en cours. Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
LLM Observability is not available in the US1-FED site.
Our quickstart docs make use of the LLM Observability SDK for Python. For detailed usage, see the SDK documentation. If your application is written in another language, you can create traces by calling the API instead.
The example script below uses OpenAI, but you can modify it to use a different provider. To run the script as written, you need:
An OpenAI API key stored in your environment as OPENAI_API_KEY. To create one, see Account Setup and Set up your API key in the OpenAI documentation.
The OpenAI Python library installed. See Setting up Python in the OpenAI documentation for instructions.
1. Install the SDK
Install the following ddtrace and openai packages:
pip install ddtrace
pip install openai
2. Create the script
The Python script below makes a single OpenAI call. Save it as quickstart.py.
quickstart.py
importosfromopenaiimportOpenAIoai_client=OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))completion=oai_client.chat.completions.create(model="gpt-3.5-turbo",messages=[{"role":"system","content":"You are a helpful customer assistant for a furniture store."},{"role":"user","content":"I'd like to buy a chair for my living room."},],)
3. Run the script
Run the Python script with the following shell command, sending a trace of the OpenAI call to Datadog:
If your application consists of more elaborate prompting or complex chains or workflows involving LLMs, you can trace it using the instrumentation guide and the SDK documentation.