Getting this error while trying to run a prompt


response = openai.Completion.create(
            model="gpt-4",  # or another GPT-4 model name if updated
            prompt="Hi How are you?",
            max_tokens=50  # Adjust based on how much completion you expect

Error Message:

An error occurred: This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions?

If that’s the case what code should be used?

Hi @DavidOS366

The model gpt-4 can only be accessed on chat completions endpoint.

Additionally the text completion endpoint has been deprecated.

I have an AI to answer this kind of question also…

from openai import OpenAI

def get_chat_completion():
    Fetch a chat completion using the latest method from OpenAI's API.

        None: Prints the chat completion response.
    # Initialize the OpenAI client
    client = OpenAI()

    # Create a chat completion with specific messages
    completion =
        model="gpt-4",  # Specify the model, use the latest version available
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "Hi How are you?!"}

    # Accessing the first message in the response and printing it

# Example usage

New error:

ImportError: cannot import name ‘OpenAI’ from ‘openai’

openai is there, because other prompt is working. That is going to dall-e-3 model.

You must update the openai module that you have installed if you want to follow along with any API reference documentation that you will find in the sidebar of the forum.

In your OS, using an administrator/root account if Python is a system-wide installation:

pip install --upgrade openai

0.28.1 was the last version to support the methods you demonstrate (and that a normal AI might answer about because of its old knowledge).

Then you can use the “client” method as shown.

1 Like

This worked

def detect_human_written_text(prompt_text):
    client = OpenAI(api_key = 'dasdasdadasdasddadsadasdadsasdsa')
        response =
        model="gpt-4",  # Specify the model, use the latest version available
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": prompt_text}
        return response.choices[0].message.content.strip()
    except Exception as e:
        print("An error occurred:", e)
        return None

Although I wrote a prompt for detection of whether written by human or AI, are there models for that already?

UH OH! is the prompt too tight? That is totally written by Human.

prompt : Is the following text written by a human? Respond with ‘True’ if it is written by a human, otherwise respond with ‘False’. : 56454315613.21312215512.1231561561231223.1532156235165454

output: False

There is no reliable detection of AI-written text. Certainly not just by asking “did you write this?” to an AI.

OpenAI models have even had what are called “echo logprobs” disabled so that one couldn’t run statistical analysis on the perplexity of an input.

You can see how much an AI wants to improve language by “proofread this text and correct any errors”. Most botspam posted to this forum has no suggestions by the AI because it was already written by an AI. That is also going to be a land of foibles and career-ending disgrace.

I was thinking of building a replacement of the reCaptcha system that prevents website from bots. I thought why not use AI to detect whether a given input is written by a human or not, that in theory should serve the purpose. Looks like it cant.

1 Like