Gpt-4-vision-preview and firebase storage

hey everyone!

any idea why I’d be getting the error below when I’m trying to run the vision api on an image stored in firebase?

Error calling OpenAI Vision API: BadRequestError: 400 You uploaded an unsupported image. Please make sure your image is below 20 MB in size and is of one the following formats: ['png', 'jpeg', 'gif', 'webp'].
    at APIError.generate (/Users/anirbankumar/Documents/RealtorAI/backend/node_modules/openai/error.js:44:20)
    at OpenAI.makeStatusError (/Users/anirbankumar/Documents/RealtorAI/backend/node_modules/openai/core.js:255:33)
    at OpenAI.makeRequest (/Users/anirbankumar/Documents/RealtorAI/backend/node_modules/openai/core.js:294:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processImagesWithVisionApi (/Users/anirbankumar/Documents/RealtorAI/backend/app.js:73:26)
    at async /Users/anirbankumar/Documents/RealtorAI/backend/app.js:46:35 {
  status: 400,
  headers: {
    'alt-svc': 'h3=":443"; ma=86400',
    'cf-cache-status': 'DYNAMIC',
    'cf-ray': '84315af6ddc019e7-EWR',
    connection: 'keep-alive',
    'content-length': '284',
    'content-type': 'application/json',
    date: 'Wed, 10 Jan 2024 02:05:30 GMT',
    'openai-organization': 'user-mmpfcolcvpgickr1d3p3exlf',
    'openai-processing-ms': '322',
    'openai-version': '2020-10-01',
    server: 'cloudflare',
    'set-cookie': '__cf_bm=zP5i12_4Jzc6l4gKu1ONp_oqej2kMXVHum8E4teRUYs-1704852330-1-AX4dDWvKQQGviQ++VYmV+yWQ//0sNkLN6xG7fCJ5kygZCWMmvvgtNqKooI3uQ9yHzhnx72OT8za7MU01Xuew/WY=; path=/; expires=Wed, 10-Jan-24 02:35:30 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None, _cfuvid=bTSw1xx9lQs7Ucb0hwDzxohCtMyDBuq8WDzkRID8Nfk-1704852330457-0-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None',
    'strict-transport-security': 'max-age=15724800; includeSubDomains',
    'x-ratelimit-limit-requests': '100',
    'x-ratelimit-limit-tokens': '10000',
    'x-ratelimit-remaining-requests': '81',
    'x-ratelimit-remaining-tokens': '9553',
    'x-ratelimit-reset-requests': '4h23m48.602s',
    'x-ratelimit-reset-tokens': '2.682s',
    'x-request-id': '851e8704043e170063674d0637530ffe'
  },
  error: {
    message: "You uploaded an unsupported image. Please make sure your image is below 20 MB in size and is of one the following formats: ['png', 'jpeg', 'gif', 'webp'].",
    type: 'invalid_request_error',
    param: null,
    code: 'invalid_image_format'
  },
  code: 'invalid_image_format',
  param: null,
  type: 'invalid_request_error'
}
Error processing the form submission: BadRequestError: 400 You uploaded an unsupported image. Please make sure your image is below 20 MB in size and is of one the following formats: ['png', 'jpeg', 'gif', 'webp'].
    at APIError.generate (/Users/anirbankumar/Documents/RealtorAI/backend/node_modules/openai/error.js:44:20)
    at OpenAI.makeStatusError (/Users/anirbankumar/Documents/RealtorAI/backend/node_modules/openai/core.js:255:33)
    at OpenAI.makeRequest (/Users/anirbankumar/Documents/RealtorAI/backend/node_modules/openai/core.js:294:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processImagesWithVisionApi (/Users/anirbankumar/Documents/RealtorAI/backend/app.js:73:26)
    at async /Users/anirbankumar/Documents/RealtorAI/backend/app.js:46:35 {
  status: 400,
  headers: {
    'alt-svc': 'h3=":443"; ma=86400',
    'cf-cache-status': 'DYNAMIC',
    'cf-ray': '84315af6ddc019e7-EWR',
    connection: 'keep-alive',
    'content-length': '284',
    'content-type': 'application/json',
    date: 'Wed, 10 Jan 2024 02:05:30 GMT',
    'openai-organization': 'user-mmpfcolcvpgickr1d3p3exlf',
    'openai-processing-ms': '322',
    'openai-version': '2020-10-01',
    server: 'cloudflare',
    'set-cookie': '__cf_bm=zP5i12_4Jzc6l4gKu1ONp_oqej2kMXVHum8E4teRUYs-1704852330-1-AX4dDWvKQQGviQ++VYmV+yWQ//0sNkLN6xG7fCJ5kygZCWMmvvgtNqKooI3uQ9yHzhnx72OT8za7MU01Xuew/WY=; path=/; expires=Wed, 10-Jan-24 02:35:30 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None, _cfuvid=bTSw1xx9lQs7Ucb0hwDzxohCtMyDBuq8WDzkRID8Nfk-1704852330457-0-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None',
    'strict-transport-security': 'max-age=15724800; includeSubDomains',
    'x-ratelimit-limit-requests': '100',
    'x-ratelimit-limit-tokens': '10000',
    'x-ratelimit-remaining-requests': '81',
    'x-ratelimit-remaining-tokens': '9553',
    'x-ratelimit-reset-requests': '4h23m48.602s',
    'x-ratelimit-reset-tokens': '2.682s',
    'x-request-id': '851e8704043e170063674d0637530ffe'
  },
  error: {
    message: "You uploaded an unsupported image. Please make sure your image is below 20 MB in size and is of one the following formats: ['png', 'jpeg', 'gif', 'webp'].",
    type: 'invalid_request_error',
    param: null,
    code: 'invalid_image_format'
  },
  code: 'invalid_image_format',
  param: null,
  type: 'invalid_request_error'
}

I’m printing the URL and the image is accessible through the browser and a curl command returns a 200 on it… The image meets the criteria too.

Hi,

Download the image locally and then specify that image in base64 format when calling the API, that way you can manage any image issues in your code.

What code are you using for the API call?

1 Like