I trying to access gpt-4o from Python code, and using the sample code below to test it:
from openai import OpenAI
MODEL = "gpt-4o"
client = OpenAI(api_key="XXXXXXXXXXXX")
# Basic Chat
completion = client.chat.completions.create(
model = MODEL,
messages=[
{"role":"system", "content":"You are a helpful assistant. Help me with my math homework"},
{"role":"user", "content":"Hello! Can you solve 9+11?"}
]
)
print(f"Assistant: {completion.choices[0].message.content}")
At the end I am getting
Error code: 404 - {'error': {'message': 'The model `gpt-4o` does not exist or you do not have access to it.', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}
My question is, although it is announced it is going to be free to access GPT-4o, does it cover all sorts of access or only via the browser on the chat window?
I tested your code and it works fine on my end. Please check the permissions of your API key to ensure it has access to the GPT-4o model.
Thanks @tiansenxu , just to confirm, you are also on free tier (never made any credit top up or so) ?
Youâre welcome. I am using a paid account. Regarding your question, the free access might be for specific users, such as new registrants. Although Iâm not entirely sure, I recall that new users often receive some free credits or access privileges.ă
I have exactly the same problem - have enough credits and code was working before with v3.5
+updated to the latest python openai package version, didnât solve the problem
I am using paid account and generated my api_key just today.
When I checked my project api keys permissions I can see âAllâ
openai.NotFoundError: Error code: 404 - {âerrorâ: {âmessageâ: âThe model gpt-4o
does not exist or you do not have access to it.â, âtypeâ: âinvalid_request_errorâ, âparamâ: None, âcodeâ: âmodel_not_foundâ}}
python code is just similar:
from openai import OpenAI
model=âgpt-4oâ
client = OpenAI(api_key=âsk-proj-gC6fUxxxxxxxxxxxâ)
completion = client.chat.completions.create(
model=model,
messages=[
{âroleâ:âsystemâ,
âcontentâ: âYou are a helpful assitance. He me to solve my math homework!â},
{ "role":"user",
"content": "Hello! could you solve 2+2 for me?"}
]
)
print("Assitant: "+ completion.choices[0].message.content)
You might need to wait until you hit billing Tier 1 or Tier 2⌠Iâd check the docs.
1 Like
Thanks @PaulBellow
After checking the tiers and limits page, it seems like the case for me.
@PaulBellow where can I check my limit ⌠what should to do hit billing tier 1 or tier2? which docs are you referring . apart from being gptplus user should I need toapy additionally to access apis? thx
I hope you have created a project and then, API key.
Follow these steps :
- Login to your OpenAI account
- go to settings option (available on upper right corner)
- under project tab( available in the left pane), go to Limits option
- after clicking Limits, youâll find the Allowed models in Model usage. just click edit button, and add the model you want to use through API.