
azure-openai
#10060
schema_validation_error
Invalid schema for function 'information_extraction': Input must be an 'object' or 'boolean' type.
This error has been identified and solved.
Reason
The 400 status error in the Azure OpenAI API, specifically the "Invalid schema for function" error, is likely due to several reasons:
Incorrect or Missing Schema
The error message indicates that the provided data does not conform to the expected JSON schema. This could be because the schema for the information_extraction
function requires specific types (e.g., object
or boolean
) that are not being met by the provided data (['Tech Sector Concerns', 'Bot Development Work', 'Expense Question', 'API Configuration Progress']
), which is an array of strings rather than the expected type.
Incorrect Request Payload
The payload you are sending to the API might not match the required structure or types expected by the information_extraction
function. This discrepancy can lead to a "Bad Request" error as the server cannot process the request due to the invalid payload.
Model-Specific Parameters
Different OpenAI models and functions have specific parameter requirements. The error suggests that the information_extraction
function expects parameters of a certain type that are not being provided correctly, leading to a schema validation error.
Solution
To resolve the 400 status error in the Azure OpenAI API due to the "Invalid schema for function" error, you need to ensure that the data provided conforms to the expected JSON schema. Here are the key actions to take:
Correct the data type: Ensure that the data provided for the
information_extraction
function matches the expected types, such asobject
orboolean
, rather than an array of strings.Verify the request payload: Make sure the payload conforms to the required structure and types expected by the
information_extraction
function.Check model-specific parameters: Ensure you are using the correct parameters for the specific OpenAI model and function you are interacting with.
Inspect headers and content type: Confirm that the
Content-Type
header is set correctly toapplication/json
.Review API documentation: Refer to the OpenAI API documentation to ensure compliance with the latest schema and parameter requirements.
Suggested Links
https://cheatsheet.md/chatgpt-cheatsheet/openai-api-error-axioserror-request-failed-status-code-400
https://portkey.ai/error-library/schema-error-10019
https://learn.microsoft.com/en-us/answers/questions/2139738/openai-badrequesterror-error-code-400-((error-((me
https://github.com/instructor-ai/instructor/issues/961
https://learn.microsoft.com/en-us/answers/questions/1479386/azure-openai-api-calling-issue
https://portkey.ai/error-library/prompt-error-10016
https://community.openai.com/t/badrequesterror-invalid-schema-for-function/580803
https://community.openai.com/t/how-can-i-write-a-post-request-for-azure-openai-that-uses-structured-output/898569
https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/openai/azure-ai-openai/TROUBLESHOOTING.md