#openai.error.InvalidRequestError Billing hard limit has been reached

43 messages · Page 1 of 1 (latest)

analog ledge
#

im getting this error but i havent made any requests yet

#

im using the example code provided

vocal wave
#

Go to settings -> usage -> usage limits and see what your limit has been set at, and increase it if necessary

analog ledge
#

its not used at all, maybe something in the example is outdated?

#
response = openai.Image.create(
    prompt="a white siamese cat",
    n=1,
    size="1024x1024"
)
#

api key is correct too

vocal wave
#

Check what your hard limit is set to

#

There’s another page that shows you your hard limit

#

In settings somewhere

#

I’ll send a screenshot when I get home

analog ledge
#

its set to default 120$

vocal wave
#

oh interesting

analog ledge
#

the limits seem cool, some people mention they needed to set an engine name correctly in some cases

vocal wave
#

Not sure why you’re getting that error, have you double checked that it’s the correct API key and not for a different account?

#

Nah you don’t need an engine name for image

#

Let me check how I send my image request real quick, brb

analog ledge
#

this is the full error trace

Traceback (most recent call last):
  File "c:\Users\User\Desktop\point-e\point_e\examples\dalle2api.py", line 6, in <module>
    response = openai.Image.create(
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_resources\image.py", line 22, in create
    return instance.request("post", cls._get_url("generations"), params)
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\openai_object.py", line 179, in request
    response, stream, api_key = requestor.request(
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_requestor.py", line 181, in request
    resp, got_stream = self._interpret_response(result, stream)
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_requestor.py", line 396, in _interpret_response
    self._interpret_response_line(
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_requestor.py", line 429, in _interpret_response_line
    raise self.handle_error_response(
openai.error.InvalidRequestError: Billing hard limit has been reached
vocal wave
#

I am sending the request the same as you and it seems to work

#

I’d say triple check the API key

analog ledge
#

this is the full code

import openai

openai.api_key = "sk-xxx"

response = openai.Image.create(
    prompt="a white siamese cat",
    n=1,
    size="1024x1024"
)

image_url = response['data'][0]['url']
#

api key just created

vocal wave
#

Yeah that looks good to me

#

hmm

analog ledge
#

maybe im missing async before the function?

vocal wave
#

nah the library isn’t actually async so no worries about that

analog ledge
#

hmm maybe its python version?

#

im on 3.9.smth

vocal wave
#

I’m also on 3.9

#

I’ll take a look at the library source later tonight and see if I can find anything else that may be giving u that error even tho you haven’t hit billing limit

analog ledge
#

ok just run it and it worked

vocal wave
#

oh lol

#

haha

analog ledge
#

i didnt change anything, maybe its a server bug lol

vocal wave
#

Yeah has to be

analog ledge
#

just one thing, whats the command to save the image to a file?

vocal wave
#

Sometimes invalid request is returned when overloaded

#

Uhhh you have to open the URL and read the image data from it, then write to a file

#

You can see code in the GitHub link I sent

#

Near the same location further down

analog ledge
#

awesome thanks mate! have a good holiday