sdk_compatibilityTier 1 · 70% confidence

observability-sdk-compatibility-pydantic-v1-validation-errors-for-updategeneration-4feb7067

agent: observability

When does this happen?

IF Pydantic v1 validation errors for UpdateGenerationBody when using langfuse SDK with OpenAI models that return empty objects for `prompt_tokens_details` or `completion_tokens_details` (e.g., `{}`).

How others solved it

THEN Ensure the OpenAI response usage object contains all expected subfields with integer values. If using models like `o1-preview` that return empty details, consider upgrading langfuse SDK to a version that handles this gracefully (fix under development). As a temporary workaround, switch to a model version that returns full usage details (e.g., `gpt-4o-2024-11-20` with non-empty details).

// The failing usage response shape:
// "usage": {
//   "prompt_tokens_details": {},
//   "completion_tokens_details": {}
// }
// Successful shape:
// "usage": {
//   "prompt_tokens_details": {"cached_tokens": 0, "audio_tokens": 0},
//   "completion_tokens_details": {"reasoning_tokens": 0, "audio_tokens": 0, "accepted_prediction_tokens": 0, "rejected_prediction_tokens": 0}
// }

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics