OpenAI has deprecated direct image processing through its API

Nope … :slight_smile: please find under what I found on the OpenAI related:

" OpenAI has deprecated direct image processing through its API, so if you’re using openai.ChatCompletion or other similar methods for image-related tasks, they will no longer work in openai>=1.0.0"

I am talking about direct vision image processing via API … if you upload an image to the Chat bot then yes it is working.
When you upload an image via API request is not workiing anymore.

If I am wrong and you found a way to upload an image via API request to then pls share … :slight_smile:

Even if you have an image on your system with any container food related or not pls try to upload it and ask the response to be Brand:, Category: and Type : … let AI to identify the object.

This is a snipet of the code related to the image upload:

def encode_image_to_base64(image_path):
with open(image_path, “rb”) as image_file:
return base64.b64encode(image_file.read()).decode(‘utf-8’)

def send_images_to_ai(encoded_images, item_code):
# Prepare messages list with only available images
messages = [
{“type”: “text”,
“text”: (
"Identify the object and categorize it specifically under the most applicable Category within "
"Dairy, Non Dairy, Fats, Meats, Grain Product, Meat Alternative, Non Alcoholic Beverage, Spirits & Liquors, Dietary Supplement, Condiment. "
“Provide:\nBrand:\nProduct Type:\nCategory:\n\nNothing else.”
)}
]

# Add images conditionally based on availability
if 'esp32_1' in encoded_images:
    messages.append({"type": "image", "image": encoded_images['esp32_1']})
if 'esp32_2' in encoded_images:
    messages.append({"type": "image", "image": encoded_images['esp32_2']})
if 'esp32_3' in encoded_images:
    messages.append({"type": "image", "image": encoded_images['esp32_3']})

payload = {
    "model": "gpt-4-turbo-2024-04-09",

“model”: “gpt-4-vision-preview”, was working perfectly

    "messages": [
        {
            "role": "user",
            "content": messages
        }
    ],
    "max_tokens": 50
}
      
headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {api_key}"
}
response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
if response.status_code == 200:
    response_data = response.json()
    print(json.dumps(response_data, indent=4))  # For debugging, remove or adjust as needed
    return response_data  # Return the response data for further processing
else:
    print(f"Error in image analysis API request: {response.status_code}")
    logging.error(f"Error in image analysis API request: {response.status_code}")
    return None

The commented model was working till Nov 18th after nothing related works.