Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: zero usage returned for streaming from text completions api of litellm proxy server #8349

Open
minwhoo opened this issue Feb 7, 2025 · 1 comment · May be fixed by #8419
Open

[Bug]: zero usage returned for streaming from text completions api of litellm proxy server #8349

minwhoo opened this issue Feb 7, 2025 · 1 comment · May be fixed by #8419

Comments

@minwhoo
Copy link

minwhoo commented Feb 7, 2025

What happened?

Token usage information is empty when streaming from completions api of litellm proxy server. Observed on openai/openai-compatible endpoints.
As the screenshot below shows, only the streaming+completions api combination has this issue, while streaming+chat completions work correctly.

Using litellm proxy server v1.60.6

Image

Relevant log output

Are you a ML Ops Team?

No

What LiteLLM version are you on ?

v1.60.6

Twitter / LinkedIn details

No response

@minwhoo minwhoo added the bug Something isn't working label Feb 7, 2025
@minwhoo
Copy link
Author

minwhoo commented Feb 7, 2025

Possible source of bug: the stream_options arg is missing when instantiating TextCompletionStreamWrapper class below.
Adding stream_options=kwargs.get('stream_options'), seems to fix it for my use case.

litellm/litellm/main.py

Lines 3941 to 3950 in 7739be3

return TextCompletionStreamWrapper(
completion_stream=_async_streaming(
response=response,
model=model,
custom_llm_provider=custom_llm_provider,
args=args,
),
model=model,
custom_llm_provider=custom_llm_provider,
)

@krrishdholakia krrishdholakia changed the title [Bug]: zero usage returned for streaming from completions api of litellm proxy server [Bug]: zero usage returned for streaming from text completions api of litellm proxy server Feb 8, 2025
@Kaushikdkrikhanu Kaushikdkrikhanu linked a pull request Feb 9, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants