Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get cost for an agent #323

Open
bhavik-dand opened this issue Mar 24, 2025 · 5 comments
Open

Get cost for an agent #323

bhavik-dand opened this issue Mar 24, 2025 · 5 comments
Labels
question Question about using the SDK

Comments

@bhavik-dand
Copy link

Can we get cost information as part for every .run call?

@bhavik-dand bhavik-dand added the question Question about using the SDK label Mar 24, 2025
@rm-openai
Copy link
Collaborator

This generally isn't part of most model providers SDKs. Would it make sense for you to use the usage information to calculate it? Maybe there's some library that can help with it?

@bhavik-dand
Copy link
Author

Yes it would be helpgul to track cost. I use this functionality provided by litellm currently in my app.

llm_cost = completion_cost(completion_response=response)
It would be great if we can some more data like total_token_usage, input_tokens and output_tokens as well.

@rm-openai
Copy link
Collaborator

Yeah thats available here: https://openai.github.io/openai-agents-python/ref/result/#agents.result.RunResultBase.raw_responses

So you can use the usage data to compute cost

@lbug
Copy link

lbug commented Mar 25, 2025

Wouldn't that be an issue for the reasoning models like o3-mini and o1 because the CoT is not part of the raw response?

@rm-openai
Copy link
Collaborator

rm-openai commented Mar 25, 2025

No, the reported tokens includes reasoning tokens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about using the SDK
Projects
None yet
Development

No branches or pull requests

3 participants