Does not have access to model `gpt-4o`

Hi there,

I’m trying to use gpt-4o by API and i’m always getting this:

{
    "error": {
        "message": "Project `X` does not have access to model `gpt-4o`",
        "type": "invalid_request_error",
        "param": null,
        "code": "model_not_found"
    }
}

I have 5.99$ credit balance, i have set the usage to allow gpt-4o, and i still get the error, on postman and on vb .net

Can anyone help?

thanks in advance

Welcome @CipKroell

Make sure that:

  1. gpt-4o model shows up in the list when you make a list models api call with the project API key
  2. Your project api key has Model Capabilities scope enabled
    The image shows a list of technical capabilities for a model, which includes audio, chat completions, embeddings, images, and moderations, likely indicating the services provided by an API or software platform. (Captioned by AI)
  3. On the limits page for the project, the Model Usage is appropriately configured.

Thanks sps,
Now it works on postman but not on vb .net,

i’m using the code provided by postman, but it returns:
The response status code does not indicate success: 400 (Bad Request).

Here is the code:

Dim client As New HttpClient With {
    .Timeout = TimeSpan.FromSeconds(15)
}

Dim request As New HttpRequestMessage(HttpMethod.Post, "https://api.openai.com/v1/chat/completions")
request.Headers.Add("Authorization", $"Bearer {apiKey}")

Dim RequestContent As String = $"{{""model"": ""gpt-4o"",""messages"": [{{""role"": ""user"",""content"": ""{Prompt}""}}]}}"
Dim content As New StringContent(requestContent, Nothing, "application/json")
request.Content = content

Dim response As HttpResponseMessage = client.SendAsync(request).Result
response.EnsureSuccessStatusCode()

Dim settings As New JsonSerializerSettings()
settings.Converters.Add(New VbNewLineConverter())

Dim ResponseString As String = response.Content.ReadAsStringAsync().Result
Dim SerializedResponse As Response = JsonConvert.DeserializeObject(Of Response)(ResponseString, settings)

Return New AIResponse(
    Prompt,
    SerializedResponse.choices(0).message.content,
    SerializedResponse.usage.prompt_tokens,
    SerializedResponse.usage.completion_tokens,
    ResponseString
    )

Can you share the complete response status text?

1 Like

I have the answer now, the problem is not the code but the prompt by it self, i was sending a “VbLf” at the end of the prompt(a \n in c# for exemple) and for some reason the API doesn’t like it!

trimming it solved the problem!

Thanks @sps for your help!

1 Like