Skip to main content
Use Lemma’s OpenAI Agents integration when your app uses the OpenAI Agents SDK trace processor system. The integration creates one Lemma trace for each OpenAI Agents trace, maps model calls to generations, maps function calls to tools, and preserves parent IDs so child spans stay nested correctly. You do not need to wrap agent runs in lemma.trace(). Register the processor once, then run OpenAI Agents normally.

TypeScript

Install both packages:
Register the Lemma processor before running agents. By default, credentials are read from LEMMA_API_KEY and LEMMA_PROJECT_ID:
You can also pass credentials directly:
Then run your agent normally:

Python

Install the Python extra:
Register the Lemma processor before running agents. By default, credentials are read from LEMMA_API_KEY and LEMMA_PROJECT_ID:
You can also pass credentials directly:
Then run your agent normally:

What Lemma records

OpenAI Agents trace group_id is recorded as the Lemma threadId, so runs in the same conversation stay grouped.

Privacy

The integration records prompts, tool inputs, tool outputs, and model output by default. Disable input/output recording when you need structure and timings without payload contents:

Debugging

Use debug mode to confirm spans are arriving live and nested under the expected parent:
Look for span started and span ended logs. Tool/function spans should include the generation or agent span ID as parentId in TypeScript or parent_id in Python.