Hi everyone, I need the different error codes from the API in the json output for a specific code. I have found three of them : “insufficient_quota”,“invalid_api_key”,“string_above_max_length”
I don’t find anywhere all the different error codes .I have seen the http error code (401,403,429,…) but I need these error code from the json output of the API.
If anyone could help, thank you in advance
Not sure I follow what you are asking for, you get returned text for the error, that’s what you check for.
Sorry if I’m not bein clear.
I’m currently developing a project that integrates the OpenAI API, and I’d like to properly handle potential errors in my code. To do this, I need a comprehensive list of all the possible error.code
values that the API might return.
For example, I recently encountered the following error :
{
“error”: {
“message”: “Invalid ‘messages[1].content’: string too long. Expected a string with maximum length 1048576, but got a string with length 1540820 instead.”,
“type”: “invalid_request_error”,
“param”: “messages[1].content”,
“code”: “string_above_max_length”
}
}
Here, the code
field is "string_above_max_length"
.
I need a list or documentation of all potential error codes like this? It would help me write detailed and precise error-handling logic for my app.
I couldn’t find the exhaustive list but this link covers the common API errors. It didn’t contain the error you received so I hope someone from the team responds on this thread too.
Thank you for your response. The API errors are somewhat general, and I was hoping for more detailed information. I’ll make do with this if I do not get any more specific answer. Thanks
The input to the API is validated. This validation is fluid and rarely documented, and the parameters that are used and which could fail are vast and growing.
Who would know that the maximum internal “name” field in a “response format” is 64 characters? The actual API backend would have to be published, and then mapped to the kind of error every validation check could generate, which often reiterate the input, like “the model `gpt-4o-audio-preview’ requires voice modality”, or “the voice ‘sky’ is not valid”.
The error types that the API SDK library can raise are listed in the documentation, a smaller set to map, to determine if retry or fail are appropriate.
The error ‘Invalid request error’ is part of the current documentation.
The link has been posted previously and you can find the reference under ‘Bad request error’ in the section for Python library error types.
It is indicated that the ‘Invalid request error’ has been replaced with the ‘Bad request error’.
This implies you could consider using a more up to date SDK to find the respective errors in the documentation faster.
In short: look at the error type first.
“type”: “invalid_request_error”,
I got your points. Thank you for your help
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.