Messages with vision: DeepSeek V4 Flash Vision (Anthropic format)
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": "这张图里有什么?用一句话描述。"
},
{
"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": "这张图里有什么?用一句话描述。"
},
{
"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: '这张图里有什么?用一句话描述。'},
{
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' => '这张图里有什么?用一句话描述。'
],
[
'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\": \"这张图里有什么?用一句话描述。\"\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\": \"这张图里有什么?用一句话描述。\"\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\": \"这张图里有什么?用一句话描述。\"\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": "图中显示一条提示:所有检查均已通过,其中包含一次成功的 Mintlify 部署。"
}
],
"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
DeepSeek V4 Flash Vision Messages API 参考
deepseek-v4-flash-vision-exp 的 Anthropic 原生 /v1/messages API 参考与在线调试:base64 与外链两种传图方式、思考开关、工具闭环,令牌必须用 ClaudeCode 分组。
POST
/
v1
/
messages
Messages with vision: DeepSeek V4 Flash Vision (Anthropic format)
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": "这张图里有什么?用一句话描述。"
},
{
"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": "这张图里有什么?用一句话描述。"
},
{
"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: '这张图里有什么?用一句话描述。'},
{
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' => '这张图里有什么?用一句话描述。'
],
[
'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\": \"这张图里有什么?用一句话描述。\"\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\": \"这张图里有什么?用一句话描述。\"\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\": \"这张图里有什么?用一句话描述。\"\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": "图中显示一条提示:所有检查均已通过,其中包含一次成功的 Mintlify 部署。"
}
],
"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 格式请改用
Chat 在线调试。右侧 Playground 可直接调试:在 x-api-key 填
sk-your-apiyi-key(ClaudeCode 分组的令牌,
不带 Bearer 前缀),anthropic-version 保持 2023-06-01。
默认示例用的是一张公网图片、并已关闭深度思考,点击发送即可看到响应。参数说明速查
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
model | string | ✓ | — | 固定 deepseek-v4-flash-vision-exp |
max_tokens | int | ✓ | — | Anthropic 格式下必填,硬上限 393,216;开思考建议 2000+ |
messages | array | ✓ | — | content 可以是字符串,也可以是内容块数组 |
system | string | — | 系统提示词 | |
thinking.type | string | enabled | disabled 可关闭,关掉后 content 只剩 text 块 | |
thinking.budget_tokens | int | — | enabled 时的思考预算 | |
stream | bool | false | SSE 流式,标准 Anthropic 事件序列 | |
top_p | number | — | ClaudeCode 分组下可省略 | |
temperature / top_k / stop_sequences | — | — | 均生效 | |
tools | array | — | Anthropic 标准 input_schema 格式 |
两种传图方式
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 是块数组
| 情况 | content |
|---|---|
| 默认(思考开启) | [{"type": "thinking", ...}, {"type": "text", ...}] |
thinking.type = "disabled" | [{"type": "text", ...}] |
| 调用工具时 | [{"type": "thinking", ...}, {"type": "tool_use", ...}] |
ClaudeCode 分组返回的 thinking 块带 signature 字段,流式下也有 signature_delta。
多轮与工具闭环
把上一轮 assistant 的整个content(含 thinking 块,不要剥)原样放回 messages,
再追加 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": "看图,调用 record_shape。"},
{"type": "image", "source": {"type": "url", "url": "https://example.com/shape.jpg"}}
]},
{"role": "assistant", "content": "<上一轮返回的 content 数组,原样放这里>"},
{"role": "user", "content": [
{"type": "tool_result", "tool_use_id": "<上一轮 tool_use 的 id>", "content": "{\"ok\":true}"}
]}
]
}
default 分组会 400 的地方,也是 Claude Code 等客户端
的必经路径 —— 所以分组不能选错。
缓存字段的口径
自动前缀缓存生效,映射到 Anthropic 标准字段:| 字段 | 行为 |
|---|---|
cache_read_input_tokens | 自动前缀缓存命中量。命中范围止于第一张图片之前,图片本身永不进缓存 |
cache_creation_input_tokens | 恒为 0。上游用的是自动前缀缓存,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 |
授权
API易令牌,直接填 sk- 开头的 Key。分组必须为 ClaudeCode
请求头
Anthropic API 版本号,固定 2023-06-01
请求体
application/json
模型 ID,固定 deepseek-v4-flash-vision-exp
可用选项:
deepseek-v4-flash-vision-exp 最大输出 tokens(Anthropic 格式下必填),硬上限 393,216。开思考建议 2000 以上
必填范围:
x <= 393216消息数组。content 可以是字符串,也可以是内容块数组(图文混合)
Show child attributes
Show child attributes
系统提示词
深度思考开关。传 {"type": "disabled"} 关闭后 content 只剩 text 块,本端点两个分组都生效
Show child attributes
Show child attributes
是否流式输出(SSE)。事件为 Anthropic 标准的 message_start / content_block_delta / message_stop 等
采样温度
核采样阈值。ClaudeCode 分组下可省略;default 分组下不传必返回 400
候选截断
停止序列
工具列表,Anthropic 标准 input_schema 格式。实测含流式增量拼装与完整两轮闭环
此页面对您有帮助吗?
⌘I