File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Required parameters:
4+ # @raycast.schemaVersion 1
5+ # @raycast.title Check Usage of OpenAI API
6+ # @raycast.mode inline
7+ # @raycast.packageName System
8+
9+ #
10+ # Optional parameters:
11+ # @raycast.icon 💲
12+ #
13+ # Documentation:
14+ # @raycast.description Get total usage of OpenAI API
15+ # @raycast.author nagauta
16+ # @raycast.authorURL https://github.com/nagauta
17+
18+ _ORGANIZATION=" "
19+ _OPENAI_APIKEY=" "
20+
21+ _START_DATE=" $( date -u +' %Y-%m' ) -01"
22+ _END_DATE=" $( date -u -v+1m +' %Y-%m' ) -01"
23+ echo
24+ TOTAL_USAGE=$( curl -sSf " https://api.openai.com/dashboard/billing/usage?end_date=${_END_DATE} &start_date=${_START_DATE} " \
25+ -H " authorization: Bearer ${_OPENAI_APIKEY} " \
26+ | jq -r ' "$" + (.total_usage | round / 100 | tostring)' )
27+
28+ echo " Total Usage: ${TOTAL_USAGE} , Period: ${_START_DATE} -${_END_DATE} "
You can’t perform that action at this time.
0 commit comments