← Back to changelog
August 8, 2024

Tracing of OpenAI Structured Outputs

Picture Jannik MaierhöferJannik Maierhöfer

Langfuse now supports tracing OpenAI Structured Outputs.

What are structured outputs?

Generating structured data from unstructured inputs is a core AI use case today. Developers use the OpenAI API to build applications that fetch data, answer questions via function calling, extract structured data, and create multi-step workflows for LLMs to take actions. Structured Outputs is a new capability of the OpenAI API that builds upon JSON mode and function calling to enforce a strict schema in a model output.

How to trace structured output in Langfuse?

If you use the OpenAI Python SDK, you can use the Langfuse drop-in OpenAI SDK replacement to get full logging by changing only the import. With that, you can monitor the structured output generated by OpenAI in Langfuse.

- import openai
+ from langfuse.openai import openai
 
Alternative imports:
+ from langfuse.openai import OpenAI, AsyncOpenAI, AzureOpenAI, AsyncAzureOpenAI

For and end-to-end example, have a look at our cookbook on tracing stuctured outputs with Langfuse:

Was this page useful?

Questions? We're here to help

Subscribe to updates