VLM
BF16
Playground
Ask me anything :)
Press Tab to automatically fill the input with the placeholder text
What is this image?
Attach image
Control Bar
Attach an image
JPG or PNG
API
import base64
import requests
from io import BytesIO
from PIL import Image
def encode_image(img):
buffered = BytesIO()
img.save(buffered, format="PNG")
encoded_string = base64.b64encode(buffered.getvalue()).decode("utf-8")
return encoded_string
img = Image.open("path_to_your_image")
base64_img = encode_image(img)
api = "https://api.hyperbolic.xyz/v1/chat/completions"
api_key = "<api-key>"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}",
}
payload = {
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{
"type": "image_url",
"image_url": {"url": f"data:image/jpeg;base64,"},
},
],
}],
"model": "mistralai/Pixtral-12B-2409",
"max_tokens": 512,
"temperature": 0.7,
"top_p": 0.9,
}
response = requests.post(api, headers=headers, json=payload)
print(response.json())