Skip to content

API Key 余额信息查询 #79

Description

@Ai-Yolo

目前通过接口可以查询到部分Key信息,而无需对话请求。
可以在后台对Key测试后记录并显示当前查询到的信息。

以下是从代码中提取出的OpenAI官方API接口:

https://api.openai.com/dashboard/billing/subscription
用于获取OpenAI订阅信息的API接口。调用方式和官方其他API一样,该接口需要在请求的Authorization标头中包含密钥。

https://api.openai.com/dashboard/billing/usage
用于获取OpenAI使用情况的API接口。该接口也需要在请求的Authorization标头中包含密钥。
此外,还需要在URL的查询参数中提供起始日期和结束日期,以指定要获取的使用情况的时间范围(例如最近两个月)

formatDate := func(d time.Time) string {
			return fmt.Sprintf("%d-%02d-%02d", d.Year(), d.Month(), d.Day())
		}
		startDate := formatDate(time.Now().AddDate(0, -1, 0))
		endDate := formatDate(time.Now().AddDate(0, 1, 0))
		usageURL := fmt.Sprintf("https://api.openai.com/dashboard/billing/usage?start_date=%s&end_date=%s", startDate, endDate)

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already existsenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions