Closed Jafo232 closed 1 year ago
I submitted this PR that would make this work.
You can now use the latest release which gives you access to the header / meta information on every response: https://github.com/openai-php/client#meta-information
You can now use the latest release which gives you access to the header / meta information on every response: https://github.com/openai-php/client#meta-information
I have the same problem. I've tried to use the meta information but it doesn't give information about usage (eg. promptTokens
, completionTokens
, totalTokens
).
But this doesn't tell you how many input/output tokens were used unless I am missing something..
But this doesn't tell you how many input/output tokens were used unless I am missing something..
I just found out that this is due to an OpenAI API limitation, not to the PHP implementation. Source: https://cookbook.openai.com/examples/how_to_stream_completions#downsides
_Another small drawback of streaming responses is that the response no longer includes the usage field to tell you how many tokens were consumed. After receiving and combining all of the responses, you can calculate this yourself using tiktoken._
Consider:
How do I get access to the tokens used after all of this is done? The response property is private.