Skip to content

A set of python scripts for querying users in an OpenAI organization, downloading user usage to csv, and plotting cost over time.

License

Notifications You must be signed in to change notification settings

stevenrick/openai_usage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenAI Usage

A set of scripts for querying users in an OpenAI organization, downloading user usage to csv, and plotting cost over time.

External resources: Pandas, Matplotlib

Tested on Mac OS 12.6.7 with Python 3.10.9

To use, create .env file at root with the following information:

  • openai_org_id - can find here - required
  • openai_api_key - API key of a user with owner privileges in the org - required
  • data_dir - path to your data directory - optional
  • finetune_models - list of text strings that are names of any finetune models your organization uses - optional
  • date_range - list of text strings for dates to get usage from in the format of YYYY-MM-DD - optional

After your .env file is setup:

  • Run python openai_usage.py to get the users in your org and then download their data for specified date_range OR yesterday
  • Run python openai_analysis.py to clean up the usage data, attach cost values, and plot per user costs

Credit to this thread for kickstarting the process of exposing the less well documented OpenAI API usage endpoints.

About

A set of python scripts for querying users in an OpenAI organization, downloading user usage to csv, and plotting cost over time.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages