Skip to content

How can I correctly count the usage of each API Key? #230

@peiyun1982

Description

@peiyun1982

Describe the feature or improvement you're requesting

I hope to count the usage consumption of several API Keys under my OpenAI account.
On the help page, I saw this introduction.
无标题
I tried to enter this command in python:
import openai
openai.api_key = "sk-vaU0ES******fhvr"
usages = openai.usage.list()
for usage in usages.data:
print(f"Key: {usage.key}")
print(f"Total requests: {usage.total_requests}")
print(f"Total cost: {usage.total_cost}")

But I got the prompt

AttributeError: module 'openai' has no attribute 'usage'

How can I correctly count the usage of each API Key?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions