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": "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
DeepSeek V4 Flash Vision 메시지 API 레퍼런스
Anthropic 네이티브 /v1/messages API 레퍼런스 및 deepseek-v4-flash-vision-exp용 플레이그라운드입니다. base64 및 URL 이미지 소스, thinking 토글, 전체 tools 왕복을 지원합니다. ClaudeCode 그룹 token이 필요합니다.
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": "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>"
}
}이 엔드포인트의 token은
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에 입력하고
(Bearer 접두사가 없는 ClaudeCode token) anthropic-version은 2023-06-01으로 유지하십시오.
이 예제에서는 공개 이미지를 사용하고 추론 기능이 비활성화되어 있으므로, 전송을 클릭하면 즉시
응답을 확인할 수 있습니다.매개변수 빠른 참조
| 매개변수 | 유형 | 필수 | 기본값 | 비고 |
|---|---|---|---|---|
model | 문자열 | ✓ | — | 항상 deepseek-v4-flash-vision-exp |
max_tokens | 정수 | ✓ | — | Anthropic 형식에서 필수이며, 하드 상한은 393,216입니다. 추론을 활성화할 때는 2000 이상을 사용합니다 |
messages | 배열 | ✓ | — | content는 문자열 또는 콘텐츠 블록 배열입니다 |
system | 문자열 | — | 시스템 프롬프트 | |
thinking.type | 문자열 | enabled | disabled은 content에 text 블록만 남깁니다 | |
thinking.budget_tokens | 정수 | — | enabled일 때의 추론 예산 | |
stream | 부울 | false | 표준 Anthropic 이벤트 시퀀스를 사용하는 SSE 스트리밍 | |
top_p | 숫자 | — | ClaudeCode 그룹에서 선택 사항 | |
temperature / top_k / stop_sequences | — | — | 모두 적용됩니다 | |
tools | 배열 | — | 표준 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 |
|---|---|
| 기본값(추론 켜짐) | [{"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 스타일 클라이언트가 이 경로를 사용합니다 —— 따라서 그룹이 올바르게 설정되어야 합니다.
캐시 필드의 의미
APIYI의 Anthropic 네이티브/v1/messages 엔드포인트를 통해 DeepSeek을 호출할 때 캐시 과금을 적용받으려면 token에서 전용 ClaudeCode 그룹을 사용해야 합니다. 이 그룹은 기본적으로 5% 할인을 제공합니다.OpenAI 호환
/v1/chat/completions은 이미 default 그룹에서 캐시 과금을 지원하므로 ClaudeCode를 선택할 필요가 없습니다.실제 캐시 적중 여부는 요청 컨텍스트에 따라 달라지며, 올바른 그룹을 사용하더라도 보장되지 않습니다. 자동 접두사 캐싱이 적용되며, 표준 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] | top_p이 없는 default 그룹 token —— ClaudeCode로 전환합니다 |
unknown variant 'thinking' | thinking 블록을 재생하는 default 그룹 token —— ClaudeCode로 전환합니다 |
You have uploaded an unsupported image | 지원되지 않는 형식이거나 source.type = "url"이 포함된 default 그룹 token입니다 |
Image in assistant message is unsupported | 이미지는 user 메시지에만 표시할 수 있습니다 |
image file size exceeds limit 32 MB | 이미지가 32MiB보다 큽니다 |
인증
본문
application/json
응답
Generation succeeded
이 페이지가 도움이 되었나요?