-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Labels
Description
Problem:
When using LiteLLM models, there's no way to track how much each request costs. LiteLLM provides this info via _hidden_params["response_cost"]
and their completion_cost()
function, but the SDK doesn't expose it.
Proposed Solution:
Add opt-in cost tracking via ModelSettings
that populates usage.cost
with cost estimates from LiteLLM.
Usage:
agent = Agent(
model=LitellmModel(model="...", api_key="..."),
model_settings=ModelSettings(
include_usage=True,
track_cost=True, # opt-in
),
)
result = await Runner.run(agent, "Hello")
print(f"Cost: ${result.context_wrapper.usage.cost}")