openai-php / client

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

[Bug]: CreateResponseUsage is missing support for Prompt Caching #492

Closed ReSpawN closed 1 week ago

ReSpawN commented 2 weeks ago

Description

\OpenAI\Responses\Chat\CreateResponseUsage doesn't honor the Prompt Caching return which causes confusion that ChatGPT isn't 'activating' Prompt Caching (perhaps due to a unsupportive model).

{"prompt_tokens":1669,"completion_tokens":526,"total_tokens":2195,"prompt_tokens_details":{"cached_tokens":1152},"completion_tokens_details":{"reasoning_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}

Steps To Reproduce

Simply produce a request to chat/completions (chat()->create([])).

OpenAI PHP Client Version

v0.10.2

PHP Version

8.3.10

Notes

No response

gehrisandro commented 1 week ago

Implemented in https://github.com/openai-php/client/pull/494