Images Inputs
Siraya Model Router supports sending images via the API. This guide shows how to work with image file types using our API.
Image Inputs
Requests with images to vision-capable models are available via the /v1/chat/completions API with a multi-part messages parameter. The image_url can either be a URL or a base64-encoded image.
Multiple images can be sent in separate content array entries. The number of images you can send in a single request varies per provider and per model. We recommend sending the text prompt first, then the images.
Using Image URLs
Here's how to send an image using a URL:
import requests
import json
url = "https://llm.siraya.ai/v1/chat/completions"
headers = {
"Authorization": f"Bearer <API_KEY>",
"Content-Type": "application/json"
}
messages = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in detail."
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/image.jpg"
}
}
]
}
]
payload = {
"model": "claude-sonnet-4.5",
"messages": messages
}
response = requests.post(url, headers=headers, json=payload)
print(response.json()["choices"][0]["message"]["content"])
const response = await fetch('https://llm.siraya.ai/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: `Bearer <API_KEY>`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'claude-sonnet-4.5',
messages: [
{
role: 'user',
content: [
{
type: 'text',
text: "Describe this image in detail.",
},
{
type: 'image_url',
image_url: {
url: 'https://example.com/image.jpg',
},
},
],
},
],
}),
});
const data = await response.json();
console.log(data);
Using Base64 Encoded Images
For locally stored images, you can send them using base64 encoding:
import requests
import json
import base64
def encode_image_to_base64(image_path):
with open(image_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode('utf-8')
url = "https://llm.siraya.ai/v1/chat/completions"
headers = {
"Authorization": f"Bearer <API_KEY>",
"Content-Type": "application/json"
}
image_path = "path/to/your/image.jpg"
base64_image = encode_image_to_base64(image_path)
data_url = f"data:image/jpeg;base64,{base64_image}"
messages = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in detail."
},
{
"type": "image_url",
"image_url": {
"url": data_url
}
}
]
}
]
payload = {
"model": "claude-sonnet-4.5",
"messages": messages
}
response = requests.post(url, headers=headers, json=payload)
print(response.json()["choices"][0]["message"]["content"])
import fs from 'node:fs';
async function encodeImageToBase64(imagePath: string): Promise<string> {
const imageBuffer = await fs.promises.readFile(imagePath);
return `data:image/jpeg;base64,${imageBuffer.toString('base64')}`;
}
const base64Image = await encodeImageToBase64('path/to/your/image.jpg');
const response = await fetch('https://llm.siraya.ai/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: `Bearer <API_KEY>`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'claude-sonnet-4.5',
messages: [
{
role: 'user',
content: [
{ type: 'text', text: "Describe this image in detail." },
{ type: 'image_url', image_url: { url: base64Image } },
],
},
],
}),
});
const data = await response.json();
console.log(data);
Supported Image Formats
image/pngimage/jpegimage/webpimage/gif