உள்ளடக்கத்துக்குச் செல்
மானுடவியல் வடிவம்

மானுடவியல் வடிவம்

POST /v1/messages Anthropic Messages வடிவ கோரிக்கையை ஏற்று, streamed ஆகவோ இல்லாமலோ அதே வடிவில் பதிலளிக்கும். Anthropic SDK-யுடனும் Claude Code போன்ற அதன் மேல் கட்டப்பட்ட கருவிகளுடனும் பயன்படுத்துங்கள்: base URL-ஐ அமைத்து, உங்கள் Shannon API key-ஐப் பயன்படுத்தி, ஒரு Shannon மாடல் id-ஐக் கொடுங்கள்.

POST https://api.shannon-ai.com/v1/messages

Anthropic SDK-ஐ Shannon base URL-க்குச் சுட்டுங்கள். SDK /v1/messages-ஐச் சேர்த்து, உங்கள் key-ஐ x-api-key header-ல் அனுப்பும்.

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)

பதில் என்பது content blocks-ன் பட்டியலாக உள்ள ஒரு செய்தி. blocks-ஐ அவற்றின் type மூலம் கண்டறியுங்கள்: மாடல் reasoning செய்திருந்தால் முதல் block thinking ஆகவும், உரை அதன் பின்னும் வரும்.

200 JSON
{
  "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
  }
}

Headers

Header மதிப்பு விளக்கம்
x-api-key YOUR_API_KEY உங்கள் API key. இதற்குப் பதிலாக 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 மட்டுமே கட்டாயம். செயல்படுத்துவது நெடுவரிசை, ஒரு புலம் பதிலை மாற்றும் மாடல்களைக் குறிப்பிடுகிறது. ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்கள் என்பவை மாடல் பட்டியலிலுள்ள பன்னிரண்டு 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 பாத்திரங்களுடன். கீழே உள்ள செய்திகள் மற்றும் content blocks பகுதியைப் பாருங்கள். அனைத்து மாடல்கள்
system string | array மாடலுக்கான அறிவுறுத்தல்கள்: ஒரு string அல்லது உரை blocks-ன் array. கீழே உள்ள System prompt பகுதியைப் பாருங்கள். ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்கள், shannon-1.6-*, shannon-2-*, shannon-coder-1
max_tokens integer 4096 பதிலின் உச்ச வரம்பு, டோக்கன்களில். இந்த endpoint-ல் விருப்பமானது; Anthropic SDK எப்போதும் அனுப்பும். 1 முதல் 65,536 வரம்புக்கு வெளியே உள்ள மதிப்பு அந்த வரம்புக்குள் கொண்டுவரப்படும். கோரிக்கை ஓடும்போது உங்கள் இருப்பிலிருந்து ஒதுக்கி வைக்கப்படும் அளவும் இதுவே. ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்கள், shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1
stream boolean false true பதிலை server-sent events ஆக அனுப்பும். கீழே உள்ள Streaming பகுதியைப் பாருங்கள். அனைத்து மாடல்கள்
temperature number Sampling temperature. ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்களில் மதிப்புகள் 0 முதல் 2 வரை வைக்கப்படும். ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்கள், shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1
top_p number Nucleus sampling. ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்கள்
stop_sequences array 4 strings வரை. தோன்றும் முதல் string-க்கு முன்பே பதில் முடியும். stop_reason end_turn ஆகவே இருக்கும். ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்கள்
tools array மாடல் அழைக்கக்கூடிய tools, ஒவ்வொன்றும் {"name", "description", "input_schema"} வடிவில். கீழே உள்ள Tools பகுதியைப் பாருங்கள். அனைத்து மாடல்கள்
tool_choice object {"type": "auto"} மாடலே முடிவு செய்யும்; {"type": "any"} ஒரு tool-ஐ அழைக்க வைக்கும்; {"type": "tool", "name": "…"} அந்த tool-ஐயே அழைக்க வைக்கும். ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்கள்
thinking object மாடல் பதிலளிக்கும் முன் எவ்வளவு reasoning செய்கிறது. கீழே உள்ள Thinking பகுதியைப் பாருங்கள். ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்கள்
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 குறிகள் ஏற்கப்படுகின்றன, எனவே ஏற்கனவே உள்ள கிளையன்ட் குறியீடு மாற்றமின்றி இயங்கும். அவை பதிலை மாற்றாது; ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்களில் prompt caching தானாக நடக்கும்.

schema-வுக்கு ஏற்ற JSON பதில் Chat Completions-ல் response_format மூலமும், Responses-ல் text.format மூலமும் கேட்கப்படுகிறது. கட்டமைக்கப்பட்ட வெளியீடுகள்

system prompt மற்றும் thinking உடன் ஒரு கோரிக்கை

இந்தக் கோரிக்கை system prompt, thinking budget, temperature மற்றும் stop sequence ஆகியவற்றை அனுப்புகிறது. இது ஹோஸ்ட் செய்யப்பட்ட open-weight மாடலைப் பயன்படுத்துகிறது; அது இவை அனைத்தையும் செயல்படுத்தும்.

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)

ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்களில் usage, prompt cache-லிருந்து படிக்கப்பட்ட டோக்கன்களை மற்ற உள்ளீட்டு டோக்கன்களிலிருந்து தனியாகத் தெரிவிக்கும்.

200 JSON
{
  "usage": {
    "input_tokens": 31,
    "cache_read_input_tokens": 0,
    "cache_creation_input_tokens": 0,
    "output_tokens": 62
  }
}

System prompt

system என்பது ஒரு string, அல்லது [{"type": "text", "text": "…"}] வடிவில் உரை blocks-ன் array. blocks-ன் உரைகள் ஒரு வரி முறிப்புடன் இணைக்கப்படும்.

இதை ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்கள், shannon-1.6-lite, shannon-1.6-pro, shannon-2-lite, shannon-2-pro மற்றும் shannon-coder-1 செயல்படுத்துகின்றன. Shannon 3 குடும்ப id-யுடன், கட்டாயம் பின்பற்றப்பட வேண்டிய அறிவுறுத்தல்களை பயனர் செய்தியில் வையுங்கள்.

செய்திகள் மற்றும் content blocks

ஒரு செய்திக்கு role (user அல்லது assistant) மற்றும் content உண்டு. content ஒரு string அல்லது blocks-ன் array.

Block விளக்கம் கிடைக்கும் இடம்
{"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, மற்றும் பட உள்ளீட்டைப் பட்டியலிடும் ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்கள்
{"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 செய்தியில்: முந்தைய பதிலில் மாடல் செய்த tool அழைப்பு. அனைத்து மாடல்கள்
{"type": "tool_result", "tool_use_id": "toolu_…", "content": "…"} user செய்தியில்: அந்த அழைப்பின் முடிவு. content ஒரு string அல்லது உரை blocks-ன் பட்டியல். அனைத்து மாடல்கள்

முந்தைய பதிலின் content-ஐ அப்படியே திருப்பி அனுப்பலாம்: text மற்றும் tool_use blocks படிக்கப்படும், thinking blocks தவிர்க்கப்படும்.

Shannon நிலைகளில் படங்களும் ஆவணங்களும் கடைசி user செய்தியிலிருந்து படிக்கப்படுகின்றன. அளவுகளும் வரம்புகளும் தனிப் பக்கத்தில் உள்ளன. படங்களும் கோப்புகளும்

Thinking

ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்கள் thinking-ஐ ஒரு reasoning effort-ஆக மாற்றிக்கொள்கின்றன. புலம் இல்லையென்றால் effort உயர்வாக இருக்கும்.

வடிவம் budget_tokens விளைவு
{"type": "disabled"} reasoning இல்லை. பதிலில் thinking block இருக்காது.
{"type": "enabled", "budget_tokens": 2048} ≤ 2,048 குறைந்த effort.
{"type": "enabled", "budget_tokens": 8192} ≤ 8,192 நடுத்தர effort.
{"type": "enabled", "budget_tokens": 16000} > 8,192 உயர் effort.

reasoning செய்யும் மாடல் தன் reasoning-ஐ உரைக்கு முன் {"type": "thinking", "thinking": "…"} block ஆகத் தரும். reasoning செய்யும் Shannon நிலைகளும் அதை அனுப்புகின்றன.

effort நிலைகள் தனிப் பக்கத்தில் விளக்கப்பட்டுள்ளன. Reasoning effort

Tools

tool என்பது உங்கள் குறியீடு இயக்கும் ஒரு செயல்பாடு. ஒவ்வொன்றையும் name, description மற்றும் input_schema மூலம் விவரியுங்கள். மாடலுக்கு ஒரு tool தேவைப்படும்போது, பதிலில் tool_use block இருக்கும், stop_reason tool_use ஆக இருக்கும்.

tools-ல் ஒரு tool வரையறை:

tools
[
  {
    "name": "get_weather",
    "description": "Current weather for a city.",
    "input_schema": {
      "type": "object",
      "properties": {
        "city": {
          "type": "string"
        }
      },
      "required": [
        "city"
      ]
    }
  }
]

அதை அழைக்கும் பதிலின் content:

200 content
[
  {
    "type": "text",
    "text": ""
  },
  {
    "type": "tool_use",
    "id": "toolu_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
    "name": "get_weather",
    "input": {
      "city": "Paris"
    }
  }
]

tool-ஐ இயக்கி, பிறகு அழைப்பையும் tool_result block-ஐயும் messages-ல் சேர்த்து கோரிக்கையை மீண்டும் அனுப்புங்கள்:

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"} tool-ஐ அழைப்பதா என்பதை மாடல் முடிவு செய்யும். இதுவே இயல்புநிலை. அனைத்து மாடல்கள்
{"type": "any"} மாடல் tools-ல் ஒன்றை அழைத்தே ஆக வேண்டும். ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்கள்
{"type": "tool", "name": "…"} மாடல் பெயரிடப்பட்ட tool-ஐ அழைத்தே ஆக வேண்டும். ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்கள்

input_schema உள்ள tools மட்டுமே படிக்கப்படும். இந்த endpoint-ல் இணையத் தேடல் ஒரு tool அல்ல: web_search புலத்தை அமையுங்கள்.

tool loop தனிப் பக்கத்தில் முழுமையாக விளக்கப்பட்டுள்ளது. செயல்பாடு அழைப்பு

பதில்

புலம் வகை விளக்கம் அனுப்புவது
id string msg_ அதன் பின் 32 ஹெக்சாடெசிமல் எழுத்துகள். அனைத்து மாடல்கள்
type string எப்போதும் message. அனைத்து மாடல்கள்
role string எப்போதும் assistant. அனைத்து மாடல்கள்
model string பதிலளித்த மாடலின் நியமன id. அனைத்து மாடல்கள்
content array பதிலின் blocks, இந்த வரிசையில்: மாடல் reasoning செய்திருந்தால் thinking, text, பின்னர் ஒவ்வொரு tool அழைப்புக்கும் ஒரு tool_use. அனைத்து மாடல்கள்
stop_reason string பதில் ஏன் முடிந்தது. கீழே உள்ள மதிப்புகளைப் பாருங்கள். அனைத்து மாடல்கள்
usage object input_tokens மற்றும் output_tokens. அனைத்து மாடல்கள்
sources array தேடல் ஏதேனும் கண்டுபிடித்த web_search: true கோரிக்கையில் மட்டும்: மாடலுக்குத் தரப்பட்ட முடிவுகள், ஒவ்வொன்றும் index, title மற்றும் url உடன். பதிலில் உள்ள [1] என்பது index 1 கொண்ட உள்ளீடு. stream-ல் இது message_delta நிகழ்வுடன் வரும். shannon-1.6-*, shannon-2-*, Shannon 3 குடும்பம்
usage.cache_read_input_tokens integer cache_read_input_tokens என்பது cache-லிருந்து படிக்கப்பட்ட prompt பகுதி; input_tokens மீதமுள்ளது. cache_creation_input_tokens எப்போதும் 0. ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்கள்

பதில் blocks

Block விளக்கம்
{"type": "thinking", "thinking": "…"} மாடலின் reasoning. signature உறுப்பு இல்லை.
{"type": "text", "text": "…"} பதில் உரை. பதில் ஒரு tool அழைப்பாக இருந்தால் இது காலியாக இருக்கலாம்.
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} ஒரு tool அழைப்பு. input ஒரு JSON object. முடிவை அதே id உடன் திருப்பி அனுப்புங்கள்.

stop_reason

stop_reason விளக்கம் அனுப்புவது
end_turn மாடல் தன் பதிலை முடித்தது, அல்லது உங்கள் stop_sequences-ல் ஒன்று தோன்றியது. அனைத்து மாடல்கள்
tool_use பதிலில் ஒன்று அல்லது அதற்கு மேற்பட்ட tool அழைப்புகள் உள்ளன. அனைத்து மாடல்கள்
max_tokens பதில் வெளியீட்டு வரம்பில் துண்டிக்கப்பட்டது. Shannon 3 குடும்பம், shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1, streams-ல்

Streaming

server-sent events வேண்டுமென்றால் stream-ஐ true ஆக அமையுங்கள். ஒவ்வொரு frame-லும் நிகழ்வின் பெயருடன் ஒரு event: வரியும், அந்தப் பெயரை type-ல் மீண்டும் தரும் JSON object கொண்ட data: வரியும் இருக்கும். Anthropic SDK-யின் stream helpers இந்த நிகழ்வுகளை உங்களுக்காகப் படிக்கும்:

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)

நிகழ்வுகள், அவை வந்து சேரும் வரிசையில்:

நிகழ்வு தரவு எப்போது
message_start message எப்போதும் முதலில். message-ல் id, role, மாடல், காலி content மற்றும் பூஜ்யத்தில் தொடங்கும் usage இருக்கும்.
content_block_start index, content_block ஒரு block திறக்கிறது. content_block என்பது காலி text அல்லது thinking block, அல்லது அதன் id மற்றும் name உடன் ஒரு tool_use block.
content_block_delta index, delta {"type": "thinking_delta", "thinking"} thinking block-க்கான reasoning-ன் ஒரு துண்டு.
content_block_delta index, delta {"type": "text_delta", "text"} text block-க்கான பதிலின் ஒரு துண்டு.
content_block_delta index, delta {"type": "input_json_delta", "partial_json"} tool_use block-க்கான tool அழைப்பின் arguments, ஒரே delta-வில் முழுமையாக.
content_block_stop index இந்த index கொண்ட block முழுமையடைந்தது.
message_delta delta {stop_reason, stop_sequence}, usage பதிலின் முடிவு: delta.stop_reason, மற்றும் கோரிக்கையின் usage.
message_stop எப்போதும் கடைசியாக.

Blocks திறக்கும் வரிசையில் index மூலம் எண்ணிடப்படும்; அடுத்தது திறக்கும் முன் ஒரு block முழுமையடையும். ஒவ்வொரு block-ஐயும் அதன் எண்ணால் அல்ல, வகையால் படியுங்கள்: stream முதலில் ஒரு காலி text block-ஐத் திறந்து, பிறகு thinking block-ஐத் திறந்து, பதிலைப் பிந்தைய text block-ல் தரலாம்.

200 text/event-stream
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 வினாடிக்கும்.
ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்கள் : keepalive என்ற கருத்து வரி, மாடல் வேலை செய்யும்போது ஒவ்வொரு 15 வினாடிக்கும்.

தோல்வியடையும் stream

stream தொடங்கிய பிறகு ஏற்படும் தோல்வி, பிழைப் பதிலின் அதே body கொண்ட error நிகழ்வாக வரும்: {"type": "error", "error": {"type", "message"}}. முடிவு நிகழ்வுகளான message_delta மற்றும் message_stop அதன் பின்னும் வரும். பதிலைத் தோல்வியாகக் கருதி, கோரிக்கையை மீண்டும் அனுப்புங்கள்.

பிழைகள்

பிழைகள் Anthropic பிழை body-யைப் பயன்படுத்துகின்றன: type என்பது error, error object-ல் type மற்றும் message இருக்கும். இந்த endpoint அடிக்கடி தருவதை அட்டவணை பட்டியலிடுகிறது. எதை மீண்டும் முயற்சிப்பது என்பதுடன் முழுப் பட்டியல் தனிப் பக்கத்தில் உள்ளது. கையாளுவதில் பிழை

400 JSON
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "unknown model: no-such-model"
  }
}
நிலை வகை செய்தி எப்போது
401 authentication_error Missing authentication
Invalid API key
API key அனுப்பப்படவில்லை, அல்லது key தெரியாதது அல்லது ரத்து செய்யப்பட்டது.
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 பட உள்ளீடு இல்லாத ஹோஸ்ட் செய்யப்பட்ட open-weight மாடலுக்குப் படம் அனுப்பப்பட்டது.
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 ஒரு செய்திக் கோரிக்கையின் அதே body-யை (model, system, messages, tools) ஏற்று {"input_tokens": n} என்பதைத் தரும்: கோரிக்கைக்குக் கட்டணம் விதிக்கப்படும் உள்ளீட்டு டோக்கன்களின் எண்ணிக்கை. இது ஹோஸ்ட் செய்யப்பட்ட open-weight மாடல்களுக்குக் கணக்கிடுகிறது, இலவசம், மேலும் ஃப்ளட் பாதுகாப்பில் கணக்கில் சேராது.

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)

டோக்கன் எண்ணிக்கைக்குத் தனிப் பக்கம் உண்டு, plain-text endpoint மற்றும் வரம்புகளுடன். Token எண்ணிக்கை