InvalidRequestError: The model `gpt-4` does not exist or you do not have access to it

I paid 20 dollars to get access to GPT4 it works in chat.openai but I need to use it in my code and it throws this error “InvalidRequestError: The model gpt-4 does not exist or you do not have access to it” Can anyone help me how to use gpt4?

ChatGPT and the API are two separate products. You need to sign-up for the API.

1 Like

How can I sign up for the API?

Here you go…

Thank you this is just the documentation how can we pay for gpt 4 so that we can use it on our code

Sorry! Is the sign-up button top right not working for you?

It works but what should I do to pay for the GPT4 and have access to it?

You don’t directly pay for gpt-4. You choose “new payment plan”, enter a credit card, and purchase prepaid credits to add to your API account.

Billing overview

Once you’ve done that, and create a new API key, it should be granted gpt-4 as an available model, along with the increased rate limits you get for joining the group “paying customers”.

Thank you for the reply. I don’t have a “new payment plan”. I just have a "new payment method "which asks me to add a credit card. I have already had my credit card and I have access to gpt-3.5-turbo. So I am confused as to why I do not have access to GPT4. I don’t what I need to do to get access to GPT

That’s the language if you already put a credit card into the API interface a while ago and have a monthly billing pay-as-you-go plan. The main billing overview would then have a “cancel payment plan” you don’t want to click without thinking it over:

Thank you. The bad thing is that I do not see any option in the billing section of my account. In the How can I access GPT-4? | OpenAI Help Center , it says “We gave access to the GPT-4 API (8k) to all API users who have made a successful payment of $1 or more”.

I do not know how to spend at least 1$ while I have already put my credit card. In the code, it just throws the error “InvalidRequestError: The model gpt-4 does not exist or you do not have access to it” for this simple function:"
def get_completion_from_messages(messages, model=“gpt-4”, temperature=0):
response = openai.ChatCompletion.create(
model=model,
messages=messages,
temperature=temperature, # this is the degree of randomness of the model’s output
)
return response.choices[0].message[“content”]

At the billing overview link I provided above, you’ll see a button “cancel payment plan” if you are currently in a pay-as-you-go-plan. Then click on your bill history and see if you’ve ever been billed - probably not.

Pressing cancel payment plan will remove the card and the monthly billing. Then you’d likely only be offered the new payment plan button for prepaid credits, that must be purchased before use.