mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
(docs) calculate cost for streaming responses
This commit is contained in:
parent
0a83d1a924
commit
d59491f704
1 changed files with 4 additions and 1 deletions
|
|
@ -350,7 +350,10 @@ Cost for completion call with gpt-3.5-turbo: $0.0000775000
|
|||
```
|
||||
|
||||
### Track Costs, Usage, Latency for streaming
|
||||
Use a callback function for this - more info on custom callbacks: https://docs.litellm.ai/docs/observability/custom_callback
|
||||
We use a custom callback function for this - more info on custom callbacks: https://docs.litellm.ai/docs/observability/custom_callback
|
||||
- We define a callback function to calculate cost `def track_cost_callback()`
|
||||
- In `def track_cost_callback()` we check if the stream is complete - `if "complete_streaming_response" in kwargs`
|
||||
- Use `litellm.completion_cost()` to calculate cost, once the stream is complete
|
||||
|
||||
```python
|
||||
import litellm
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue