Url `'https://api.openai.com/v1/completions' does not exist

Getting this error when utilizing a library for completions, this URL is correct according to the docs so what is going on?

image

Welcome to the forum!

I think you might be trying to use ChatCompletions API calls with Completions enpoints, can you post your API calling code please.

1 Like

The URL does exist and responds.

It seems the error message includes two single-quotes - have you manually specified the URL in a way that is different than the module needs or uses by default?

Were one using the wrong endpoint for the model, you’d instead get a return message like: “OpenAI API request was invalid: This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions?” when you have proper error handling, such as a case “except openai.error.InvalidRequestError as e:” for the openai python library.

1 Like

dear, my code is
def text_generaton_with_black_box_LLMs(prompt,tem):
res=openai.ChatCompletion.create(model=‘gpt-3.5-turbo’,
messages=[
{‘role’: ‘user’, ‘content’: prompt}],
max_tokens=150,
temperature=tem,
)
return res
and I got the error: Traceback (most recent call last):
File “main.py”, line 52, in
response = text_generaton_with_black_box_LLMs(prompt,0.5)
File “main.py”, line 8, in text_generaton_with_black_box_LLMs
res=openai.ChatCompletion.create(model=‘gpt-3.5-turbo’,
File “/root/miniconda3/lib/python3.8/site-packages/openai/api_resources/chat_completion.py”, line 25, in create
return super().create(*args, **kwargs)
File “/root/miniconda3/lib/python3.8/site-packages/openai/api_resources/abstract/engine_api_resource.py”, line 153, in create
response, _, api_key = requestor.request(
File “/root/miniconda3/lib/python3.8/site-packages/openai/api_requestor.py”, line 220, in request
result = self.request_raw(
File “/root/miniconda3/lib/python3.8/site-packages/openai/api_requestor.py”, line 533, in request_raw
raise error.APIConnectionError(
openai.error.APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool (host=‘api \dot openai \dot com’, port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ProxyError(‘Cannot connect to proxy.’, NewConnectionError(‘<urllib3.connection.HTTPSConnection object at 0x7f5edde688b0>: Failed to establish a new connection: [Errno 111] Connection refused’)))
can you give me some ideas to solve it? :joy: