opik icon indicating copy to clipboard operation
opik copied to clipboard

[Bug]: ValueError: Failed to build OpikUsage for provider openai and usage {'completion_tokens': 117, 'prompt_tokens': 1630, 'total_tokens': 1747, 'completion_tokens_details': None, 'prompt_tokens_details': None}

Open Samwellwang opened this issue 3 months ago • 1 comments

What component(s) are affected?

  • [x] Opik Python SDK
  • [ ] Opik Typescript SDK
  • [ ] Opik Agent Optimizer SDK
  • [ ] Opik UI
  • [ ] Opik Server
  • [ ] Documentation

Opik version

  • Opik version: 1.8.46

Describe the problem

opik python sdk with : with track_openai(OpenAI(base_url=host_llm,api_key="none")) as client:

Reproduction steps and code snippets

No response

Error logs or stack trace

No response

Healthcheck results

No response

Samwellwang avatar Sep 25 '25 11:09 Samwellwang

Hi — thanks for opening this issue!

Before we dig deeper, could you help us narrow down what’s happening? A few clarifying questions:

  • Does this error occur every time you call track_openai(...) / use the OpikUsage functionality, or is it intermittent / under certain conditions?
  • Can you share a minimal reproducible example (i.e. the smallest snippet of code) that reliably triggers this ValueError?
  • Which version(s) of Python, opik, and any related dependencies are you using?
  • Do you see a full stack trace or error log (beyond the message “Failed to build OpikUsage …”) that could point to where it fails internally?
  • Have you ever had this functionality working correctly (i.e. in a previous version or environment)? If so, what changed (library upgrade, config changes, etc.)?

With those details, we’ll be in a much better position to diagnose what’s going wrong and propose a fix

idoberko2 avatar Sep 29 '25 12:09 idoberko2