Endpoint
Vision dan file
Kirim gambar, PDF, audio, dan video sebagai content part pada pesan ke model multimodal, lengkap dengan contoh, batas ukuran, dan plugin file-parser.
Coba di playgroundModel multimodal menerima gambar, PDF, audio, dan video dalam pesan user. Kirim content sebagai array part, bukan string. Untuk melihat apa yang diterima sebuah model, periksa architecture.input_modalities di Model (image, file, audio, video).
Content part
| Part | Bentuk | Catatan |
|---|---|---|
| Teks | { "type": "text", "text": "..." } | |
| Gambar | { "type": "image_url", "image_url": { "url": "https://..." | "data:image/png;base64,...", "detail": "auto" } } | PNG, JPEG, WebP, GIF. URL atau data URL base64. |
| PDF / file | { "type": "file", "file": { "filename": "doc.pdf", "file_data": "https://..." | "data:application/pdf;base64,..." } } | Bekerja dengan model apa pun. Model tanpa dukungan file native menerima teks hasil parsing. |
| Audio | { "type": "input_audio", "input_audio": { "data": "<base64>", "format": "wav" } } | Hanya base64. wav, mp3, dan lainnya, tergantung model. |
| Video | { "type": "video_url", "video_url": { "url": "https://..." } } | Didukung oleh beberapa model, mis. Gemini. |
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api14.com/api/v1",
apiKey: process.env.API14_API_KEY,
});
const result = await client.chat.completions.create({
"model": "openai/gpt-5-mini",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg"
}
}
]
}
]
});
console.log(result.choices[0].message.content);
Contoh gambar
{
"model": "google/gemini-2.5-flash",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "What is in this picture?" },
{ "type": "image_url", "image_url": { "url": "https://upload.wikimedia.org/wikipedia/commons/a/a7/Camponotus_flavomarginatus_ant.jpg" } }
]
}
]
}
Contoh PDF
{
"model": "anthropic/claude-sonnet-4.5",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "Summarize this contract in five bullets." },
{ "type": "file", "file": { "filename": "contract.pdf", "file_data": "data:application/pdf;base64,JVBERi0xLjcK..." } }
]
}
],
"plugins": [{ "id": "file-parser", "pdf": { "engine": "pdf-text" } }]
}
Plugin file-parser yang opsional memilih cara PDF dibaca: pdf-text (ekstraksi teks gratis), mistral-ocr (OCR untuk hasil scan, ditagih per halaman), atau native (model membaca file itu sendiri). Biaya parsing termasuk dalam usage.cost.
Respons
Respons berupa chat completion biasa. Input gambar, file, dan audio dihitung sebagai token input, dan biayanya ada di usage.cost:
{
"choices": [{ "index": 0, "finish_reason": "stop", "message": { "role": "assistant", "content": "A close-up of an ant on a leaf." } }],
"usage": { "prompt_tokens": 1290, "completion_tokens": 12, "total_tokens": 1302, "cost": 0.000417 }
}
Batas dan error
- Body request maksimal 25 MB. Base64 membuat file sekitar 33% lebih besar. Request yang lebih besar mengembalikan
413 payload_too_large. Untuk gambar besar, gunakan URL publik. - Model yang tidak menerima suatu tipe input mengembalikan
400atau404dari upstream. - Error lainnya sama seperti pada Chat completions. Lihat Error.