Multimodal
ZenMux supports multimodal inputs:
- Text input
- Image input
- PDF input
- Audio input (coming soon)
- Video input (coming soon)
Image Input
Using Image URL
python
import requests
import json
url = "https://zenmux.ai/api/v1/chat/completions"
headers = {
"Authorization": "Bearer {your ZENMUX_API_KEY}",
"Content-Type": "application/json"
}
payload = {
"model": "google/gemini-2.5-pro",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please analyze the contents of the image"
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.marmot-cloud.com/storage/tbox-router/2025/08/05/e9445SU/shengchengtupian2025-04-09-19_31.png",
}
}
]
}
]
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
ts
const response = await fetch("https://zenmux.ai/api/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer <your ZENMUX_API_KEY>",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "google/gemini-2.5-pro",
messages: [
{
role: "user",
content: [
{
type: "text",
text: "Please analyze the contents of the image",
},
{
type: "image_url",
image_url: {
url: "https://cdn.marmot-cloud.com/storage/tbox-router/2025/08/05/e9445SU/shengchengtupian2025-04-09-19_31.png",
},
},
],
},
],
}),
});
const data = await response.json();
console.log(data);
Using Image Base64 Encoding
python
import requests
import json
import base64
from pathlib import Path
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://zenmux.ai/api/v1/chat/completions"
headers = {
"Authorization": "Bearer {your ZENMUX_API_KEY}",
"Content-Type": "application/json"
}
image_path = "path/to/your/image.jpg"
base64_image = encode_image_to_base64(image_path)
data_url = "data:image/jpeg;base64,{base64_image}"
payload = {
"model": "google/gemini-2.5-pro",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please analyze the contents of the image"
},
{
"type": "image_url",
"image_url": {
"url": data_url
}
}
]
}
]
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
ts
async function encodeImageToBase64(imagePath: string): Promise<string> {
const imageBuffer = await fs.promises.readFile(imagePath);
const base64Image = imageBuffer.toString("base64");
return `data:image/jpeg;base64,${base64Image}`;
}
const imagePath = "path/to/your/image.jpg";
const base64Image = await encodeImageToBase64(imagePath);
const response = await fetch("https://zenmux.ai/api/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer ${your ZENMUX_API_KEY}",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "google/gemini-2.5-pro",
messages: [
{
role: "user",
content: [
{
type: "text",
text: "Please analyze the contents of the image",
},
{
type: "image_url",
image_url: {
url: base64Image,
},
},
],
},
],
}),
});
const data = await response.json();
console.log(data);
PDF Input
Using PDF URL
python
import requests
import json
url = "https://zenmux.ai/api/v1/chat/completions"
headers = {
"Authorization": "Bearer {your ZENMUX_API_KEY}",
"Content-Type": "application/json"
}
payload = {
"model": "google/gemini-2.5-pro",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please analyze the main content of the file"
},
{
"type": "file",
"file": {
"filename": "test.pdf",
"file_data": "https://cdn.marmot-cloud.com/storage/tbox-router/2025/08/06/uyZbd8m/xiaoxingxingzhaopengyou.pdf"
}
},
]
}
]
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
typescript
const response = await fetch("https://zenmux.ai/api/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer <your ZENMUX_API_KEY>",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "google/gemini-2.5-pro",
messages: [
{
role: "user",
content: [
{
type: "text",
text: "Please analyze the main content of the file",
},
{
type: "file",
file: {
filename: "test.pdf",
file_data:
"https://cdn.marmot-cloud.com/storage/tbox-router/2025/08/06/uyZbd8m/xiaoxingxingzhaopengyou.pdf",
},
},
],
},
],
}),
});
const data = await response.json();
console.log(data);
Using PDF Base64 Encoding
python
import requests
import json
import base64
from pathlib import Path
def encode_pdf_to_base64(pdf_path):
with open(pdf_path, "rb") as pdf_file:
return base64.b64encode(pdf_file.read()).decode("utf-8")
url = "https://zenmux.ai/api/v1/chat/completions"
headers = {
"Authorization": "Bearer {your ZENMUX_API_KEY}",
"Content-Type": "application/json"
}
pdf_path = "path/to/your/test.pdf"
base64_pdf = encode_pdf_to_base64(pdf_path)
data_url = "data:application/pdf;base64,{base64_pdf}"
payload = {
"model": "google/gemini-2.5-pro",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please analyze the main content of the file"
},
{
"type": "file",
"file": {
"filename": "test.pdf",
"file_data": data_url
}
},
]
}
],
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
typescript
async function encodePDFToBase64(pdfPath: string): Promise<string> {
const pdfBuffer = await fs.promises.readFile(pdfPath);
const base64PDF = pdfBuffer.toString("base64");
return `data:application/pdf;base64,${base64PDF}`;
}
const pdfPath = "path/to/your/test.pdf";
const base64PDF = await encodePDFToBase64(pdfPath);
const response = await fetch("https://zenmux.ai/api/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer ${your ZENMUX_API_KEY}",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "google/gemini-2.5-pro",
messages: [
{
role: "user",
content: [
{
type: "text",
text: "Please analyze the main content of the file",
},
{
type: "file",
file: {
filename: "test.pdf",
file_data: base64PDF,
},
},
],
},
],
}),
});
const data = await response.json();
console.log(data);