Peke ki ngā ihirangi
Tirohanga whānui

Tirohanga whānui

Te mahere o te API: ia endpoint, te āhua o tētahi tono me tētahi hapa, te āhua o te utu mō ngā karanga, me ngā mea hei mōhio ina haere mai koe i tētahi SDK OpenAI, Anthropic rānei.

Ngā endpoint

Kei raro i te base URL kotahi ia endpoint, ā, ka ratoa mā te HTTPS.

Base URL
https://api.shannon-ai.com
Endpoint Hōputu Mō te aha
POST /v1/chat/completions OpenAI Chat Completions Tukuna he kōrero, tikina te whakautu e whai ake nei. Me te streaming, me te kore rānei.
POST /v1/messages Anthropic Messages Te mea ōrite, i ngā āhua tono me whakautu o ngā SDK Anthropic.
POST /v1/responses OpenAI Responses Te mea ōrite, i ngā āhua Responses. Kāore te endpoint e pupuri i te tūnga: tukuna te kōrero i ia tono.
GET /v1/models Rārangi model OpenAI Rārangi i ngā model me te matapihi horopaki, ngā utu me ngā āheinga. Kāore he key e hiahiatia.
POST /v1/tokenize API Shannon Tatauria ngā token o tētahi kuputuhi, o tētahi tono chat rānei mō tētahi model open-weight hosted. Kore utu.
POST /v1/messages/count_tokens Tatau token Anthropic Tatauria ngā token input o tētahi tono Messages mō tētahi model open-weight hosted. Kore utu.

Ka tae ngā endpoint e toru e whakaputa kuputuhi ana ki ngā model ōrite. Kōwhiria te mea ka whakamahi tō waehere i tōna hōputu kē.

Ngā kaupapa tuatahi o te tono

Header Whakaahuatanga
Authorization: Bearer <key> Tō API key. E hiahiatia ana i ia endpoint haunga te GET /v1/models, ki te kore koe e tuku i te x-api-key.
x-api-key: <key> Te key ōrite i te header ka tukuna e ngā SDK Anthropic. Ka pānuitia i ia endpoint.
Content-Type: application/json E hiahiatia ana i ia POST. Ki te kore, ko 415 te whakautu.
x-request-id: <your id> Kōwhiringa. Tō ake id mō te tono; ka hoki mai i te header whakautu x-request-id. Ki te kore, ka waihanga te API i tētahi o te 12 tohu hekihekimara.
  • Ko te tinana o ia POST he ahanoa JSON kotahi, tae atu ki te 32 MiB.
  • Kāore he hapa i tētahi āpure kāore e mōhiotia e te API, ā, kāore he pānga. Kāore e rahua tētahi tono i tuhia mō tētahi atu kaiwhakarato mō tētahi āpure tāpiri.
  • Ka whakautua tētahi āpure e mōhiotia ana me te momo JSON hē, tētahi āpure e hiahiatia ana kua ngaro rānei, ki te 422. Ka whakautua tētahi tinana ehara i te JSON tika ki te 400.
  • Ko te model tētahi o ngā id i Models & pricing. Kāore e pā te pū nui, pū iti rānei.

He JSON te whakautu, he stream rānei o ngā server-sent events ina tautuhi te tono i te stream ki te true. Ka whakautu ia endpoint i tōna ake hōputu. Kei ia whakautu te header x-request-id.

Ngā mea e whiti ai tētahi tono

Ka tirohia tētahi tono i tētahi raupapa pūmau i mua i te rere o tētahi model. Ko te tirohanga tuatahi ka rahua te whakautu, nō reira kāore tētahi 401 e kī i tētahi mea mō te tinana.

Te āhua o te hapa

He ahanoa JSON te hapa me tētahi error e kawe ana i te type me te message. Ka takai te /v1/messages i a ia pēnei i ta ngā SDK Anthropic e tūmanako ai; ka whakamahi ia ara kē atu i te āhua OpenAI.

{
  "error": {
    "type": "invalid_request_error",
    "message": "unknown model: gpt-4o"
  }
}
  • Pānuitia te type me te message. Kei ētahi hapa anake te code me te param: whakaarohia he kōwhiringa. Ko null tonu te param.
  • I muri i te tīmatanga o tētahi stream, ko 200 kē te tūnga. Ka tae mai tētahi rahua i reira hei frame hapa i roto i te stream.
  • Ka kawe ia whakautu hapa i te header x-request-id.
Tūnga Momo Āhea
400 invalid_request_error Ehara te tinana i te JSON tika, kāore e mōhiotia te id model, kāore rānei te model e whakaae ki tētahi momo input i tukuna e koe.
401 authentication_error Kei te ngaro te key, kāore rānei e tika.
404 not_found_error Kāore te ara e noho ana.
405 api_error Kei te noho te ara, he hē te tikanga.
413 invalid_request_error Nui ake te tinana i te 32 MiB.
415 invalid_request_error Ehara te Content-Type i te application/json.
422 invalid_request_error He hē te momo JSON o tētahi āpure, kei te ngaro rānei tētahi āpure e hiahiatia ana.
429 rate_limit_error Kāore te toenga e kapi i te tono, neke atu i te 120 tono i tae mai i roto i te meneti, kua pau ngā karanga Shannon Coder o te matapihi, he pukumahi rānei te model. Ka kī te karere ko tēhea.
5xx api_error Tūnga 500, 502, 503 504 rānei: i tika te tono, engari kāore i taea te whakautu. Tukuna anō. Ka taea e te 500 te kawe i te momo server_error.

Whakahaere hapa

Te utu me te toenga

  • Kotahi te toenga mō ia pūkete, ā, ka tiritiri te chat me te API: te whakaaetanga o te mahere mō tēnei rā i te tuatahi, kātahi ko te nama kua hokona. Kāore he quota ake tā te API.
  • Ka pupuri tētahi tono i tana tahua output (max_tokens, taunoa 4,096), ā, ka utua ia mō ngā token i whakamahia tūturutia e ia, ki te utu a te model.
  • Ka pūrongo ia whakautu i ōna tatau token i te usage. Ka whakaatu te whārangi Keys & usage i te toenga me te utu o ia tono.
  • Ka ratoa ia tono i te ōrite. Ko te tepe anake mō te tere tono ko te flood protection: 120 tono ia meneti mō ia pūkete. Ka tatari ngā tono e tukuna whakarara ana i te rārangi.

Ngā tepe me te toenga Ngā model me ngā utu Keys & usage

Ngā āpure e whakawhirinaki ana ki te model

Ka whakaae ia model ki te tono ōrite. Ka whai pānga ētahi āpure ki ētahi model anake; ka whakaingoa te ripanga i te wāhi. Ka rārangi ngā whārangi endpoint i ia āpure.

Āpure Whakaahuatanga Whakamahia e
system Ngā tohutohu mā te model: he karere system i Chat Completions, system i Messages, instructions i Responses. Ngā model open-weight hosted, shannon-1.6-*, shannon-2-*, shannon-coder-1
temperature Te temperature sampling. Ngā model open-weight hosted, shannon-1.6-*, shannon-coder-1
top_p Nucleus sampling. Ngā model open-weight hosted
seed He seed pūmau mō te sampling. Ngā model open-weight hosted
stop Tae atu ki te 4 raupapa mutu. Ngā model open-weight hosted
reasoning_effort Te nui o te whakaaro a te model i mua i tana whakautu. reasoning.effort i Responses, thinking i Messages. Ngā model open-weight hosted
web_search Ka tuku te true i te model ki te rapu i te tukutuku mō tēnei tono. He āpure o tēnei API, i runga i Chat Completions me Messages. Ngā model Shannon haunga te shannon-coder-1
max_tokens Te tahua output. I ia model ka tautuhi i te nui e pupuritia ana i tō toenga. Hei tepe mō te roa o te whakautu: ngā model open-weight hosted, shannon-1.6-*, shannon-coder-1

Chat Completions

Ina haere mai koe i tētahi SDK OpenAI

  • Tautuhia te base URL ki te https://api.shannon-ai.com/v1 me te key ki tō key Shannon. Kātahi ka mahi ngā karanga Chat Completions me Responses ki te SDK pēnei i a ia.
  • Me id Shannon te model. Ka whakautua te ingoa model o tētahi atu kaiwhakarato, pēnei i te gpt-4o, ki te 400 me te unknown model.
  • Ka tae mai te reasoning i tētahi āpure motuhake: reasoning_content i te taha o te content, i te karere me ngā delta stream.
  • Ka kawe tētahi stream i te usage i tōna chunk whakamutunga i ngā wā katoa, i te taha o te finish_reason.
  • Ka tae mai tētahi karanga tool i roto i tētahi stream hei chunk kotahi me te aho arguments katoa.
  • Kotahi te kōwhiringa o tētahi whakautu.
  • Ka whakautua ngā ara o te API OpenAI kāore i te ripanga i runga ake nei, pēnei i te /v1/embeddings, ki te 404.

Ina haere mai koe i tētahi SDK Anthropic

  • Tautuhia te base URL ki te https://api.shannon-ai.com, kāore he /v1, me te key ki tō key Shannon. Ka tukuna e te SDK hei x-api-key.
  • Me id Shannon te model.
  • He kōwhiringa te max_tokens i tēnei API. Ko tōna taunoa 4,096.
  • Kei tētahi whakautu ngā poraka content o te momo thinking, text me tool_use. Ehara i te kuputuhi i ngā wā katoa te poraka tuatahi: kōwhiria ngā poraka mā te type.
  • Ko te stop_reason ko end_turn ko tool_use rānei. Ka taea hoki te mutu o tētahi stream o tētahi model Shannon me te max_tokens.
  • E whakaaetia ana te anthropic-version me te anthropic-beta, nō reira ka mahi te SDK kāore i huri. Kāore e hiahiatia e tētahi tono.
  • Ko ngā hapa i runga i te /v1/messages he āhua Anthropic: {"type": "error", "error": {…}}.

Ka whakaritea ngā taputapu whakawaehere e kōrero ana i ēnei hōputu i te ara ōrite: base URL, key, me tētahi id Shannon hei model. Ngā taputapu CLI mō te tuhi code