ઇમેજ અને ફાઇલ્સ
મેસેજ સાથે ઇમેજ મોકલો: કયા મોડેલ્સ તે લે છે, સ્વીકારાતા સ્વરૂપો અને તેમની મર્યાદાઓ.
POST https://api.shannon-ai.com/v1/chat/completions
ઇમેજ user મેસેજની અંદર, તેના content ના એક ભાગ તરીકે પ્રવાસ કરે છે. નમૂનો સ્થાનિક ફાઇલ વાંચે છે અને તેને data URL તરીકે મોકલે છે.
import base64
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.shannon-ai.com/v1")
with open("photo.jpg", "rb") as f:
image = base64.b64encode(f.read()).decode()
response = client.chat.completions.create(
model="shannon-3",
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "What is in this picture?"},
{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64," + image}},
],
}],
)
print(response.choices[0].message.content) import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://api.shannon-ai.com/v1" });
const image = fs.readFileSync("photo.jpg").toString("base64");
const response = await client.chat.completions.create({
model: "shannon-3",
messages: [{
role: "user",
content: [
{ type: "text", text: "What is in this picture?" },
{ type: "image_url", image_url: { url: "data:image/jpeg;base64," + image } },
],
}],
});
console.log(response.choices[0].message.content); # Linux: base64 -w0 photo.jpg macOS: base64 -i photo.jpg
IMAGE=$(base64 -w0 photo.jpg)
curl https://api.shannon-ai.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"model": "shannon-3",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What is in this picture?"},
{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,${IMAGE}"}}
]
}]
}
EOF {
"id": "chatcmpl-8d1f3a5c7e9b4d2f6a8c0e2b4d6f8a1c",
"object": "chat.completion",
"created": 1791590400,
"model": "shannon-3",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "A grey cat asleep on a windowsill, with a potted fern beside it.",
"reasoning_content": null
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 286,
"completion_tokens": 19,
"total_tokens": 305
}
} કયા મોડેલ્સ ઇમેજ લે છે
| મોડેલ્સ | શું વાંચે છે |
|---|---|
shannon-3, shannon-3-pro, shannon-3.1, shannon-3.1-pro | ઇમેજ, અને ડોક્યુમેન્ટ્સ: PDF, Word, PowerPoint, Excel અને સાદી ટેક્સ્ટ ફાઇલ્સ. |
shannon-1.6-lite, shannon-1.6-pro | ઇમેજ. |
shannon-2-lite, shannon-2-pro | ઇમેજ, tools અથવા response_format પણ મોકલતી રિક્વેસ્ટ્સમાં. |
Kimi-K3-3BIT-REAP, MiniMax-M3-3BIT-REAP, Kimi-K2.6-W4A16-AUTOROUND-REAP, inkling-W4A16-AUTOROUND-REAP, MiMo-V2.5-W8A16 | ઇમેજ. |
DeepSeek-V4-Pro-0813-3BIT-REAP, GLM-5.2-3BIT-REAP, Nemotron3Ultra-3BIT-REAP, DeepSeek-V4-Flash-0731-W4A16-AUTOROUND-REAP, Laguna-S-2.1-W4A16-AUTOROUND-REAP, MiMo-V2.5-Pro-W8A16, Hy3-W8A16 | ટેક્સ્ટ. ઇમેજવાળી રિક્વેસ્ટનો જવાબ સ્ટેટસ 400 થી અપાય છે. |
shannon-coder-1 | ટેક્સ્ટ. |
GET /v1/models દરેક id માટે ઇમેજ ઇનપુટ capabilities.vision તરીકે જણાવે છે. મોડેલ્સ અને કિંમત
- Shannon મોડેલ્સ છેલ્લા user મેસેજની ફાઇલ્સ વાંચે છે. ઇમેજને તે વિશે પૂછતા મેસેજમાં મૂકો.
- Shannon 3 ફેમિલી અગાઉના user મેસેજની થોડી ઇમેજ અને ડોક્યુમેન્ટ પણ નજરમાં રાખે છે જો તે ઇનલાઇન મોકલાયેલ હોય, અને રિક્વેસ્ટ દીઠ ઇમેજની નક્કી કરેલી મહત્તમ સંખ્યા વાંચે છે, પહેલીથી ગણતાં.
- હોસ્ટેડ open-weight મોડેલ્સ વાતચીતના દરેક મેસેજની ઇમેજ વાંચે છે.
સ્વીકારાતા સ્વરૂપો
ફાઇલ બે રીતમાંથી એકથી મોકલાય છે: રિક્વેસ્ટની અંદર base64 તરીકે, અથવા API મેળવે તેવા સરનામા તરીકે. દરેક ફાઇલ રિક્વેસ્ટ સાથે પ્રવાસ કરે છે; API પાસે કોઈ અપલોડ એન્ડપોઇન્ટ નથી.
| એન્ડપોઇન્ટ | રિક્વેસ્ટમાં (base64) | સરનામા દ્વારા |
|---|---|---|
/v1/chat/completions | {"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,…"}} | {"type": "image_url", "image_url": {"url": "https://…"}} |
/v1/responses | {"type": "input_image", "image_url": "data:image/jpeg;base64,…"} | {"type": "input_image", "image_url": "https://…"} |
/v1/messages | {"type": "image", "source": {"type": "base64", "media_type": "image/jpeg", "data": "…"}} | {"type": "image", "source": {"type": "url", "url": "https://…"}} |
દરેક ફોર્મેટમાં એ જ user મેસેજ:
{
"role": "user",
"content": [
{"type": "text", "text": "What is in this picture?"},
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD…"
}
}
]
} {
"role": "user",
"content": [
{"type": "input_text", "text": "What is in this picture?"},
{
"type": "input_image",
"image_url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD…"
}
]
} {
"role": "user",
"content": [
{"type": "text", "text": "What is in this picture?"},
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": "/9j/4AAQSkZJRgABAQAAAQABAAD…"
}
}
]
} - data URL નું સ્વરૂપ
data:<media type>;base64,<data>છે.;base64ભાગ જરૂરી છે. /v1/chat/completionsઅને/v1/responsesપર,image_urlસ્ટ્રિંગ પોતે અથવા ઓબ્જેક્ટ{"url": "…"}હોઈ શકે.- ફાઇલ પ્રકાર data URL માંથી અથવા
media_typeમાંથી આવે છે. તેના વિના ઇમેજimage/pngતરીકે વંચાય છે. - ઇનલાઇન ફાઇલ્સ રિક્વેસ્ટ બોડીના કદમાં ગણાય છે, જે 32 MiB સુધીનો હોઈ શકે.
- સુસંગતતા માટે સ્વીકારાય છે:
image_url.detail.
રિમોટ ફાઇલ્સની મર્યાદાઓ
જ્યારે તમે સરનામું મોકલો, ત્યારે મોડેલ ચાલે તે પહેલાં API આ મર્યાદાઓમાં ફાઇલ મેળવે છે:
| મર્યાદા | નિયમ |
|---|---|
| કદ | ફાઇલ દીઠ 8 MiB સુધી. |
| સમય | જવાબ આપવા માટે 20 સેકન્ડ. |
| રીડાયરેક્ટ | વધુમાં વધુ 5. |
| સરનામું | http:// અથવા https://, સરનામામાં વપરાશકર્તા નામ કે પાસવર્ડ વિના, જાહેર સરનામાવાળા હોસ્ટ પર. |
| હોસ્ટનો જવાબ | 200 શ્રેણીનું સ્ટેટસ અને ખાલી ન હોય તેવો બોડી. ફાઇલ પ્રકાર Content-Type માંથી વંચાય છે. |
| આ રીતે માંગવામાં આવે છે | User-Agent: ShannonBot/1.0 (+https://shannon-ai.com) |
ઇમેજ ટોકન્સમાં કેવી રીતે ગણાય છે
હોસ્ટેડ open-weight મોડેલ્સ પર ઇમેજ દરેક 28 × 28 પિક્સેલ પેચ દીઠ એક ટોકન ગણાય છે: પહોળાઈ ભાગ્યા 28, ઉપર ગોળ કરેલી, ગુણ્યા ઊંચાઈ ભાગ્યા 28, ઉપર ગોળ કરેલી. પરિણામ usage.prompt_tokens નો ભાગ છે અને ઇનપુટ તરીકે બિલ થાય છે.
- 1024 × 1024
- 1,369 ટોકન્સ
- 1920 × 1080
- 2,691 ટોકન્સ
- 512 × 512
- 361 ટોકન્સ
- રિમોટ ઇમેજ પહેલા મેળવાય છે, તેથી તેનું વાસ્તવિક કદ ગણાય છે.
- જેનું કદ વાંચી ન શકાય તેવી ઇમેજ 1,024 ટોકન્સ ગણાય છે.
- ગણતરી એન્ડપોઇન્ટ્સ data URL માટે એ જ નિયમ વાપરે છે. તેઓ રિમોટ સરનામું મેળવતા નથી અને તેને 1,024 ટોકન્સ ગણે છે. ટોકન ગણતરી
- Shannon મોડેલ માટે, ઇમેજવાળી રિક્વેસ્ટનો ખર્ચ જવાબના
usageપરથી વાંચો.
ડોક્યુમેન્ટ્સ અને અન્ય ફાઇલ્સ
Shannon 3 ફેમિલી (shannon-3, shannon-3-pro, shannon-3.1, shannon-3.1-pro) ડોક્યુમેન્ટ પણ વાંચે છે. ડોક્યુમેન્ટનો ટેક્સ્ટ કાઢી લેવામાં આવે છે અને તમારા મેસેજ સાથે મોડેલને આપવામાં આવે છે.
| ડોક્યુમેન્ટ | મીડિયા પ્રકાર |
|---|---|
application/pdf | |
| Word | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
| PowerPoint | application/vnd.openxmlformats-officedocument.presentationml.presentation |
| Excel | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
ડોક્યુમેન્ટ ઇમેજની જેમ user મેસેજનો એક ભાગ છે:
| એન્ડપોઇન્ટ | રિક્વેસ્ટમાં (base64) | સરનામા દ્વારા |
|---|---|---|
/v1/chat/completions, /v1/messages | {"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "…"}} | {"type": "document", "source": {"type": "url", "url": "https://…"}} |
/v1/responses | {"type": "input_file", "file_data": "data:application/pdf;base64,…"} | {"type": "input_file", "file_url": "https://…"} |
{
"model": "shannon-3",
"messages": [
{
"role": "user",
"content": [
{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": "JVBERi0xLjcKJeLjz9MK…"
}
},
{"type": "text", "text": "Summarise this report in five points."}
]
}
]
} {
"model": "shannon-3",
"input": [
{
"role": "user",
"content": [
{
"type": "input_file",
"file_data": "data:application/pdf;base64,JVBERi0xLjcKJeLjz9MK…"
},
{
"type": "input_text",
"text": "Summarise this report in five points."
}
]
}
]
} {
"model": "shannon-3",
"messages": [
{
"role": "user",
"content": [
{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": "JVBERi0xLjcKJeLjz9MK…"
}
},
{"type": "text", "text": "Summarise this report in five points."}
]
}
]
} - ફાઇલનો સાચો મીડિયા પ્રકાર આપો. તેના વિના ડોક્યુમેન્ટ
application/pdfતરીકે વંચાય છે. - CSV જેવી સાદી ટેક્સ્ટ ફાઇલ ટેક્સ્ટ તરીકે વંચાય છે અને એ જ રીતે જોડાય છે.
- જ્યારે ડોક્યુમેન્ટ વાંચી ન શકાય, અથવા ફાઇલ અન્ય પ્રકારની હોય, ત્યારે મોડેલને તે જણાવાય છે અને તે જવાબમાં કહી શકે છે. સ્ટેટસ હજી પણ
200હોય છે. - અન્ય દરેક મોડેલ પર ડોક્યુમેન્ટ ભાગ મોડેલ જે વાંચે છે તેમાંથી બાકાત રખાય છે, અને રિક્વેસ્ટનો જવાબ બાકીના ભાગ પરથી અપાય છે.
- સરનામા દ્વારા મોકલેલું ડોક્યુમેન્ટ ઉપરની રિમોટ ફાઇલ્સની મર્યાદાઓ હેઠળ મેળવાય છે.
એરર્સ
| સ્ટેટસ | પ્રકાર | મેસેજ | ક્યારે |
|---|---|---|---|
400 | invalid_request_error | <id> does not accept image input | ફક્ત ટેક્સ્ટ લેતા હોસ્ટેડ open-weight મોડેલને ઇમેજ મોકલવામાં આવી. તમારા બેલેન્સમાંથી કંઈ કપાતું નથી. |
400 | invalid_request_error | audio and video input are not supported by any hosted model | હોસ્ટેડ open-weight મોડેલને ઓડિયો અથવા વિડિયો ભાગ મોકલવામાં આવ્યો. |
413 | invalid_request_error | Failed to buffer the request body: … | ઇનલાઇન ફાઇલ્સ સાથેનો રિક્વેસ્ટ બોડી 32 MiB કરતાં મોટો છે. એરર code: "request_too_large" લઈ જાય છે. |
રિક્વેસ્ટ ગમે તે ફાઇલ્સ લઈ જાય, Shannon મોડેલ સ્ટેટસ 200 થી જવાબ આપે છે: તે ન વાંચતું હોય તેવો ભાગ બાકાત રખાય છે. ભૂલ સંભાળ