openai-php / client

⚡️ OpenAI PHP is a supercharged community-maintained PHP API client that allows you to interact with OpenAI API.
MIT License
4.99k stars 523 forks source link

fix: add missing properties (specially `cached_usage`) to chat `CreateResponseUsage` #494

Closed IsraelOrtuno closed 2 weeks ago

IsraelOrtuno commented 3 weeks ago

What:

Description:

Chat CreateResponseUsage object is omitting some properties which have probably been have added in more modern versions of the API which are related to the tokens usage. I think cached_usage is specially important (two issues were already requesting this) as this would help users track if their prompts are being cached properly and could directly contribute to save money.

Check the usage property for reference: https://platform.openai.com/docs/api-reference/chat/object

Related:

Fixes #486 #492

gehrisandro commented 2 weeks ago

Thanks, @IsraelOrtuno for this PR! 🚀