GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • instructor
  • Introduction
  • Learning
  • Integrations
  • Cookbook
  • Concepts
  • Prompt Engineering
  • CLI Reference
  • Find Jobs (External)
  • Blog
  • Finetuning GPT-3.5
  • Usage Tracking
  • Batch Jobs

This view

  • Original page
  • New address

GeezerVison is showing python.useinstructor.com — OpenAI API Usage CLI Guide - Instructor

Using the OpenAI API Usage CLI¶

The OpenAI API Usage CLI tool provides functionalities for monitoring your OpenAI API usage, breaking it down by model, date, and cost.

Legacy estimates

This command uses a legacy OpenAI usage endpoint and a static model-price table. It does not reconcile invoices or account for current cache, tool, modality, batch, or service-tier pricing. Model-prefix fallback can also apply the wrong rate to newer model variants. An empty result does not establish zero usage. Use provider billing records for financial reporting.

Monitoring API Usage¶

View Usage Options¶

$ instructor usage --help

 Usage: instructor usage [OPTIONS] COMMAND [ARGS]...

 Check OpenAI API usage data

╭─ Options ───────────────────────────────────────────────────────╮
│ --help          Show this message and exit.                     │
╰─────────────────────────────────────────────────────────────────╯
╭─ Commands ──────────────────────────────────────────────────────╮
│ list       Displays OpenAI API usage data for the past N days.  │
╰─────────────────────────────────────────────────────────────────╯

List Usage for Specific Number of Days¶

To display API usage for the past 3 days, use the following command:

$ instructor usage list --n 3

This will output a table similar to:

                 Usage Summary by Date, Snapshot, and Cost
┏━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ Date       ┃ Snapshot ID               ┃ Total Requests ┃ Total Cost ($) ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
│ 2023-09-04 │ gpt-5.4-mini                │             44 │           0.68 │
│ 2023-09-04 │ gpt-5.4-mini    │            195 │           0.84 │
│ 2023-09-04 │ text-embedding-ada-002-v2 │            276 │           0.00 │
│ 2023-09-04 │ gpt-4-32k-0613            │            328 │          49.45 │
└────────────┴───────────────────────────┴────────────────┴────────────────┘

List Usage for Today¶

To display the API usage for today, simply run:

$ instructor usage list

Contributions¶

We aim to provide a light wrapper around the API rather than offering a complete CLI. Contributions are welcome! Please feel free to make an issue at jxnl/instructor/issues or submit a pull request.

Was this page helpful?
Thanks for your feedback!
Thanks for your feedback! Help us improve this page by using our feedback form.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.