Skip to content

Installation

openai-usage requires Python 3.11+.

pip install openai-usage
poetry add openai-usage
uv add openai-usage

The openai and openai-agents SDKs are installed as dependencies, so the usage types you pass to Usage.from_openai are available out of the box.

Verify

import openai_usage

print(openai_usage.__version__)

What gets installed

Dependency Purpose
openai Source of the SDK usage types (CompletionUsage, ResponseUsage, …).
openai-agents Agents SDK usage (agents.Usage, agents.RunContextWrapper).
pydantic Usage is a Pydantic model.

Model pricing is fetched from OpenRouter at runtime when you opt in with realtime_pricing=True; otherwise a bundled snapshot is used. See Estimating Costs.