Bad Gateway text-davinci-002

Hi all,
I was running the text-davinci-002 using the command
response = openai.Completion.create(model='text-davinci-002', prompt=batch['prompt_text'], max_tokens=1024)

but I got the following error:

Traceback (most recent call last):
  File "/user/anaconda3/envs/t5_baseline/lib/python3.8/site-packages/openai/", line 419, in _interpret_response_line
    data = json.loads(rbody)
  File "/user/anaconda3/envs/t5_baseline/lib/python3.8/json/", line 357, in loads
    return _default_decoder.decode(s)
  File "/user/anaconda3/envs/t5_baseline/lib/python3.8/json/", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/user/anaconda3/envs/t5_baseline/lib/python3.8/json/", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 76, in <module>
  File "", line 38, in generate_context
    response = openai.Completion.create(model=args.model_name, prompt=batch['text'],  max_tokens=1024)
  File "/user/anaconda3/envs/t5_baseline/lib/python3.8/site-packages/openai/api_resources/", line 25, in create
    return super().create(*args, **kwargs)
  File "/user/anaconda3/envs/t5_baseline/lib/python3.8/site-packages/openai/api_resources/abstract/", line 115, in create
    response, _, api_key = requestor.request(
  File "/user/anaconda3/envs/t5_baseline/lib/python3.8/site-packages/openai/", line 181, in request
    resp, got_stream = self._interpret_response(result, stream)
  File "/user/anaconda3/envs/t5_baseline/lib/python3.8/site-packages/openai/", line 396, in _interpret_response
  File "/user/anaconda3/envs/t5_baseline/lib/python3.8/site-packages/openai/", line 421, in _interpret_response_line
    raise error.APIError(
openai.error.APIError: HTTP code 502 from API (<html>
<head><title>502 Bad Gateway</title></head>
<center><h1>502 Bad Gateway</h1></center>

This occurred at 2300th prompt example in the dataset. I had ~8000 more such prompt examples remaining but now I have to run this from scratch again. Is this something that is bound to happen often or is there anything that I should do to avoid this?

1 Like