An InvalidRequestError
means the API request you sent was incomplete, incorrectly formatted, or contained invalid values. This commonly occurs due to small mistakes like typos or unsupported parameters.
Common Reasons for an InvalidRequestError
Missing parameters: Your request left out required information.
Incorrect parameters: A parameter was provided incorrectly (wrong type or unsupported).
Typos or formatting issues: Misspellings, incorrect JSON formatting, or invalid encoding (e.g., UTF-8 errors).
Unsupported features: You're using features (e.g., functions, tools) that aren't supported by the model you've selected.
Model name errors: Incorrect model names or aliases (e.g.,
"gpt4"
instead of"gpt-4o"
).Exceeding limits: Your request is too large (exceeding token limits or payload size).
Troubleshooting Steps to Fix the Error
Carefully review the error message
It often specifies exactly what went wrong.
Look for the
"param"
field in the error message鈥攖his indicates the exact parameter causing the issue.
Check the official API documentation
Confirm parameter names, types, formats, and limits are correctly followed.
Verify the parameters you're using match your specific model and endpoint.
Validate your model name
Ensure the correct model name is specified exactly as listed in the API reference.
Check the request format and size
Ensure the request is properly formatted in JSON and encoded in UTF-8.
Confirm you're not exceeding token limits or data size restrictions.
Test your request separately
Use tools like Postman or curl to send the request independently.
Utilize the OpenAI API Explorer to simplify debugging.
Still Having Trouble?
If you've followed these steps but still need help, you can try searching or posting in our Developer Community, or you can contact OpenAI Support.
Provide the following details in your support request:
Model name you're using
The complete error message and HTTP status code
Your request body and headers (remove any sensitive info)
Timestamp and timezone of the error
Any relevant logs or additional context