Repository navigation
Streamed chat completions report no token usage unless you ask (stream_options) #4370
virajrakholiya
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
A small one that can make your cost numbers wrong for weeks.
A non-streamed
chat.completions.createreturnsusage. A streamed one does not, unless you ask for it:Three details worth knowing:
[DONE], and that chunk'schoicesis an empty list. Code that readschunk.choices[0]on every chunk raisesIndexErroron exactly that chunk.usage=None, so check before reading it.Chat UIs are mostly streamed. Without
include_usage, a token dashboard only counts the calls that weren't.Question: for interrupted streams, does anyone estimate output tokens from the text received so far, or just flag the call?
Disclosure: I'm building Relia, which records each call made with the
openaipackage (model, tokens, estimated cost from public list prices, duration, failures, streamed answers included) next to the request that made it. https://tryrelia.com/r/virajAll reactions