---
type: email
from: Hassan Abu Alhaj <notifications@github.com>
subject: [openai/openai-agents-python] Add opt-in cost tracking for LiteLLM

 models (PR #1832)
received: 2026-03-06 07:47:32
date_header: Tue, 30 Sep 2025 05:50:08 -0700
priority: normal
status: awaiting_approval
uid: 31629
---

## Email Content

**From:** Hassan Abu Alhaj <notifications@github.com>
**Subject:** [openai/openai-agents-python] Add opt-in cost tracking for LiteLLM

 models (PR #1832)
**Date:** Tue, 30 Sep 2025 05:50:08 -0700

### Body (preview)

Resolves #1831



Adds cost tracking for LiteLLM models when users enable it via `ModelSettings(track_cost=True)`.



**Changes**

- Added `cost` field to `Usage` class

- Added `track_cost` setting to `ModelSettings`. Opt-in (defaults to `False`)

- LiteLLM cost extraction:

  - Non-streaming: reads from `_hidden_params[&quot;response_cost&quot;]`

  - Streaming: calculates via `litellm.completion_cost()`

  - Includes cached &amp; reasoning tokens for accurate pricing



You can view, comment on, or merge this pull request online at:



  https://github.com/openai/openai-agents-python/pull/1832



-- Commit Summary --



  * add litellm cost tracking feature to Usage objects through `track_cost` model setting



-- File Changes --



    M src/agents/extensions/models/litellm_model.py (71)

    M src/agents/model_settings.py (6)

    M src/agents/run.py (4)

    M src/agents/usage.py (8)

    M tests/test_usage.py (49)



-- Patch Links --



https://github.com/openai/openai-agents-python/pull/1832.patch

https://github.com/openai/openai-agents-python/pull/1832.diff



-- 

Reply to this email directly or view it on GitHub:

https://github.com/openai/openai-agents-python/pull/1832

You are receiving this because you are subscribed to this thread.



Message ID: &lt;openai/openai-agents-python/pull/1832@github.com&gt;

---

## Suggested Actions
- [ ] Reply
- [ ] Archive
- [ ] Escalate
