Analyze uploaded image using Chat GPT Open API with Power Automate HTTP custom connector

 

Hello Techies! In this article, I’m working on a scenario where I have created a Power App and a Power Automate flow. I am taking an image input from the Power App and passing it to Power Automate. In Power Automate, we use the HTTP connector to connect to the ChatGPT Open API, where we perform image analysis. Finally, we showcase the output in the Power App.

 


Power App

 

Here we are taking input from user by taking Patient Name & Image.

On the submit button we are starting our Power Automate flow.

 

 

Set(Variable_Name,'PowerAutomateFlow_Name'.Run(TextInput4.Text,{contentBytes:AddMediaButton1.Media,name:"IMG"}))

 


 

Power Automate Flow

 

Flow we will start with the action by taking input from the Power App

 

  • When Power App Calls a Flow (V2)
  • Create File
  • Get File Content Using path
  • Compose  (base64(body('Get_file_content_using_path')))
  • HTTP 

URI- https://api.openai.com/v1/chat/completions

Method - POST

Headers - Content Type - application/json

     - Authorization- Bearer API KEY

 

Body -

{

 "model": "gpt-4o-mini",

 "messages": [

 {

 "role": "user",

 "content": [

 {

 "type": "text",

 "text": "Provide details analysis of image whetever you understand in points"

 },

 {

 "type": "image_url",

 "image_url": {

 "url": "data:image/jpeg;base64,Need_To_Pass_IMAGE"

 }

 }

 ]

 }

 ],

 "max_tokens": 300


 

  • Initialize Variable  Type - Object

                Value - Body Output

  • Compose - replace(replace(replace(string(variables('Replace Testing')['choices'][0]['message']['content']),'*',''),'\n',' '),'#','')
  • Respond to power app or flow  - Send Text output of compose to Power Apps

Comments