New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

openai-billing

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openai-billing

fetch openai billing

latest
Source
npmnpm
Version
2.1.0
Version published
Maintainers
1
Created
Source

查询 openai 余额

Install

npm i openai-billing

Usage

import { fetchBilling } from "openai-billing"

// for CommonJS
// const { fetchBilling } = require("openai-billing")

const apikey = 'YOUR OPENAI KEY'
const result = await fetchBilling(apikey, { baseURL: 'https://api.openai.com' })

if (result.error) {
    const { code, message } = result.error
    console.error(`Error: ${code} - ${message}`)
}
else {
    const { total, used, remain, expiresTime } = result
    console.log(`
额度总量: 💵 $ ${total}
已用额度: 💵 $ ${used}
剩余额度: 💵 $ ${remain}
过期时间:🪫  ${new Date(expiresTime).toLocaleDateString()}
    `)
}

Use in browser

<script src="https://cdn.jsdelivr.net/npm/openai-billing@2">
const apikey = 'YOUR OPENAI KEY'
const result = await OpenaiBilling.fetchBilling(apikey, { baseURL: 'https://api.openai.com' })

// ...

Keywords

openai

FAQs

Package last updated on 03 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts