Skip to content

Commit 314eb46

Browse files
authored
Apply suggestions from code review
1 parent 08e50cf commit 314eb46

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

docs/usage.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Usage
2+
13
The Agents SDK automatically tracks token usage for every run. You can access it from the run context and use it to monitor costs, enforce limits, or record analytics.
24

35
## What is tracked

examples/basic/usage_tracking.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from pydantic import BaseModel
44

5-
from agents import Agent, Runner, function_tool
5+
from agents import Agent, Runner, Usage, function_tool
66

77

88
class Weather(BaseModel):
@@ -17,7 +17,7 @@ def get_weather(city: str) -> Weather:
1717
return Weather(city=city, temperature_range="14-20C", conditions="Sunny with wind.")
1818

1919

20-
def print_usage(usage) -> None:
20+
def print_usage(usage: Usage) -> None:
2121
print("\n=== Usage ===")
2222
print(f"Requests: {usage.requests}")
2323
print(f"Input tokens: {usage.input_tokens}")
@@ -44,4 +44,3 @@ async def main() -> None:
4444
if __name__ == "__main__":
4545
asyncio.run(main())
4646

47-

0 commit comments

Comments
 (0)