ezzcodeezzlife / dalle2-in-python

Use DALL·E 2 in Python
https://pypi.org/project/dalle2/
MIT License
178 stars 34 forks source link

Add support for user information API calls #9

Open charlesjlee opened 1 year ago

charlesjlee commented 1 year ago

It would be nice to be able to get some user information -- specifically how many tokens are left in the user's account.

ezzcodeezzlife commented 1 year ago

Did you find API endpoints for this? (i was looking for the same thing with openais gpt3 api, but found nothing)

charlesjlee commented 1 year ago

I just created this as a placeholder. I didn't try doing it 😆

kv-crosstech commented 1 year ago
import requests

auth_header = "Bearer sess-......."

ret = requests.get(
    "https://labs.openai.com/api/labs/billing/credit_summary",
    headers={"Authorization": auth_header},
)
print(ret.json())

returns {'aggregate_credits': 545, 'next_grant_ts': 1661754850, 'breakdown': {'free': 0, 'paid_dalle_15_115': 545}, 'object': 'credit_summary'}

ezzcodeezzlife commented 1 year ago

I will add this asap 🔥