Anthropic 형식
POST /v1/messages는 Anthropic Messages 형식의 요청을 받아 스트리밍 여부와 관계없이 같은 형식으로 응답합니다. Anthropic SDK 및 이를 기반으로 하는 Claude Code 같은 도구와 함께 사용하세요. base URL을 설정하고, Shannon API 키를 사용하며, Shannon 모델 id를 지정하면 됩니다.
POST https://api.shannon-ai.com/v1/messages
Anthropic SDK가 Shannon base URL을 가리키게 하세요. SDK가 /v1/messages를 붙이고 x-api-key 헤더에 키를 담아 보냅니다.
import anthropic
client = anthropic.Anthropic(
api_key="YOUR_API_KEY",
base_url="https://api.shannon-ai.com",
)
message = client.messages.create(
model="shannon-3",
max_tokens=1024,
messages=[{"role": "user", "content": "Say hello in one sentence."}],
)
for block in message.content:
if block.type == "text":
print(block.text) import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.shannon-ai.com",
});
const message = await client.messages.create({
model: "shannon-3",
max_tokens: 1024,
messages: [{ role: "user", content: "Say hello in one sentence." }],
});
for (const block of message.content) {
if (block.type === "text") console.log(block.text);
} curl https://api.shannon-ai.com/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "shannon-3",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Say hello in one sentence."}]
}' 응답은 content가 블록 목록인 메시지입니다. 블록은 type으로 찾으세요. 모델이 추론했다면 첫 블록이 thinking이고 텍스트는 그 뒤에 옵니다.
{
"id": "msg_5f0c1e7a9b3d4c62a8e1f07d2b46c9a3",
"type": "message",
"role": "assistant",
"model": "shannon-3",
"content": [
{
"type": "thinking",
"thinking": "The user wants a greeting in one sentence. Keep it short and friendly."
},
{
"type": "text",
"text": "Hello, it is good to meet you."
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 1184,
"output_tokens": 46
}
} 헤더
| 헤더 | 값 | 설명 |
|---|---|---|
x-api-key | YOUR_API_KEY | API 키입니다. 대신 Authorization: Bearer YOUR_API_KEY도 사용할 수 있습니다. |
content-type | application/json | 필수. |
anthropic-version | 2023-06-01 | 허용되지만 필수는 아닙니다. Anthropic SDK는 2023-06-01을 보내며, 값에 상관없이 응답 형식은 같습니다. |
anthropic-beta | 허용되지만 필수는 아닙니다. | |
x-request-id | 선택 사항. 요청에 붙이는 사용자 고유의 id입니다. 응답에 그대로 반환되며, 없으면 응답에 십육진수 문자 12개로 된 id가 포함됩니다. |
요청 필드
필수 필드는 messages뿐입니다. 적용 대상 열에는 해당 필드가 응답을 바꾸는 모델이 나와 있습니다. 호스팅 오픈 웨이트 모델은 모델 목록의 열두 개 id이며, Shannon 3 제품군은 shannon-3, shannon-3-pro, shannon-3.1, shannon-3.1-pro입니다. 모델 및 가격
| 필드 | 유형 | 기본값 | 설명 | 적용 대상 |
|---|---|---|---|---|
model | string | shannon-1.6-lite | 모델 목록에 있는 Shannon 모델 id입니다. 모든 요청에 보내세요. 대소문자를 구분하지 않고 일치시킵니다. 다른 이름은 400 unknown model을 반환하므로, 자체 모델 이름을 보내는 도구는 Shannon id로 설정해야 합니다. | 모든 모델 |
messages | array | 필수. 가장 오래된 메시지부터 순서대로 나열한 대화이며, 역할은 user와 assistant입니다. 아래의 메시지와 콘텐츠 블록을 참조하세요. | 모든 모델 | |
system | string | array | 모델에 대한 지침입니다. 문자열 또는 텍스트 블록 배열입니다. 아래의 시스템 프롬프트를 참조하세요. | 호스팅 오픈 웨이트 모델, shannon-1.6-*, shannon-2-*, shannon-coder-1 | |
max_tokens | integer | 4096 | 응답의 상한(토큰 단위)입니다. 이 엔드포인트에서는 선택 사항이지만 Anthropic SDK는 항상 보냅니다. 1에서 65,536 범위를 벗어난 값은 해당 범위로 조정됩니다. 요청이 실행되는 동안 잔액에서 따로 확보해 두는 양이기도 합니다. | 호스팅 오픈 웨이트 모델, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 |
stream | boolean | false | true이면 응답을 server-sent events로 보냅니다. 아래의 스트리밍을 참조하세요. | 모든 모델 |
temperature | number | 샘플링 temperature. 호스팅 오픈 웨이트 모델에서는 값이 0에서 2 사이로 유지됩니다. | 호스팅 오픈 웨이트 모델, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 | |
top_p | number | Nucleus 샘플링. | 호스팅 오픈 웨이트 모델 | |
stop_sequences | array | 최대 4개의 문자열. 가장 먼저 나타나는 문자열 앞에서 답변이 끝납니다. stop_reason은 end_turn으로 유지됩니다. | 호스팅 오픈 웨이트 모델 | |
tools | array | 모델이 호출할 수 있는 도구이며, 각각 {"name", "description", "input_schema"} 형태입니다. 아래의 도구를 참조하세요. | 모든 모델 | |
tool_choice | object | {"type": "auto"}는 모델이 결정하게 하고, {"type": "any"}는 모델이 도구를 호출하게 하며, {"type": "tool", "name": "…"}는 모델이 해당 도구를 호출하게 합니다. | 호스팅 오픈 웨이트 모델 | |
thinking | object | 모델이 답하기 전에 얼마나 추론할지 정합니다. 아래의 Thinking을 참조하세요. | 호스팅 오픈 웨이트 모델 | |
web_search | boolean | false | 이 형식에 대한 Shannon의 추가 기능: true이면 모델이 답하기 전에 웹을 검색합니다. | shannon-1.6-*, shannon-2-*, Shannon 3 제품군 |
max_tokens가 없으면 값은 4,096이고, shannon-coder-1에서는 65,536입니다.
기존 클라이언트 코드가 변경 없이 실행되도록 metadata, top_k, service_tier, 그리고 블록의 cache_control 마커를 허용합니다. 이들은 응답을 바꾸지 않으며, 호스팅 오픈 웨이트 모델의 프롬프트 캐싱은 자동입니다.
스키마에 맞는 JSON 답변은 Chat Completions에서는 response_format으로, Responses에서는 text.format으로 요청합니다. 구조화된 출력
시스템 프롬프트와 thinking을 포함한 요청
이 요청은 시스템 프롬프트, thinking 예산, temperature, 중단 시퀀스를 보냅니다. 이 모두를 적용하는 호스팅 오픈 웨이트 모델을 사용합니다.
import anthropic
client = anthropic.Anthropic(
api_key="YOUR_API_KEY",
base_url="https://api.shannon-ai.com",
)
message = client.messages.create(
model="DeepSeek-V4-Flash-0731-W4A16-AUTOROUND-REAP",
max_tokens=4096,
system="You are a physics teacher. Answer in two sentences.",
thinking={"type": "enabled", "budget_tokens": 2048},
temperature=0.3,
stop_sequences=["\n\n"],
messages=[{"role": "user", "content": "Why is the sky blue?"}],
)
for block in message.content:
if block.type == "thinking":
print("reasoning:", block.thinking)
elif block.type == "text":
print("answer:", block.text)
print(message.usage) import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.shannon-ai.com",
});
const message = await client.messages.create({
model: "DeepSeek-V4-Flash-0731-W4A16-AUTOROUND-REAP",
max_tokens: 4096,
system: "You are a physics teacher. Answer in two sentences.",
thinking: { type: "enabled", budget_tokens: 2048 },
temperature: 0.3,
stop_sequences: ["\n\n"],
messages: [{ role: "user", content: "Why is the sky blue?" }],
});
for (const block of message.content) {
if (block.type === "thinking") console.log("reasoning:", block.thinking);
if (block.type === "text") console.log("answer:", block.text);
}
console.log(message.usage); curl https://api.shannon-ai.com/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "DeepSeek-V4-Flash-0731-W4A16-AUTOROUND-REAP",
"max_tokens": 4096,
"system": "You are a physics teacher. Answer in two sentences.",
"thinking": {"type": "enabled", "budget_tokens": 2048},
"temperature": 0.3,
"stop_sequences": ["\n\n"],
"messages": [{"role": "user", "content": "Why is the sky blue?"}]
}' 호스팅 오픈 웨이트 모델에서는 usage가 프롬프트 캐시에서 읽은 토큰을 다른 입력 토큰과 구분해서 보고합니다.
{
"usage": {
"input_tokens": 31,
"cache_read_input_tokens": 0,
"cache_creation_input_tokens": 0,
"output_tokens": 62
}
} 시스템 프롬프트
system은 문자열이거나 [{"type": "text", "text": "…"}] 형태의 텍스트 블록 배열입니다. 블록의 텍스트는 줄바꿈으로 이어 붙여집니다.
호스팅 오픈 웨이트 모델, shannon-1.6-lite, shannon-1.6-pro, shannon-2-lite, shannon-2-pro, shannon-coder-1에서 적용됩니다. Shannon 3 제품군 id에서는 반드시 지켜야 하는 지침을 사용자 메시지에 넣으세요.
메시지와 콘텐츠 블록
메시지에는 user 또는 assistant인 role과 content가 있습니다. content는 문자열이거나 블록 배열입니다.
| 블록 | 설명 | 사용 가능 대상 |
|---|---|---|
{"type": "text", "text": "…"} | 텍스트. | 모든 모델 |
{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "…"}}{"type": "image", "source": {"type": "url", "url": "…"}} | user 메시지에 담긴 이미지. base64 또는 URL로 전달합니다. | Shannon 3 제품군, shannon-1.6-lite, shannon-1.6-pro, 그리고 이미지 입력을 지원하는 호스팅 오픈 웨이트 모델 |
{"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "…"}} | user 메시지에 담긴 문서(PDF, Word, PowerPoint 또는 Excel). base64 또는 URL로 전달합니다. | Shannon 3 제품군 |
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} | assistant 메시지에서: 모델이 이전 응답에서 수행한 도구 호출. | 모든 모델 |
{"type": "tool_result", "tool_use_id": "toolu_…", "content": "…"} | user 메시지에서: 해당 호출의 결과. content는 문자열이거나 텍스트 블록 목록입니다. | 모든 모델 |
이전 응답의 content를 그대로 다시 보낼 수 있습니다. text와 tool_use 블록은 읽히고 thinking 블록은 건너뜁니다.
Shannon 티어에서는 이미지와 문서를 마지막 user 메시지에서 읽습니다. 크기와 제한은 별도 페이지에 있습니다. 이미지와 파일
Thinking
호스팅 오픈 웨이트 모델은 thinking을 추론 effort에 매핑합니다. 필드가 없으면 effort는 높음입니다.
| 형태 | budget_tokens | 효과 |
|---|---|---|
{"type": "disabled"} | 추론 없음. 응답에 thinking 블록이 없습니다. | |
{"type": "enabled", "budget_tokens": 2048} | ≤ 2,048 | 낮은 effort. |
{"type": "enabled", "budget_tokens": 8192} | ≤ 8,192 | 중간 effort. |
{"type": "enabled", "budget_tokens": 16000} | > 8,192 | 높은 effort. |
추론하는 모델은 추론 내용을 텍스트 앞에 {"type": "thinking", "thinking": "…"} 블록으로 반환합니다. 추론하는 Shannon 티어도 이를 보냅니다.
effort 수준은 별도 페이지에서 설명합니다. 추론 effort
도구
도구는 사용자의 코드가 실행하는 함수입니다. 각 도구를 name, description, input_schema로 설명하세요. 모델이 도구를 원하면 응답에 tool_use 블록이 들어 있고 stop_reason은 tool_use입니다.
tools의 도구 정의:
[
{
"name": "get_weather",
"description": "Current weather for a city.",
"input_schema": {
"type": "object",
"properties": {
"city": {
"type": "string"
}
},
"required": [
"city"
]
}
}
] 도구를 호출하는 응답의 content:
[
{
"type": "text",
"text": ""
},
{
"type": "tool_use",
"id": "toolu_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
"name": "get_weather",
"input": {
"city": "Paris"
}
}
] 도구를 실행한 뒤, 호출과 tool_result 블록을 messages에 추가해 요청을 다시 보내세요:
[
{
"role": "user",
"content": "What is the weather in Paris?"
},
{
"role": "assistant",
"content": [
{
"type": "tool_use",
"id": "toolu_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
"name": "get_weather",
"input": {
"city": "Paris"
}
}
]
},
{
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": "toolu_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
"content": "{\"temperature_c\": 18, \"sky\": \"cloudy\"}"
}
]
}
] tool_choice
| 형태 | 효과 | 적용 대상 |
|---|---|---|
{"type": "auto"} | 모델이 도구를 호출할지 결정합니다. 기본값입니다. | 모든 모델 |
{"type": "any"} | 모델은 도구 중 하나를 반드시 호출해야 합니다. | 호스팅 오픈 웨이트 모델 |
{"type": "tool", "name": "…"} | 모델은 지정된 도구를 반드시 호출해야 합니다. | 호스팅 오픈 웨이트 모델 |
input_schema가 있는 도구만 읽습니다. 웹 검색은 이 엔드포인트에서 도구가 아닙니다. web_search 필드를 설정하세요.
도구 루프는 별도 페이지에서 자세히 설명합니다. 함수 호출
응답
| 필드 | 유형 | 설명 | 전송 주체 |
|---|---|---|---|
id | string | msg_ 뒤에 십육진수 문자 32개가 붙습니다. | 모든 모델 |
type | string | 항상 message입니다. | 모든 모델 |
role | string | 항상 assistant입니다. | 모든 모델 |
model | string | 응답한 모델의 정식 id입니다. | 모든 모델 |
content | array | 응답의 블록이며 순서는 다음과 같습니다. 모델이 추론했다면 thinking, 그다음 text, 그다음 도구 호출마다 tool_use 하나씩. | 모든 모델 |
stop_reason | string | 응답이 끝난 이유입니다. 아래의 값을 참조하세요. | 모든 모델 |
usage | object | input_tokens와 output_tokens입니다. | 모든 모델 |
sources | array | web_search: true로 보낸 요청에서 검색이 결과를 찾았을 때만 있습니다. 모델에 전달된 결과이며 각각 index, title, url을 포함합니다. 답변의 [1]은 index가 1인 항목입니다. 스트림에서는 message_delta 이벤트와 함께 옵니다. | shannon-1.6-*, shannon-2-*, Shannon 3 제품군 |
usage.cache_read_input_tokens | integer | cache_read_input_tokens는 프롬프트 중 캐시에서 읽은 부분이고, input_tokens는 나머지입니다. cache_creation_input_tokens는 항상 0입니다. | 호스팅 오픈 웨이트 모델 |
응답 블록
| 블록 | 설명 |
|---|---|
{"type": "thinking", "thinking": "…"} | 모델의 추론입니다. signature 멤버는 없습니다. |
{"type": "text", "text": "…"} | 답변 텍스트입니다. 응답이 도구 호출이면 비어 있을 수 있습니다. |
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} | 도구 호출입니다. input은 JSON 객체입니다. 결과는 같은 id로 되돌려 보내세요. |
stop_reason
| stop_reason | 설명 | 전송 주체 |
|---|---|---|
end_turn | 모델이 답변을 마쳤거나, stop_sequences 중 하나가 나타났습니다. | 모든 모델 |
tool_use | 응답에 하나 이상의 도구 호출이 있습니다. | 모든 모델 |
max_tokens | 출력 한도에서 응답이 잘렸습니다. | Shannon 3 제품군, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1, 스트림에서 |
스트리밍
server-sent events를 받으려면 stream을 true로 설정하세요. 각 프레임에는 이벤트 이름이 있는 event: 줄과, type에 같은 이름을 반복하는 JSON 객체가 있는 data: 줄이 있습니다. Anthropic SDK의 스트림 헬퍼가 이 이벤트를 대신 읽어 줍니다:
import anthropic
client = anthropic.Anthropic(
api_key="YOUR_API_KEY",
base_url="https://api.shannon-ai.com",
)
with client.messages.stream(
model="shannon-3",
max_tokens=1024,
messages=[{"role": "user", "content": "Explain server-sent events in three sentences."}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
message = stream.get_final_message()
print()
print(message.stop_reason, message.usage) import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.shannon-ai.com",
});
const stream = client.messages.stream({
model: "shannon-3",
max_tokens: 1024,
messages: [{ role: "user", content: "Explain server-sent events in three sentences." }],
});
stream.on("text", (text) => process.stdout.write(text));
const message = await stream.finalMessage();
console.log("\n", message.stop_reason, message.usage); curl -N https://api.shannon-ai.com/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "shannon-3",
"max_tokens": 1024,
"stream": true,
"messages": [{"role": "user", "content": "Explain server-sent events in three sentences."}]
}' 이벤트가 도착하는 순서는 다음과 같습니다:
| 이벤트 | 데이터 | 시점 |
|---|---|---|
message_start | message | 항상 가장 먼저 옵니다. message에는 id, 역할, 모델, 빈 content, 영에서 시작하는 usage가 들어 있습니다. |
content_block_start | index, content_block | 블록이 열립니다. content_block은 빈 text 또는 thinking 블록이거나, id와 name이 있는 tool_use 블록입니다. |
content_block_delta | index, delta {"type": "thinking_delta", "thinking"} | thinking 블록에서 추론의 일부입니다. |
content_block_delta | index, delta {"type": "text_delta", "text"} | text 블록에서 답변의 일부입니다. |
content_block_delta | index, delta {"type": "input_json_delta", "partial_json"} | tool_use 블록에서 도구 호출의 인자이며, 하나의 델타로 완전하게 전달됩니다. |
content_block_stop | index | 이 index의 블록이 끝났습니다. |
message_delta | delta {stop_reason, stop_sequence}, usage | 응답의 끝입니다. delta.stop_reason과 요청의 usage가 들어 있습니다. |
message_stop | 항상 마지막에 옵니다. |
블록은 열리는 순서대로 index로 번호가 매겨지며, 한 블록이 끝난 뒤에 다음 블록이 열립니다. 각 블록은 번호가 아니라 유형으로 읽으세요. 스트림이 먼저 빈 text 블록을 열고, 이어서 thinking 블록을 열고, 답변은 그 뒤의 text 블록으로 전달할 수 있습니다.
event: message_start
data: {"type":"message_start","message":{"id":"msg_5f0c…","type":"message","role":"assistant","model":"shannon-3","content":[],"usage":{"input_tokens":0,"output_tokens":0}}}
event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
event: content_block_stop
data: {"type":"content_block_stop","index":0}
event: content_block_start
data: {"type":"content_block_start","index":1,"content_block":{"type":"thinking","thinking":""}}
event: content_block_delta
data: {"type":"content_block_delta","index":1,"delta":{"type":"thinking_delta","thinking":"Three sentences: what it is, how it is framed, why it is used."}}
event: ping
data: {"type": "ping"}
event: content_block_stop
data: {"type":"content_block_stop","index":1}
event: content_block_start
data: {"type":"content_block_start","index":2,"content_block":{"type":"text","text":""}}
event: content_block_delta
data: {"type":"content_block_delta","index":2,"delta":{"type":"text_delta","text":"Server-sent events let a server push text over one HTTP reply."}}
event: content_block_stop
data: {"type":"content_block_stop","index":2}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"input_tokens":1190,"output_tokens":84}}
event: message_stop
data: {"type":"message_stop"} Keep-alive
| 전송 주체 | 설명 |
|---|---|
Shannon 3 제품군, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 | 데이터가 {"type": "ping"}인 ping 이벤트이며, 15초마다 전송됩니다. |
| 호스팅 오픈 웨이트 모델 | 주석 줄 : keepalive이며, 모델이 작업하는 동안 15초마다 전송됩니다. |
실패하는 스트림
스트림이 시작된 뒤의 실패는 오류 응답과 같은 본문을 가진 error 이벤트로 전달됩니다: {"type": "error", "error": {"type", "message"}}. 마무리 이벤트인 message_delta와 message_stop은 그대로 뒤따릅니다. 응답을 실패로 처리하고 요청을 다시 보내세요.
오류
오류는 Anthropic 오류 본문 형식을 사용합니다. type은 error이고, error 객체에는 type과 message가 들어 있습니다. 표에는 이 엔드포인트가 가장 자주 반환하는 오류가 나와 있습니다. 재시도해야 하는 경우를 포함한 전체 목록은 별도 페이지에 있습니다. 오류 처리
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "unknown model: no-such-model"
}
} | 상태 | 유형 | 메시지 | 시점 |
|---|---|---|---|
401 | authentication_error | Missing authenticationInvalid API key | API 키를 보내지 않았거나, 키를 알 수 없거나 폐기되었습니다. |
400 | invalid_request_error | unknown model: <id> | model이 Shannon 모델 id가 아닙니다. |
400 | invalid_request_error | No user message provided | Shannon 티어: 요청에 사용자 텍스트도 tools도 없습니다. |
400 | invalid_request_error | <id> does not accept image input | 이미지 입력을 지원하지 않는 호스팅 오픈 웨이트 모델에 이미지를 보냈습니다. |
422 | invalid_request_error | Failed to deserialize the JSON body into the target type: … | messages가 없거나, 필드의 JSON 타입이 잘못되었습니다. |
429 | rate_limit_error | Quota exceeded. Upgrade your plan at shannon-ai.com/plan | max_tokens가 남은 잔액보다 큽니다. |
429 | rate_limit_error | Too many requests. Retry in <n>s. | 플러드 보호: 계정에서 분당 120건을 초과하는 요청이 있었습니다. |
429 | rate_limit_error | Shannon Coder call quota reached. Upgrade your plan at shannon-ai.com/plan | shannon-coder-1: 현재 4시간 구간에 대한 플랜의 Shannon Coder 호출 횟수를 모두 사용했습니다. |
500 | server_error | The model backend failed to answer. Please retry. | 모델이 응답을 생성하지 못했습니다. 요청을 다시 보내세요. |
502 | api_error | The model backend failed to answer. Please retry. | 모델이 응답을 생성하지 못했습니다. 요청을 다시 보내세요. |
토큰 계산
POST /v1/messages/count_tokens는 메시지 요청과 동일한 본문(model, system, messages, tools)을 받아 {"input_tokens": n}을 반환합니다. 이는 해당 요청에 청구될 입력 토큰 수입니다. 호스팅 오픈 웨이트 모델에 대해 계산할 수 있으며, 무료이고 플러드 보호에 집계되지 않습니다.
import anthropic
client = anthropic.Anthropic(
api_key="YOUR_API_KEY",
base_url="https://api.shannon-ai.com",
)
count = client.messages.count_tokens(
model="DeepSeek-V4-Flash-0731-W4A16-AUTOROUND-REAP",
system="You are a physics teacher. Answer in two sentences.",
messages=[{"role": "user", "content": "Why is the sky blue?"}],
)
print(count.input_tokens) import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.shannon-ai.com",
});
const count = await client.messages.countTokens({
model: "DeepSeek-V4-Flash-0731-W4A16-AUTOROUND-REAP",
system: "You are a physics teacher. Answer in two sentences.",
messages: [{ role: "user", content: "Why is the sky blue?" }],
});
console.log(count.input_tokens); curl https://api.shannon-ai.com/v1/messages/count_tokens \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "DeepSeek-V4-Flash-0731-W4A16-AUTOROUND-REAP",
"system": "You are a physics teacher. Answer in two sentences.",
"messages": [{"role": "user", "content": "Why is the sky blue?"}]
}'
# {"input_tokens": 31} 토큰 계산은 별도 페이지에서 일반 텍스트 엔드포인트와 제한과 함께 설명합니다. 토큰 수 계산