Chat completion with vision: DeepSeek V4 Flash Vision
curl --request POST \
--url https://api.apiyi.com/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "deepseek-v4-flash-vision-exp",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image? Answer in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://docs.apiyi.com/images/checks-passed.png",
"detail": "original"
}
}
]
}
]
}
'import requests
url = "https://api.apiyi.com/v1/chat/completions"
payload = {
"model": "deepseek-v4-flash-vision-exp",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image? Answer in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://docs.apiyi.com/images/checks-passed.png",
"detail": "original"
}
}
]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'deepseek-v4-flash-vision-exp',
messages: [
{
role: 'user',
content: [
{type: 'text', text: 'What is in this image? Answer in one sentence.'},
{
type: 'image_url',
image_url: {url: 'https://docs.apiyi.com/images/checks-passed.png', detail: 'original'}
}
]
}
]
})
};
fetch('https://api.apiyi.com/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.apiyi.com/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'deepseek-v4-flash-vision-exp',
'messages' => [
[
'role' => 'user',
'content' => [
[
'type' => 'text',
'text' => 'What is in this image? Answer in one sentence.'
],
[
'type' => 'image_url',
'image_url' => [
'url' => 'https://docs.apiyi.com/images/checks-passed.png',
'detail' => 'original'
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.apiyi.com/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"deepseek-v4-flash-vision-exp\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"What is in this image? Answer in one sentence.\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"https://docs.apiyi.com/images/checks-passed.png\",\n \"detail\": \"original\"\n }\n }\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.apiyi.com/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"deepseek-v4-flash-vision-exp\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"What is in this image? Answer in one sentence.\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"https://docs.apiyi.com/images/checks-passed.png\",\n \"detail\": \"original\"\n }\n }\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"deepseek-v4-flash-vision-exp\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"What is in this image? Answer in one sentence.\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"https://docs.apiyi.com/images/checks-passed.png\",\n \"detail\": \"original\"\n }\n }\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "35a4e262-f2b8-4eb7-bdb2-012b02c7012d",
"object": "chat.completion",
"model": "deepseek-v4-flash-vision-exp",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The image shows a notification stating that all checks have passed, including a successful Mintlify deployment."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 295,
"completion_tokens": 49,
"total_tokens": 344,
"prompt_cache_hit_tokens": 0,
"prompt_cache_miss_tokens": 295
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}DeepSeek V4 Flash Vision
Справочник Chat API для DeepSeek V4 Flash Vision
Справочник по OpenAI-compatible Chat Completions API и песочница для deepseek-v4-flash-vision-exp: три способа отправки изображений, подробная экономия token, переключатель рассуждения. Требуется token группы по умолчанию.
POST
/
v1
/
chat
/
completions
Chat completion with vision: DeepSeek V4 Flash Vision
curl --request POST \
--url https://api.apiyi.com/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "deepseek-v4-flash-vision-exp",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image? Answer in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://docs.apiyi.com/images/checks-passed.png",
"detail": "original"
}
}
]
}
]
}
'import requests
url = "https://api.apiyi.com/v1/chat/completions"
payload = {
"model": "deepseek-v4-flash-vision-exp",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image? Answer in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://docs.apiyi.com/images/checks-passed.png",
"detail": "original"
}
}
]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'deepseek-v4-flash-vision-exp',
messages: [
{
role: 'user',
content: [
{type: 'text', text: 'What is in this image? Answer in one sentence.'},
{
type: 'image_url',
image_url: {url: 'https://docs.apiyi.com/images/checks-passed.png', detail: 'original'}
}
]
}
]
})
};
fetch('https://api.apiyi.com/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.apiyi.com/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'deepseek-v4-flash-vision-exp',
'messages' => [
[
'role' => 'user',
'content' => [
[
'type' => 'text',
'text' => 'What is in this image? Answer in one sentence.'
],
[
'type' => 'image_url',
'image_url' => [
'url' => 'https://docs.apiyi.com/images/checks-passed.png',
'detail' => 'original'
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.apiyi.com/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"deepseek-v4-flash-vision-exp\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"What is in this image? Answer in one sentence.\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"https://docs.apiyi.com/images/checks-passed.png\",\n \"detail\": \"original\"\n }\n }\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.apiyi.com/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"deepseek-v4-flash-vision-exp\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"What is in this image? Answer in one sentence.\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"https://docs.apiyi.com/images/checks-passed.png\",\n \"detail\": \"original\"\n }\n }\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"deepseek-v4-flash-vision-exp\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"What is in this image? Answer in one sentence.\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"https://docs.apiyi.com/images/checks-passed.png\",\n \"detail\": \"original\"\n }\n }\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "35a4e262-f2b8-4eb7-bdb2-012b02c7012d",
"object": "chat.completion",
"model": "deepseek-v4-flash-vision-exp",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The image shows a notification stating that all checks have passed, including a successful Mintlify deployment."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 295,
"completion_tokens": 49,
"total_tokens": 344,
"prompt_cache_hit_tokens": 0,
"prompt_cache_miss_tokens": 295
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}Проверьте, что ваш token находится в группе
default перед тестированием.token ClaudeCode всё ещё возвращает здесь 200, но detail, переключатель режима рассуждения и logprobs
все перестают работать, а из ответа пропадает поле completion_tokens_details —— кажется, что вы неправильно
задали параметры, хотя на самом деле неверна группа. Для формата Anthropic используйте вместо этого
песочницу сообщений.Используйте песочницу справа для прямого тестирования: поместите
Bearer sk-your-api-key в
Authorization. В примере используется публичное изображение, а режим рассуждения отключён, поэтому вы можете нажать
отправить и сразу увидеть ответ. Для локального файла замените image_url.url на
data:image/jpeg;base64,<BASE64>.Краткая справка по параметрам
| Параметр | Тип | Обязательно | Значение по умолчанию | Примечания |
|---|---|---|---|---|
model | string | ✓ | — | Всегда deepseek-v4-flash-vision-exp |
messages | array | ✓ | — | content — это string или массив частей для смешанного текста и изображений |
max_tokens | int | — | Бюджет вывода, жёсткий потолок 393,216; используйте 2000+ при включённом thinking | |
thinking.type | string | enabled | disabled надёжно отключает thinking и экономит 80 input tokens | |
reasoning_effort | string | — | none эквивалентен отключению thinking; low/high/max не показывают стабильной разницы | |
response_format | object | — | Работает только json_object; json_schema выдаёт ошибку | |
stream | bool | false | Потоковая передача SSE; используйте вместе с stream_options.include_usage для usage | |
temperature / top_p / stop / seed | — | — | Все действуют | |
logprobs / top_logprobs | — | — | Работает; диапазон top_logprobs — 0–20 | |
tools | array | — | Function Call; используйте его вместо json_schema для структурированного вывода |
Три способа отправить изображение
image_url с base64 data URL
{
"type": "image_url",
"image_url": {"url": "data:image/jpeg;base64,<BASE64>", "detail": "original"}
}
image_url с публичной ссылкой
{
"type": "image_url",
"image_url": {"url": "https://example.com/image.jpg", "detail": "low"}
}
Блок file с file_data
{
"type": "file",
"file_data": "data:image/jpeg;base64,<BASE64>",
"filename": "image.jpg"
}
image_url (303 token для одного и того же изображения в любом случае).
detail в блоке file игнорируется без предупреждения —— без ошибки и без сохранения.
Чтобы использовать detail: "low", отправьте изображение через канал image_url.Также, file_id (Files API) недоступен на этой платформе; при передаче одного возвращается
invalid file_id.Сколько экономит detail
Одно и то же изображение 1600×1200 на всех четырёх уровнях:
detail | Image tokens | по сравнению с original |
|---|---|---|
low | 142 | -60% |
high | 354 | same |
original | 354 | baseline |
auto | 354 | same |
low достаточно для определения типа изображения, распознавания объекта или грубой классификации.
original оставляйте для чтения мелкого текста или значений на диаграммах.
Значение вне перечисления вызывает явную ошибку:
unknown variant 'ultra', expected one of 'low', 'high', 'original', 'auto'.
Как изображения становятся token
| Размер изображения | tokens |
|---|---|
| 64×64 | 114 |
| 384×384 | 114 |
| 800×800 | 346 |
| 2000×2000 | 346 |
| 4000×4000 | 346 |
| 1600×400 | 266 |
| 1600×1200 | 354 |
Два способа отключить рассуждение
{ "thinking": { "type": "disabled" } }
{ "reasoning_effort": "none" }
prompt_tokens снижается с 303 до 223, а reasoning_content
исчезает). reasoning: {"effort": "none"} и enable_thinking: false не работают.
Слишком маленький
max_tokens возвращает пустой content. При включённом рассуждении даже вопрос
в одну строку может сначала выдать несколько сотен tokens рассуждения; когда бюджет
заканчивается, вы получаете finish_reason: "length" и пустую строку —— это легко принять за то, что модель не смогла ответить.
Используйте 2000 или больше при включённом рассуждении или просто отключите его.Нужен структурированный вывод? Используйте инструменты
response_format: {"type": "json_schema"} возвращает
This response_format type is unavailable now (ограничение модели выше по цепочке).
json_object работает, но не ограничивает поля. Для принудительного применения используйте Вызов функции:
{
"model": "deepseek-v4-flash-vision-exp",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "Look at the image and call record_shape."},
{"type": "image_url", "image_url": {"url": "https://example.com/shape.jpg"}}
]
}],
"tools": [{
"type": "function",
"function": {
"name": "record_shape",
"parameters": {
"type": "object",
"properties": {
"shape": {"type": "string"},
"color": {"type": "string"}
},
"required": ["shape", "color"]
}
}
}]
}
Распространённые ошибки
| Ошибка | Причина |
|---|---|
You have uploaded an unsupported image | Формат не JPEG/PNG/GIF/WebP, либо base64 повреждён |
Failed to download image | URL недоступен или ответ не был получен в течение более 60 секунд |
image file size exceeds limit 32 MB | Размер изображения больше 32 MiB |
external link length … too long, max link length 8192 | URL слишком длинный |
Image in assistant message is unsupported | Изображения могут появляться только в сообщениях user |
valid range of max_tokens is [1, 393216] | max_tokens выше допустимого предела |
invalid file_id | Вы использовали file_id; эта платформа не предоставляет Files API |
Авторизации
Тело
application/json
Была ли эта страница полезной?