
openai
#10500
input_validation_error
Invalid input: The length of the provided string exceeds the maximum limit of 1024 characters.
This error has been identified and solved.
Reason
The 400 status error you're encountering, specifically the message "Invalid 'tools.function.description': string too long," is due to the length of the string provided in the tools.function.description
field exceeding the maximum allowed length. In this case, the string has a length of 1784 characters, which is beyond the expected maximum length of 1024 characters as defined by the OpenAI API. This violation of the API's string length constraints results in a "Bad Request" error.
Solution
To fix the 400 status error caused by the tools.function.description
string being too long, you need to ensure that the description does not exceed the maximum allowed length of 1024 characters. Here are the key steps to resolve this issue:
Trim or shorten the description to fit within the 1024-character limit.
Split the description into multiple fields if necessary, though this might require adjusting your API usage.
Review and adjust any automated processes that generate these descriptions to enforce the character limit.
By adhering to these guidelines, you can prevent the "string too long" error and ensure successful API interactions.
Suggested Links
https://cheatsheet.md/chatgpt-cheatsheet/openai-api-error-axioserror-request-failed-status-code-400
https://community.openai.com/t/issue-with-an-error-400-string-too-long/878992
https://community.openai.com/t/getting-400-response-with-already-working-code/509212
https://community.openai.com/t/error-400-related-to-size-of-string/840368
https://learn.microsoft.com/en-us/answers/questions/1532521/run-failed-openai-api-hits-badrequesterror-error-c
https://community.openai.com/t/function-call-description-max-length/529902
https://github.com/home-assistant/core/issues/121325
https://community.openai.com/t/assisants-api-message-content-maximum-length/829483