curl --request POST \
--url https://api.apiyi.com/v1/messages \
--header 'Content-Type: application/json' \
--header 'anthropic-version: <anthropic-version>' \
--header 'x-api-key: <api-key>' \
--data '
{
"model": "deepseek-v4-flash-vision-exp",
"max_tokens": 800,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image? Answer in one sentence."
},
{
"type": "image",
"source": {
"type": "url",
"url": "https://docs.apiyi.com/images/checks-passed.png"
}
}
]
}
]
}
'import requests
url = "https://api.apiyi.com/v1/messages"
payload = {
"model": "deepseek-v4-flash-vision-exp",
"max_tokens": 800,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image? Answer in one sentence."
},
{
"type": "image",
"source": {
"type": "url",
"url": "https://docs.apiyi.com/images/checks-passed.png"
}
}
]
}
]
}
headers = {
"anthropic-version": "<anthropic-version>",
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'anthropic-version': '<anthropic-version>',
'x-api-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'deepseek-v4-flash-vision-exp',
max_tokens: 800,
messages: [
{
role: 'user',
content: [
{type: 'text', text: 'What is in this image? Answer in one sentence.'},
{
type: 'image',
source: {type: 'url', url: 'https://docs.apiyi.com/images/checks-passed.png'}
}
]
}
]
})
};
fetch('https://api.apiyi.com/v1/messages', 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/messages",
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',
'max_tokens' => 800,
'messages' => [
[
'role' => 'user',
'content' => [
[
'type' => 'text',
'text' => 'What is in this image? Answer in one sentence.'
],
[
'type' => 'image',
'source' => [
'type' => 'url',
'url' => 'https://docs.apiyi.com/images/checks-passed.png'
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"anthropic-version: <anthropic-version>",
"x-api-key: <api-key>"
],
]);
$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/messages"
payload := strings.NewReader("{\n \"model\": \"deepseek-v4-flash-vision-exp\",\n \"max_tokens\": 800,\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\",\n \"source\": {\n \"type\": \"url\",\n \"url\": \"https://docs.apiyi.com/images/checks-passed.png\"\n }\n }\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("anthropic-version", "<anthropic-version>")
req.Header.Add("x-api-key", "<api-key>")
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/messages")
.header("anthropic-version", "<anthropic-version>")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"deepseek-v4-flash-vision-exp\",\n \"max_tokens\": 800,\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\",\n \"source\": {\n \"type\": \"url\",\n \"url\": \"https://docs.apiyi.com/images/checks-passed.png\"\n }\n }\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["anthropic-version"] = '<anthropic-version>'
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"deepseek-v4-flash-vision-exp\",\n \"max_tokens\": 800,\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\",\n \"source\": {\n \"type\": \"url\",\n \"url\": \"https://docs.apiyi.com/images/checks-passed.png\"\n }\n }\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "a5cb230d-ac08-43ed-8c4b-8f88b37119d3",
"type": "message",
"role": "assistant",
"model": "deepseek-v4-flash-vision-exp",
"content": [
{
"type": "text",
"text": "The image shows a notification stating that all checks have passed, including a successful Mintlify deployment."
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 295,
"output_tokens": 51,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0
}
}{
"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 Messages API Reference
Справочник и песочница Anthropic-native /v1/messages API для deepseek-v4-flash-vision-exp: источники изображений base64 и URL, переключатель thinking, полный round trip инструментов. Требуется token группы ClaudeCode.
curl --request POST \
--url https://api.apiyi.com/v1/messages \
--header 'Content-Type: application/json' \
--header 'anthropic-version: <anthropic-version>' \
--header 'x-api-key: <api-key>' \
--data '
{
"model": "deepseek-v4-flash-vision-exp",
"max_tokens": 800,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image? Answer in one sentence."
},
{
"type": "image",
"source": {
"type": "url",
"url": "https://docs.apiyi.com/images/checks-passed.png"
}
}
]
}
]
}
'import requests
url = "https://api.apiyi.com/v1/messages"
payload = {
"model": "deepseek-v4-flash-vision-exp",
"max_tokens": 800,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image? Answer in one sentence."
},
{
"type": "image",
"source": {
"type": "url",
"url": "https://docs.apiyi.com/images/checks-passed.png"
}
}
]
}
]
}
headers = {
"anthropic-version": "<anthropic-version>",
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'anthropic-version': '<anthropic-version>',
'x-api-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'deepseek-v4-flash-vision-exp',
max_tokens: 800,
messages: [
{
role: 'user',
content: [
{type: 'text', text: 'What is in this image? Answer in one sentence.'},
{
type: 'image',
source: {type: 'url', url: 'https://docs.apiyi.com/images/checks-passed.png'}
}
]
}
]
})
};
fetch('https://api.apiyi.com/v1/messages', 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/messages",
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',
'max_tokens' => 800,
'messages' => [
[
'role' => 'user',
'content' => [
[
'type' => 'text',
'text' => 'What is in this image? Answer in one sentence.'
],
[
'type' => 'image',
'source' => [
'type' => 'url',
'url' => 'https://docs.apiyi.com/images/checks-passed.png'
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"anthropic-version: <anthropic-version>",
"x-api-key: <api-key>"
],
]);
$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/messages"
payload := strings.NewReader("{\n \"model\": \"deepseek-v4-flash-vision-exp\",\n \"max_tokens\": 800,\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\",\n \"source\": {\n \"type\": \"url\",\n \"url\": \"https://docs.apiyi.com/images/checks-passed.png\"\n }\n }\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("anthropic-version", "<anthropic-version>")
req.Header.Add("x-api-key", "<api-key>")
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/messages")
.header("anthropic-version", "<anthropic-version>")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"deepseek-v4-flash-vision-exp\",\n \"max_tokens\": 800,\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\",\n \"source\": {\n \"type\": \"url\",\n \"url\": \"https://docs.apiyi.com/images/checks-passed.png\"\n }\n }\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["anthropic-version"] = '<anthropic-version>'
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"deepseek-v4-flash-vision-exp\",\n \"max_tokens\": 800,\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\",\n \"source\": {\n \"type\": \"url\",\n \"url\": \"https://docs.apiyi.com/images/checks-passed.png\"\n }\n }\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "a5cb230d-ac08-43ed-8c4b-8f88b37119d3",
"type": "message",
"role": "assistant",
"model": "deepseek-v4-flash-vision-exp",
"content": [
{
"type": "text",
"text": "The image shows a notification stating that all checks have passed, including a successful Mintlify deployment."
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 295,
"output_tokens": 51,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0
}
}{
"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>"
}
}ClaudeCode. Это жёсткое требование.Использование группы default приводит к двум наслаивающимся проблемам:- Если не указывать
top_p, каждый раз возвращается 400Invalid top_p value - Даже если
top_pуказан, повторная отправка блокаthinkingиз первого хода во второй ход возвращаетunknown variant 'thinking', expected one of 'text', 'image_url', 'file'—— а стандартные клиенты, такие как Claude Code и Anthropic SDK, всегда повторно отправляют его, поэтому многоходовой режим всегда ломается
ClaudeCode, и ни одна из этих проблем не возникнет. Для формата OpenAI используйте
Песочницу чата вместо этого.sk-your-apiyi-key в x-api-key
(токен ClaudeCode, без префикса Bearer ) и оставьте anthropic-version на 2023-06-01.
В примере используется общедоступное изображение и отключён thinking, так что вы можете нажать «Отправить» и сразу увидеть
ответ.Краткая справка по параметрам
| Параметр | Тип | Обязательный | По умолчанию | Примечания |
|---|---|---|---|---|
model | string | ✓ | — | Всегда deepseek-v4-flash-vision-exp |
max_tokens | int | ✓ | — | Требуется в формате Anthropic, жесткий предел 393,216; используйте 2000+ при включённом thinking |
messages | array | ✓ | — | content — это строка или массив блоков содержимого |
system | string | — | Системный prompt | |
thinking.type | string | enabled | disabled оставляет только блок text в content | |
thinking.budget_tokens | int | — | Бюджет рассуждения при enabled | |
stream | bool | false | SSE-потоковая передача со стандартной последовательностью событий Anthropic | |
top_p | number | — | Необязательно в группе ClaudeCode | |
temperature / top_k / stop_sequences | — | — | Все вступают в силу | |
tools | array | — | Стандартный формат Anthropic input_schema |
Two ways to send an image
source.type = "base64"
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": "<BASE64>"
}
}
data не содержит префикса data:image/jpeg;base64, —— это отличается от формата
OpenAI.
source.type = "url"
{
"type": "image",
"source": {"type": "url", "url": "https://example.com/image.jpg"}
}
source.type = "url" работает только в группе ClaudeCode; группа default возвращает
You have uploaded an unsupported image.source.type = "file" требует Files API, который эта платформа не предоставляет.Содержимое ответа представляет собой массив блоков
| Случай | content |
|---|---|
| По умолчанию (рассуждение включено) | [{"type": "thinking", ...}, {"type": "text", ...}] |
thinking.type = "disabled" | [{"type": "text", ...}] |
| При вызове инструмента | [{"type": "thinking", ...}, {"type": "tool_use", ...}] |
ClaudeCode блок thinking содержит поле signature, а потоковая передача также выдает signature_delta.
Многоходовый диалог и возврат через инструмент
Поместите весьcontent предыдущего хода ассистента обратно в messages —— включая блок
thinking, не удаляйте его —— затем добавьте tool_result:
{
"model": "deepseek-v4-flash-vision-exp",
"max_tokens": 1500,
"tools": [{
"name": "record_shape",
"input_schema": {
"type": "object",
"properties": {
"shape": {"type": "string"},
"color": {"type": "string"}
},
"required": ["shape", "color"]
}
}],
"messages": [
{"role": "user", "content": [
{"type": "text", "text": "Look at the image and call record_shape."},
{"type": "image", "source": {"type": "url", "url": "https://example.com/shape.jpg"}}
]},
{"role": "assistant", "content": "<the content array returned by the previous turn, verbatim>"},
{"role": "user", "content": [
{"type": "tool_result", "tool_use_id": "<the tool_use id from the previous turn>", "content": "{\"ok\":true}"}
]}
]
}
default возвращает 400,
и именно по этому пути идет каждый клиент в стиле Claude Code —— поэтому группа должна быть правильной.
Как читаются поля кэша
Применяется автоматическое кэширование префикса, сопоставленное со стандартными полями Anthropic:| Поле | Поведение |
|---|---|
cache_read_input_tokens | Размер попадания в автоматический кэш префикса. Попадание останавливается перед первым изображением; сами изображения никогда не кэшируются |
cache_creation_input_tokens | Всегда 0. Upstream использует автоматическое кэширование префикса и игнорирует явные маркеры cache_control |
input_tokens | После попадания здесь хранится только некэшированный остаток, в отличие от формата OpenAI, где prompt_tokens всегда равно полному количеству. Эти два значения нельзя напрямую согласовать |
Распространённые ошибки
| Ошибка | Причина |
|---|---|
Invalid top_p value, the valid range of top_p is (0, 1.0] | Токен группы default без top_p —— переключитесь на ClaudeCode |
unknown variant 'thinking' | Токен группы default, повторно отправляющий блок thinking —— переключитесь на ClaudeCode |
You have uploaded an unsupported image | Неподдерживаемый формат или токен группы default с source.type = "url" |
Image in assistant message is unsupported | Изображения могут появляться только в сообщениях user |
image file size exceeds limit 32 MB | Изображение больше 32 MiB |
Авторизации
Your APIYI token, the raw sk- key. The token must be in the ClaudeCode group
Заголовки
Anthropic API version, always 2023-06-01
Тело
Model ID, always deepseek-v4-flash-vision-exp
deepseek-v4-flash-vision-exp Output token budget (required in the Anthropic format), hard ceiling 393,216. Use 2000 or more with thinking on
x <= 393216Message array. content is either a plain string or an array of content blocks for mixed text and images
Show child attributes
Show child attributes
System prompt
Thinking toggle. With {"type": "disabled"} the response content holds only a text block. Works in both groups on this endpoint
Show child attributes
Show child attributes
Stream the response over SSE, emitting the standard Anthropic message_start / content_block_delta / message_stop events
Sampling temperature
Nucleus sampling threshold. Optional in the ClaudeCode group; in the default group, omitting it returns 400
Candidate cutoff
Stop sequences
Tool list in the standard Anthropic input_schema format. Verified with streaming increments and a full two-turn round trip
Ответ
Generation succeeded
Array of content blocks. [thinking, text] with thinking on, just [text] with it off, and [thinking, tool_use] when calling a tool
Usage. Note this differs from the OpenAI format: after a cache hit input_tokens holds only the uncached remainder, so it cannot be reconciled with prompt_tokens directly
Show child attributes
Show child attributes
Была ли эта страница полезной?