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
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
)
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!