Tlola ho ea ho litaba
Anthropic

Anthropic

POST /v1/messages e amohela kopo ka sebopeho sa Anthropic Messages mme e araba ka sebopeho se tšoanang, ka streaming kapa ntle le eona. E sebelise le Anthropic SDK le lisebelisoa tse hahiloeng ho eona, tse kang Claude Code: beha base URL, sebelisa senotlolo sa hau sa Shannon API mme u reye id ea model ea Shannon.

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

Supa Anthropic SDK ho base URL ea Shannon. SDK e eketsa /v1/messages mme e romela senotlolo sa hau ho header ea 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)

Karabo ke molaetsa oo content ea ona e leng lenane la li-block. Fumana li-block ka type ea tsona: ha model e nahanne, block ea pele ke thinking mme mongolo o e latela.

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

Li-header

Header Boleng Tlhaloso
x-api-key YOUR_API_KEY Senotlolo sa hau sa API. Authorization: Bearer YOUR_API_KEY e amohelwa sebakeng sa sona.
content-type application/json E hlokahala.
anthropic-version 2023-06-01 E amohelwa, ha e hlokahale. Anthropic SDK e romela 2023-06-01; karabo e na le sebopeho se tšoanang ho sa tsotellehe boleng.
anthropic-beta E amohelwa, ha e hlokahale.
x-request-id Ha e hlokahale. Id ea hau ea kopo. E khutla e sa fetohang karabong; ntle le eona karabo e na le id ea litlhaku tse 12 tsa hexadecimal.

Li-field tsa kopo

messages feela e hlokahala. Kholomo ea E sebelisoa ke e reha li-model tseo field e fetolang karabo ho tsona. Li-model tse hosted tsa open-weight ke li-id tse mashome a mararo a metso e meraro tsa lenane la li-model; lelapa la Shannon 3 ke shannon-3, shannon-3-pro, shannon-3.1 le shannon-3.1-pro. Li-model le litheko

Lebala Mofuta Tloaelo Tlhaloso E sebelisoa ke
model string shannon-1.6-lite Id ea model ea Shannon ho tsoa lenaneng la li-model. E romele ho kopo e 'ngoe le e 'ngoe. Ho lekanya ha ho tsotelle litlhaku tse kholo le tse nyane. Lebitso le leng lefe kapa lefe le khutlisa 400 unknown model, kahoo sesebelisoa se romelang mabitso a sona a model se tlameha ho behoa ho id ea Shannon. Li-model tsohle
messages array E hlokahala. Moqoqo, molaetsa o moholo ka ho fetisisa pele, o nang le li-role user le assistant. Bona Messages le content blocks ka tlase. Li-model tsohle
system string | array Litaelo tsa model: string, kapa array ea li-block tsa mongolo. Bona System prompt ka tlase. Li-model tse hosted tsa open-weight, shannon-1.6-*, shannon-2-*, shannon-coder-1
max_tokens integer 4096 Moeli o phahameng oa karabo, ka tokens. Ha o hlokahale ho endpoint ena; Anthropic SDK kamehla e o romela. Boleng bo kantle ho 1 ho isa ho 65,536 bo fetoleloa ka har'a moeli oo. Ke hape palo e behelloang thoko ho balance ea hau ha kopo e ntse e sebetsa. Li-model tse hosted tsa open-weight, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1
stream boolean false true e romela karabo e le server-sent events. Bona Streaming ka tlase. Li-model tsohle
temperature number Sampling temperature. Ho li-model tse hosted tsa open-weight litekanyo li bolokoa pakeng tsa 0 le 2. Li-model tse hosted tsa open-weight, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1
top_p number Nucleus sampling. Li-model tse hosted tsa open-weight
stop_sequences array Ho fihlela ho li-string tse 4. Karabo e fela pele ho ea pele e hlahang. stop_reason e lula e le end_turn. Li-model tse hosted tsa open-weight
tools array Lisebelisoa tseo model e ka li bitsang, e 'ngoe le e 'ngoe e le {"name", "description", "input_schema"}. Bona Tools ka tlase. Li-model tsohle
tool_choice object {"type": "auto"} e lumella model hore e iketsetse qeto, {"type": "any"} e e qobella ho bitsa tool, {"type": "tool", "name": "…"} e e qobella ho bitsa tool eo. Li-model tse hosted tsa open-weight
thinking object Hore na model e nahana hakae pele e araba. Bona Thinking ka tlase. Li-model tse hosted tsa open-weight
web_search boolean false Tlatsetso ea Shannon ho sebopeho: true e lumella model hore e batle webeng pele e araba. shannon-1.6-*, shannon-2-*, lelapa la Shannon 3

Ntle le max_tokens boleng ke 4,096, le 65,536 ho shannon-coder-1.

Li-marker tsa metadata, top_k, service_tier le cache_control ho li-block lia amohelwa e le hore code ea moreki e teng e sebetse ntle le phetoho. Ha li fetole karabo; prompt caching ho li-model tse hosted tsa open-weight ke automatic.

Karabo ea JSON e latelang schema e kopuoa ka response_format ho Chat Completions le ka text.format ho Responses. Diphumo tse hlophisitsoeng

Kopo e nang le system prompt le thinking

Kopo ena e romela system prompt, thinking budget, temperature le stop sequence. E sebelisa model e hosted ea open-weight, e sebelisang tsohle.

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)

Ho li-model tse hosted tsa open-weight usage e tlaleha tokens tse baloang ho prompt cache ka thoko ho input tokens tse ling.

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

System prompt

system ke string, kapa array ea li-block tsa mongolo ka sebopeho [{"type": "text", "text": "…"}]. Mengolo ea li-block e kopanngoa ka mohala o mocha.

E sebelisoa ke li-model tse hosted tsa open-weight, shannon-1.6-lite, shannon-1.6-pro, shannon-2-lite, shannon-2-pro le shannon-coder-1. Ka id ea lelapa la Shannon 3, kenya litaelo tse lokelang ho latelloa molaetsa oa user.

Melaetsa le content blocks

Molaetsa o na le role, user kapa assistant, le content. content ke string, kapa array ea li-block.

Block Tlhaloso E fumaneha ho
{"type": "text", "text": "…"} Mongolo. Li-model tsohle
{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "…"}}
{"type": "image", "source": {"type": "url", "url": "…"}}
Setšoantšo molaetsa oa user, e le base64 kapa ka URL. Lelapa la Shannon 3, shannon-1.6-lite, shannon-1.6-pro, le li-model tse hosted tsa open-weight tse ngotsoeng input ea setšoantšo
{"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "…"}} Tokomane (PDF, Word, PowerPoint kapa Excel) molaetsa oa user, e le base64 kapa ka URL. Lelapa la Shannon 3, le li-model tse hosted tsa open-weight (li rometsoe inline, eseng ka URL)
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} Molaetsa oa assistant: kopo ea tool eo model e e entseng karabong e fetileng. Li-model tsohle
{"type": "tool_result", "tool_use_id": "toolu_…", "content": "…"} Molaetsa oa user: sephetho sa kopo eo. content ke string, kapa lenane la li-block tsa mongolo. Li-model tsohle

U ka romela content ea karabo e fetileng hape joalo ka ha e le: li-block tsa text le tool_use lia baloa, li-block tsa thinking lia tlolloa.

Ho li-tier tsa Shannon litšoantšo le litokomane li baloa molaetsa oa ho qetela oa user. Boholo le meeli li na le leqephe la tsona. Litšoantšo le lifaele

Ho nahana

Li-model tse hosted tsa open-weight li fetolela thinking ho reasoning effort. Ntle le field effort ke high.

Sebopeho budget_tokens Phello
{"type": "disabled"} Ha ho reasoning. Karabo ha e na block ea thinking.
{"type": "enabled", "budget_tokens": 2048} ≤ 2,048 Effort e tlase.
{"type": "enabled", "budget_tokens": 8192} ≤ 8,192 Effort e bohareng.
{"type": "enabled", "budget_tokens": 16000} > 8,192 Effort e phahameng.

Model e nahanang e khutlisa reasoning ea eona e le block {"type": "thinking", "thinking": "…"} pele ho mongolo. Li-tier tsa Shannon tse nahanang li e romela hape.

Li-effort li hlalositsoe leqepheng la tsona. Effort ea reasoning

Lisebelisoa

Tool ke function eo code ea hau e e etsang. Hlalosa e 'ngoe le e 'ngoe ka name, description le input_schema. Ha model e batla tool, karabo e na le block ea tool_use mme stop_reason ke tool_use.

Tlhaloso ea tool ho tools:

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

content ea karabo e e bitsang:

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

Etsa tool, ebe u romela kopo hape le kopo ea tool le block ea tool_result e kentsoeng ho 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

Sebopeho Phello E sebelisoa ke
{"type": "auto"} Model e iketsetsa qeto ea hore na e bitse tool. Ena ke default. Li-model tsohle
{"type": "any"} Model e tlameha ho bitsa e 'ngoe ea lisebelisoa. Li-model tse hosted tsa open-weight
{"type": "tool", "name": "…"} Model e tlameha ho bitsa tool e rehiloeng. Li-model tse hosted tsa open-weight

Ke lisebelisoa feela tse nang le input_schema tse baloang. Web search hase tool endpoint-ng ena: beha field ea web_search.

Tool loop e hlalositsoe ka botlalo leqepheng la eona. Mekhosi ya mesebetsi

Karabo

Lebala Mofuta Tlhaloso E rometsoe ke
id string msg_ e latelwa ke litlhaku tse 32 tsa hexadecimal. Li-model tsohle
type string Kamehla ke message. Li-model tsohle
role string Kamehla ke assistant. Li-model tsohle
model string Id ea canonical ea model e arabileng. Li-model tsohle
content array Li-block tsa karabo, ka tatellano ena: thinking ha model e nahanne, text, ebe tool_use e le 'ngoe bakeng sa kopo e 'ngoe le e 'ngoe ea tool. Li-model tsohle
stop_reason string Hobaneng karabo e felile. Bona litekanyo tse ka tlase. Li-model tsohle
usage object input_tokens le output_tokens. Li-model tsohle
sources array Feela ho kopo e nang le web_search: true eo patlo ea eona e fumaneng eng kapa eng: liphetho tseo model e li file, e 'ngoe le e 'ngoe e na le index, title le url. [1] karabong ke entry e nang le index 1. Ho stream e tla le event ea message_delta. shannon-1.6-*, shannon-2-*, lelapa la Shannon 3
usage.cache_read_input_tokens integer cache_read_input_tokens ke karolo ea prompt e baloang ho cache; input_tokens ke karolo e setseng. cache_creation_input_tokens kamehla ke 0. Li-model tse hosted tsa open-weight

Li-block tsa karabo

Block Tlhaloso
{"type": "thinking", "thinking": "…"} Reasoning ea model. Ha ho setho sa signature.
{"type": "text", "text": "…"} Mongolo oa karabo. O ka ba o se na letho ha karabo e le kopo ea tool.
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} Kopo ea tool. input ke ntho ea JSON. Romela sephetho hape ka id e tšoanang.

stop_reason

stop_reason Tlhaloso E rometsoe ke
end_turn Model e qetile karabo ea eona, kapa e 'ngoe ea stop_sequences tsa hau e hlahile. Li-model tsohle
tool_use Karabo e na le kopo e le 'ngoe kapa tse ngata tsa tool. Li-model tsohle
max_tokens Karabo e khaoloe moeling oa output. Lelapa la Shannon 3, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1, ho li-stream

Streaming

Beha stream ho true bakeng sa server-sent events. Frame e 'ngoe le e 'ngoe e na le mohala oa event: o nang le lebitso la event le mohala oa data: o nang le ntho ea JSON e pheta lebitso ho type. Li-helper tsa stream tsa Anthropic SDK li bala li-event tsena bakeng sa hau:

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)

Li-event, ka tatellano eo li fihlang ka eona:

Ketsahalo Data Neng
message_start message Kamehla ke ea pele. message e na le id, role, model, content e se nang letho le usage e qalang ho zero.
content_block_start index, content_block Block e a buleha. content_block ke block e se nang letho ea text kapa thinking, kapa block ea tool_use e nang le id le name ea eona.
content_block_delta index, delta {"type": "thinking_delta", "thinking"} Karolo ea reasoning, bakeng sa block ea thinking.
content_block_delta index, delta {"type": "text_delta", "text"} Karolo ea karabo, bakeng sa block ea text.
content_block_delta index, delta {"type": "input_json_delta", "partial_json"} Li-argument tsa kopo ea tool, li felletse delta e le 'ngoe, bakeng sa block ea tool_use.
content_block_stop index Block e nang le index ena e phethahetse.
message_delta delta {stop_reason, stop_sequence}, usage Qetello ea karabo: delta.stop_reason, le usage ea kopo.
message_stop Kamehla ke ea ho qetela.

Li-block li bokelloa ka index ka tatellano eo li buloang ka eona, mme block e le 'ngoe e phethahala pele e latelang e buloa. Bala block e 'ngoe le e 'ngoe ka mofuta oa eona, eseng ka nomoro ea eona: stream e ka bula block e se nang letho ea text pele, ebe block ea thinking, mme ea fana ka karabo ho block e latelang ea text.

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

E rometsoe ke Tlhaloso
Lelapa la Shannon 3, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 Event ea ping e nang le data {"type": "ping"}, ka mor'a metsotsoana e 15 e 'ngoe le e 'ngoe.
Li-model tse hosted tsa open-weight Event ea ping e nang le data {"type": "ping"}, ka mor'a metsotsoana e 15 e 'ngoe le e 'ngoe.

Stream e hlolehang

Phoso ka mor'a hore stream e qale ke event ea error e nang le body e tšoanang le ea karabo ea phoso: {"type": "error", "error": {"type", "message"}}. Li-event tsa ho koala, message_delta le message_stop, li ntse li latela. Nka karabo e le e hlolehileng mme u romele kopo hape.

Liphoso

Liphoso li sebelisa body ea phoso ea Anthropic: type ke error, mme ntho ea error e na le type le message. Tafole e thathamisa seo endpoint ena e se khutlisang hangata. Lenane le felletseng, le se ka lekoang hape, le na le leqephe la lona. Diphoso

400 JSON
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "unknown model: no-such-model"
  }
}
Boemo Mofuta Molaetsa Neng
401 authentication_error Missing authentication
Invalid API key
Ha ho senotlolo sa API se rometsoeng, kapa senotlolo ha se tsejoe kapa se hlakotsoe.
400 invalid_request_error unknown model: <id> model hase id ea model ea Shannon.
400 invalid_request_error No user message provided Li-tier tsa Shannon: kopo ha e na mongolo oa user kapa tools.
400 invalid_request_error <id> does not accept image input Setšoantšo se rometsoe ho model e hosted ea open-weight e se nang input ea setšoantšo.
422 invalid_request_error Failed to deserialize the JSON body into the target type: … messages ha e eo, kapa field e na le mofuta o fosahetseng oa JSON.
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 e kholo ho feta se setseng ho balance ea hau.
429 rate_limit_error Too many requests. Retry in <n>s. Flood protection: likopo tse fetang 120 ka motsotso o le mong ho akhaonte ea hau.
500 server_error The model backend failed to answer. Please retry. Model ha ea ka ea hlahisa karabo. Romela kopo hape.
502 api_error The model backend failed to answer. Please retry. Model ha ea ka ea hlahisa karabo. Romela kopo hape.

Ho bala tokens

POST /v1/messages/count_tokens e amohela body e tšoanang le ea kopo ea molaetsa (model, system, messages, tools) mme e khutlisa {"input_tokens": n}: palo ea input tokens tseo kopo e ka lefisoang ka tsona. E bala bakeng sa li-model tse hosted tsa open-weight, ke mahala mme ha e baloe ke 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)

Ho bala ho na le leqephe la ho eona, le endpoint ea mongolo o hlakileng le meeli. Ho bala tokens

SHANNON Pontšo ea lenaneo la NVIDIA Inception SHANNON LAB LLC ke setho sa lenaneo la NVIDIA Inception.

Kgetha puo ya hao

Dipuo tsohle di lekana. Kgetha eo o batlang ho e sebedisa ha o bala.

Yuropa

Middle East le Afrika Leboea

Asia Boroa

Asia Boroa-Botjhabela

Asia Botjhabela

Asia e Bohareng le Caucasus

Afrika

Oceania

Lipuo tse Entsoeng le tsa Khale