File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -102,15 +102,18 @@ async function chatReplyProcess(
102102
103103async function fetchBalance ( ) {
104104 const OPENAI_API_KEY = process . env . OPENAI_API_KEY
105+ const OPENAI_API_BASE_URL = process . env . OPENAI_API_BASE_URL
106+
105107 if ( ! isNotEmptyString ( OPENAI_API_KEY ) )
106108 return Promise . resolve ( '-' )
107109
110+ const API_BASE_URL = isNotEmptyString ( OPENAI_API_BASE_URL )
111+ ? OPENAI_API_BASE_URL
112+ : 'https://api.openai.com'
113+
108114 try {
109- const headers = {
110- 'Content-Type' : 'application/json' ,
111- 'Authorization' : `Bearer ${ OPENAI_API_KEY } ` ,
112- }
113- const response = await axios . get ( 'https://api.openai.com/dashboard/billing/credit_grants' , { headers } )
115+ const headers = { 'Content-Type' : 'application/json' , 'Authorization' : `Bearer ${ OPENAI_API_KEY } ` }
116+ const response = await axios . get ( `${ API_BASE_URL } /dashboard/billing/credit_grants` , { headers } )
114117 const balance = response . data . total_available ?? 0
115118 return Promise . resolve ( balance . toFixed ( 3 ) )
116119 }
You can’t perform that action at this time.
0 commit comments