From abc03d1e7b8dd1d7fd9968784a382a849613870f Mon Sep 17 00:00:00 2001 From: Saumyaranjan Nayak <107764221+Sdnsoumy@users.noreply.github.com> Date: Fri, 10 Jul 2026 21:55:57 +0530 Subject: [PATCH] docs: expand include_cost_in_streaming_usage with examples and test links --- docs/include_cost_in_streaming_usage.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/include_cost_in_streaming_usage.md b/docs/include_cost_in_streaming_usage.md index f9b246002df..aee78ba1d30 100644 --- a/docs/include_cost_in_streaming_usage.md +++ b/docs/include_cost_in_streaming_usage.md @@ -47,6 +47,24 @@ Example final stream chunk (simplified): } ``` +Quick curl example (streaming, requesting usage) + +```bash +curl -N -X POST "http://localhost:4000/v1/chat/completions" \ + -H "Authorization: Bearer sk-xxx" \ + -H "Content-Type: application/json" \ + -d '{ + "model": "gpt-4o-mini", + "messages": [{"role":"user","content":"Say hi"}], + "stream": true, + "stream_options": {"include_usage": true} + }' +``` + +Notes for reviewers and tests +- See streaming tests that exercise this flow for examples and expected shapes: [tests/local_testing/test_streaming.py](tests/local_testing/test_streaming.py) and [tests/test_litellm/proxy/response_api_endpoints/test_endpoints.py](tests/test_litellm/proxy/response_api_endpoints/test_endpoints.py). +- The implementation reads the same `usage` shape used for non-streaming responses and injects it into the last chunk; reviewers should ensure the example aligns with the live site formatting. + Where to contribute - The public docs site (`litellm-docs`) hosts user-facing documentation. Add this snippet to the cost-tracking or streaming usage page in `litellm-docs` and link back to the `x-litellm-response-cost` docs if relevant.