Not able to process/analyze images using GPT 4o model through Assistants API

Ahmed Rasheed 0 Reputation points
2024-07-18T14:47:01.3333333+00:00

I'm not able to pass the image to GPT 4o model through azure openai assistants api. The create message endpoint of deployed model only support string in the content.

/threads/{thread_id}/messages

It gives an error when trying to pass content as an array format which is needed when passing image to the model, shown below

content = [
    {
        "type": "text",
        "text": {
            "value": text_content,
            "annotations": []
        }
    },
    {
        "type": "image_url",
        "image_url": {
            "url": f"data:image/{extension};base64,{base64image}",
        }
    }
]
message = await self.client.beta.threads.messages.create(
    thread_id=thread_id,
    role="user",
    content=content,
)

gives this error when making post request to azure endpoint

openai.BadRequestError: Error code: 400 - {'error': {'message': "Invalid type for 'content[0].text': expected a string, but got an object instead.", 'type': 'invalid_request_error', 'param': 'content[0].text', 'code': 'invalid_type'}}

Is there any other way from which I can parse the image files as GPT 4o natively supports the image processing and it is processing images when chat-completion API is used.

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
4,101 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. VasaviLankipalle-MSFT 18,676 Reputation points Moderator
    2024-07-18T20:35:32.25+00:00

    Hello @Ahmed Rasheed , Thanks for using Microsoft Q&A Platform.

    Unfortunately, to analyze images using GPT 4o model through Assistants API is not yet supported. We don't have any ETA to share with you at this moment.

    Try GPT-4o for chat completions.

    Is this something you are looking for?

    Regards,

    Vasavi

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.