docs: fix streaming example in README (#16461)

* docs: add messages variable definition in streaming example

- Add missing messages variable in streaming code example
- Makes the example complete and runnable without modifications

* docs: capitalize LiteLLM in streaming section

* docs: add gpt-4o comment
This commit is contained in:
Cesar Garcia 2025-11-10 22:16:17 -03:00 committed by GitHub
parent 3289038089
commit 656dce92d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -132,11 +132,15 @@ print(response)
## Streaming ([Docs](https://docs.litellm.ai/docs/completion/stream))
liteLLM supports streaming the model response back, pass `stream=True` to get a streaming iterator in response.
LiteLLM supports streaming the model response back, pass `stream=True` to get a streaming iterator in response.
Streaming is supported for all models (Bedrock, Huggingface, TogetherAI, Azure, OpenAI, etc.)
```python
from litellm import completion
messages = [{"content": "Hello, how are you?", "role": "user"}]
# gpt-4o
response = completion(model="openai/gpt-4o", messages=messages, stream=True)
for part in response:
print(part.choices[0].delta.content or "")