Simira kuzvirimo
Anthropic

Anthropic

POST /v1/messages inotora request ye-Anthropic Messages format ndokupindura nge-format imwechete, ine streaming kana pasina. Shandisa ne-Anthropic SDK ne-tools dzakavakirwa pairi, sa-Claude Code: isa base URL, shandisa Shannon API key yako uye utaure Shannon model id.

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

Taridzira Anthropic SDK pa-Shannon base URL. SDK inowedzera /v1/messages uye inotumira key yako mu-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)

Mhinduro i-message ine content iri list ye-blocks. Tsvaga ma-block nemhando yawo mu-type: kana model yakafunga, block yekutanga i-thinking uye text inouya mushure mayo.

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
  }
}

Ma-header

Musoro Kukosha Tsananguro
x-api-key YOUR_API_KEY API key yako. Authorization: Bearer YOUR_API_KEY inogamuchirwa panzvimbo payo.
content-type application/json Inodiwa.
anthropic-version 2023-06-01 Inogamuchirwa, haidiwi. Anthropic SDK inotumira 2023-06-01; mhinduro ine format imwechete chero value ipi.
anthropic-beta Inogamuchirwa, haidiwi.
x-request-id Haidiwi. Id yako pachako ye-request. Inodzoka isina kuchinjwa mumhinduro; pasina iyo mhinduro ine id ye-hexadecimal characters 12.

Minda yechikumbiro

messages chete ndiyo inodiwa. Column inonzi Inoshandiswa ne inotaura ma-model apo field inochinja mhinduro. Hosted open-weight models ndiwo ma-id makumi matatu nematatu e-model list; mhuri ye-Shannon 3 ndi-shannon-3, shannon-3-pro, shannon-3.1 ne-shannon-3.1-pro. Ma-model nemitengo

Munda Mhando Zvakasarudzwa Tsananguro Inoshandiswa ne
model string shannon-1.6-lite Shannon model id kubva mu-model list. Itumire ne-request imwe neimwe. Kuenzanisa hakuteereri mavara makuru nemadiki. Zita ripi neripi rimwe rinodzosa 400 unknown model, saka tool inotumira mazita ayo e-model inofanira kuiswa pa-Shannon id. Ma-model ese
messages array Inodiwa. Hurukuro, message yekare iri pamberi, ine roles user ne-assistant. Tarisa Messages ne-content blocks pazasi. Ma-model ese
system string | array Mirayiro ye-model: string, kana array ye-text blocks. Tarisa System prompt pazasi. Ma-model open-weight anobatwa nesu, shannon-1.6-*, shannon-2-*, shannon-coder-1
max_tokens integer 4096 Muganho wepamusoro wemhinduro, mu-tokens. Hauna kudiwa pa-endpoint iyi; Anthropic SDK inogara ichiutumira. Value iri kunze kwe-1 kusvika 65,536 inoendeswa mu-range iyoyo. Ndiyo zvakare huwandu hunochengetwa mu-balance yako request ichiri kushanda. Ma-model open-weight anobatwa nesu, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1
stream boolean false true inotumira mhinduro se-server-sent events. Tarisa Streaming pazasi. Ma-model ese
temperature number Sampling temperature. Pa-hosted open-weight models values dzinochengetwa pakati pe-0 ne-2. Ma-model open-weight anobatwa nesu, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1
top_p number Nucleus sampling. Ma-model open-weight anobatwa nesu
stop_sequences array Kusvika ku-strings 4. Mhinduro inopera pamberi peyekutanga inoonekwa. stop_reason inoramba iri end_turn. Ma-model open-weight anobatwa nesu
tools array Tools dzinogona kudanidzirwa ne-model, imwe neimwe se-{"name", "description", "input_schema"}. Tarisa Tools pazasi. Ma-model ese
tool_choice object {"type": "auto"} inosiya model ichisarudza, {"type": "any"} inoiita kuti idanidzire tool, {"type": "tool", "name": "…"} inoiita kuti idanidzire tool iyoyo. Ma-model open-weight anobatwa nesu
thinking object Kuti model inofunga zvakadii isati yapindura. Tarisa Thinking pazasi. Ma-model open-weight anobatwa nesu
web_search boolean false Chiwedzerwa che-Shannon ku-format: true inosiya model ichitsvaga pa-web isati yapindura. shannon-1.6-*, shannon-2-*, mhuri ye-Shannon 3

Pasina max_tokens value i4,096, uye 65,536 pa-shannon-coder-1.

metadata, top_k, service_tier ne-cache_control markers pa-blocks zvinogamuchirwa kuti client code iripo ishande isina kuchinjwa. Hazvichinji mhinduro; prompt caching pa-hosted open-weight models inoitika otomatiki.

Mhinduro ye-JSON inoenderana ne-schema inokumbirwa ne-response_format pa-Chat Completions uye ne-text.format pa-Responses. Zvinobuda zvakarongeka

Request ine system prompt ne-thinking

Request iyi inotumira system prompt, thinking budget, temperature ne-stop sequence. Inoshandisa hosted open-weight model, inoshandisa zvese izvi.

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-uncensored-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)

Pa-hosted open-weight models usage inoratidza tokens dzakaverengwa kubva ku-prompt cache zvakasiyana ne-input tokens dzimwe.

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

System prompt

system i-string, kana array ye-text blocks mu-form [{"type": "text", "text": "…"}]. Ma-text e-blocks anobatanidzwa nemutsara mutsva.

Inoshandiswa ne-hosted open-weight models, shannon-1.6-lite, shannon-1.6-pro, shannon-2-lite, shannon-2-pro ne-shannon-coder-1. Ne-id yemhuri ye-Shannon 3, isa mirayiro inofanira kuchengetwa mu-user message.

Messages ne-content blocks

Message ine role, user kana assistant, ne-content. content i-string, kana array ye-blocks.

Bhuroku Tsananguro Inowanikwa pa
{"type": "text", "text": "…"} Zvinyorwa. Ma-model ese
{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "…"}}
{"type": "image", "source": {"type": "url", "url": "…"}}
Mufananidzo mu-user message, se-base64 kana nge-URL. Mhuri ye-Shannon 3, shannon-1.6-lite, shannon-1.6-pro, ne-hosted open-weight models dzinoratidza image input
{"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "…"}} Document (PDF, Word, PowerPoint kana Excel) mu-user message, se-base64 kana nge-URL. Mhuri ye-Shannon 3, ne-hosted open-weight models (zvinotumirwa inline, kwete nge-URL)
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} Mu-assistant message: tool call yakaitwa ne-model mumhinduro yapfuura. Ma-model ese
{"type": "tool_result", "tool_use_id": "toolu_…", "content": "…"} Mu-user message: mhedzisiro ye-call iyoyo. content i-string, kana list ye-text blocks. Ma-model ese

Unogona kutumira content yemhinduro yapfuura sezvayakaita: text ne-tool_use blocks dzinoverengwa, thinking blocks dzinosiiwa.

Pa-Shannon tiers mifananidzo ne-documents zvinoverengwa kubva mu-user message yekupedzisira. Sizes ne-limits zvine peji razvo. Mifananidzo ne-files

Kufunga

Hosted open-weight models dzinoshandura thinking kuita reasoning effort. Pasina field effort iri high.

Chimiro budget_tokens Mhedzisiro
{"type": "disabled"} Hapana reasoning. Mhinduro haina thinking block.
{"type": "enabled", "budget_tokens": 2048} ≤ 2,048 Effort yakaderera.
{"type": "enabled", "budget_tokens": 8192} ≤ 8,192 Effort yepakati.
{"type": "enabled", "budget_tokens": 16000} > 8,192 Effort yepamusoro.

Model inofunga inodzosa reasoning yayo se-block {"type": "thinking", "thinking": "…"} pamberi pe-text. Shannon tiers dzinofunga dzinoitumirawo.

Ma-effort anotsanangurwa papeji rawo. Simba rekufunga

Zvishandiso

Tool i-function inomhanywa ne-code yako. Tsanangura imwe neimwe ne-name, description ne-input_schema. Kana model ichida tool, mhinduro ine tool_use block uye stop_reason i-tool_use.

Tool definition mu-tools:

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

content yemhinduro inoidanidzira:

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

Mhanyisa tool, wotumira request zvakare ine call ne-tool_result block yawedzerwa mu-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

Chimiro Mhedzisiro Inoshandiswa ne
{"type": "auto"} Model inosarudza kana ichidanidzira tool. Iyi ndiyo default. Ma-model ese
{"type": "any"} Model inofanira kudanidzira imwe ye-tools. Ma-model open-weight anobatwa nesu
{"type": "tool", "name": "…"} Model inofanira kudanidzira tool yakatumidzwa. Ma-model open-weight anobatwa nesu

Tools dzine input_schema chete ndidzo dzinoverengwa. Web search haisi tool pa-endpoint iyi: isa web_search field.

Tool loop yakatsanangurwa zvizere papeji rayo. Kudanwa kwemabasa

Mhinduro

Munda Mhando Tsananguro Inotumirwa ne
id string msg_ inoteverwa ne-hexadecimal characters 32. Ma-model ese
type string Inogara iri message. Ma-model ese
role string Inogara iri assistant. Ma-model ese
model string Canonical id ye-model yakapindura. Ma-model ese
content array Ma-blocks emhinduro, nenzira iyi: thinking kana model yakafunga, text, wozoita tool_use imwe pa-tool call imwe neimwe. Ma-model ese
stop_reason string Chikonzero chekuti mhinduro yapera. Tarisa values dziri pazasi. Ma-model ese
usage object input_tokens ne-output_tokens. Ma-model ese
sources array Chete pa-request ine web_search: true ine search yakawana chimwe chinhu: mhedzisiro yakapiwa model, imwe neimwe ine index, title ne-url. [1] mumhinduro ndiyo entry ine index 1. Mu-stream inouya ne-message_delta event. shannon-1.6-*, shannon-2-*, mhuri ye-Shannon 3
usage.cache_read_input_tokens integer cache_read_input_tokens ndicho chikamu che-prompt chakaverengwa kubva ku-cache; input_tokens ndizvo zvasara. cache_creation_input_tokens inogara iri 0. Ma-model open-weight anobatwa nesu

Mabhuroku emhinduro

Bhuroku Tsananguro
{"type": "thinking", "thinking": "…"} Reasoning ye-model. Hapana signature member.
{"type": "text", "text": "…"} Text yemhinduro. Inogona kuva isina chinhu kana mhinduro iri tool call.
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} Tool call. input i-JSON object. Dzorera mhedzisiro ne-id imwechete.

stop_reason

stop_reason Tsananguro Inotumirwa ne
end_turn Model yapedza mhinduro yayo, kana imwe ye-stop_sequences dzako yaonekwa. Ma-model ese
tool_use Mhinduro ine tool call imwe kana dzakawanda. Ma-model ese
max_tokens Mhinduro yadimburwa pa-output limit. Mhuri ye-Shannon 3, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1, mu-streams

Streaming

Isa stream ku-true kuti uwane server-sent events. Frame imwe neimwe ine mutsara we-event: une zita re-event nemutsara we-data: une JSON object inodzokorora zita mu-type. Stream helpers dze-Anthropic SDK dzinoverenga ma-event aya pachako:

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)

Ma-event, nenzira anouya nayo:

Chiitiko Data Rinhi
message_start message Inogara iri yekutanga. message ine id, role, model, content isina chinhu ne-usage inotanga pa-zero.
content_block_start index, content_block Block inovhurwa. content_block i-text kana thinking block isina chinhu, kana tool_use block ine id ne-name yayo.
content_block_delta index, delta {"type": "thinking_delta", "thinking"} Chimedu che-reasoning, che-thinking block.
content_block_delta index, delta {"type": "text_delta", "text"} Chimedu chemhinduro, che-text block.
content_block_delta index, delta {"type": "input_json_delta", "partial_json"} Arguments dze-tool call, dzakazara mu-delta imwe, ye-tool_use block.
content_block_stop index Block ine index iyi yapera.
message_delta delta {stop_reason, stop_sequence}, usage Kuguma kwemhinduro: delta.stop_reason, ne-usage ye-request.
message_stop Inogara iri yekupedzisira.

Ma-block anoverengwa ne-index nenzira yaanovhurwa, uye block imwe inopera isati yavhurwa inotevera. Verenga block imwe neimwe nemhando yayo, kwete nenhamba yayo: stream inogona kutanga yavhura text block isina chinhu, wozovhura thinking block, ndokuendesa mhinduro mu-text block inotevera.

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"}

Kuramba uchibatana

Inotumirwa ne Tsananguro
Mhuri ye-Shannon 3, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 ping event ine data {"type": "ping"}, masekonzi 15 ega ega.
Ma-model open-weight anobatwa nesu ping event ine data {"type": "ping"}, masekonzi 15 ega ega.

Stream inokundikana

Kundikana kunoitika stream yatotanga i-error event ine body imwechete ne-error reply: {"type": "error", "error": {"type", "message"}}. Ma-event ekupedzisa, message_delta ne-message_stop, achatevera zvakadaro. Tora mhinduro seyakundikana uye utumire request zvakare.

Zvikanganiso

Ma-error anoshandisa Anthropic error body: type i-error, uye error object ine type ne-message. Tafura inoratidza zvinodzoserwa nguva dzakawanda ne-endpoint iyi. Rondedzero yakazara, ine zvekuedza zvakare, ine peji rayo. Zvikanganiso

400 JSON
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "unknown model: no-such-model"
  }
}
Mamiriro Mhando Meseji Rinhi
401 authentication_error Missing authentication
Invalid API key
API key haina kutumirwa, kana key haizivikanwi kana kuti yabviswa.
400 invalid_request_error unknown model: <id> model haisi Shannon model id.
400 invalid_request_error No user message provided Shannon tiers: request haina user text uye haina tools.
400 invalid_request_error <id> does not accept image input Mufananidzo watumirwa kune hosted open-weight model isina image input.
422 invalid_request_error Failed to deserialize the JSON body into the target type: … messages haisipo, kana field ine JSON type isiriyo.
400 invalid_request_error Not enough API credit. Top up at shannon-ai.com/tokens or get a GPU plan at shannon-ai.com/docs/api/plans max_tokens yakakura kupfuura zvasara mu-balance yako.
429 rate_limit_error Too many requests. Retry in <n>s. Flood protection: ma-request anopfuura 120 paminiti imwe pa-account yako.
500 server_error The model backend failed to answer. Please retry. Model haina kugadzira mhinduro. Tumira request zvakare.
502 api_error The model backend failed to answer. Please retry. Model haina kugadzira mhinduro. Tumira request zvakare.

Kuverenga tokens

POST /v1/messages/count_tokens inotora body imwechete ne-message request (model, system, messages, tools) ndokudzosera {"input_tokens": n}: huwandu hwe-input tokens request ingabhadharirwa. Inoverenga pa-hosted open-weight models, haibhadharwi uye haiverengwi ne-flood protection.

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-uncensored-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)

Kuverenga kune peji rako, rine plain-text endpoint ne-limits. Kuverenga tokens

SHANNON Chiratidzo chechirongwa che NVIDIA Inception SHANNON LAB LLC inhengo yechirongwa che NVIDIA Inception.

Sarudza mutauro wako

Mitauro yese yakafanana. Sarudza yaunoda kushandisa.

Yuropu

Middle East neNorth Africa

Nezasi kweAsia

Nezasi-mabvazuva eAsia

Mabvazuva eAsia

Central Asia neCaucasus

Afrika

Oceania

Yakagadzirwa neYekare