Install
Add the callback
model now logs its input, output, model name, latency, and token counts to the support-bot task. You keep the model you already use. Apprentice observes, it does not choose your model.
It cannot break your app
The capture path is fail-open by contract. If the Apprentice backend is slow, down, or unreachable, your LLM call still returns and your app is unaffected. The only loss is that one trace. Do not wrap the callback in atry/except to protect your app, it is already safe.
Captured traces arrive as raw rows: live, unverified. Verify them to gold, or upload curated rows as silver, before you rely on them for optimization.
RAG: the retrieved context is captured
For a standard LangChain RAG chain, the callback records the retrieved context alongside the question, so the dataset holds the exact context the model saw:client.capture directly and pass the context yourself.
Redact before anything leaves your process
If your inputs contain sensitive data, pass aredact function. It runs in your process, before the trace is sent: