Bad request: Invalid (Lazy) Media object Can this be the cause of my BadRequestError: Error code: 400

What I’m trying to do:
I am trying to pass an image from my datatable to chatGPT to analyze. I can view it in my browser in normal browser mode (chrome), however, when i use incognito mode, it gives me an error “Bad request: Invalid (Lazy) Media object”. Maybe that is why I keep getting this error?

BadRequestError: Error code: 400 - {'error': {'message': 'Invalid image.', 'type': 'invalid_request_error', 'param': None, 'code': None}}

Question 1:
How do I remove this security so i can pass my variable with url to ChatGPT without this.

Question 2:
Do you think this is the cause of the error? I am so baffled i cannot figure out why i am getting this error. The code is simple and works with URL off the web, but not with my own images from Anvil data table…

Code looks like this:
Client Side

  def button_save_click(self, **event_args):
    """This method is called when the button is clicked"""
    self.image_uploadedFile.source = self.file_loader_Office.file
    roomImg = self.file_loader_Office.file
    
    
  
    imgID = anvil.server.call('saveFile',roomImg)
    self.text_area_chatGPTOutput.text = anvil.server.call('definingPicture',imgID)
    
    pass

Server Side

@anvil.server.callable
def saveFile(roomImg):
  row = app_tables.maindata.add_row(usersEmail=anvil.users.get_user()['email'],Office=roomImg)
  rowId = row.get_id()
  return rowId



@anvil.server.callable
def definingPicture(imgID):
  imgRow = app_tables.maindata.get_by_id(imgID)
  Img = imgRow['Office']
  #ImgUrl= Img.get_url(False)
  #modified_url = ImgUrl[:-3]
  #print(modified_url)
  print(Img.get_url(False))
  NewImg = Img.get_url(False)
  response = client.chat.completions.create(
  model="gpt-4-turbo",
  messages=[
    {
      "role": "user",
      "content": [
        {"type": "text", "text": "What’s in this image?"},
        {
          "type": "image_url",
          "image_url": {
            "url": NewImg,
          },
        },
      ],
    }
  ],
  max_tokens=300,
)
  
  print(response.choices[0])

My clone link below

Clone link:

A post was merged into an existing topic: GET URL of uploaded image