Error prompting llama vision instruct model with image

I have this code:

import base64
import requests

url = "https://api.cloudflare.com/client/v4/accounts/<account-id>/ai/run/@cf/meta/llama-3.2-11b-vision-instruct"
image_path = "anakin-meme-1.png"

with open(image_path, "rb") as img_file:
    image_base64 = base64.b64encode(img_file.read()).decode("utf-8")

payload = {
    "prompt": "Describe the content of this image",
    "image": image_base64,
    "raw": False,
    "max_tokens": 256,
    "temperature": 0.6
}

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())


Which is giving me this error:

{'errors': [{'message': 'AiError: AiError: Tensor error: failed to build tensor image: Tensor error: Unknown internal error: failed to decode u8', 'code': 3016}], 'success': False, 'result': {}, 'messages': []}
Was this page helpful?