I’m encountering issues with Azure API Management while trying to validate vision requests for OpenAI. After importing the Azure OpenAI swagger specification into APIM, I set up JSON validation by using the validate-content policy.
<validate-content unspecified-content-type-action="ignore" max-size="4194394" size-exceeded-action="detect" errors-variable-name="validationErrors">
<content type="application/json" validate-as="json" action="prevent" allow-additional-properties="true" />
</validate-content>
Everything works fine for normal text inputs, but the validation seems to fail when I send visual requests containing image information. Here’s an example of the payload I’m testing:
{
"data": [
{
"role": "system",
"content": ""
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "analyze this image"
},
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgo"
}
}
]
}
],
"stream": true
}
When I send this request, the error message I receive is:
{
"statusCode": 400,
"message": "Request body doesn't match schema for application/json content type. Path: data[1].role Error: Value 'user' not found in enum. Line: 12, Position: 25 SchemaId: #/components/schemas/functionMessageRequest/properties/role"
}
From what I see, it appears the validator is referencing the incorrect schema (functionMessageRequest instead of userMessageRequest). Has anyone else faced this problem with the Swagger validation in APIM when working with OpenAI vision APIs?