Fò lọ sí àkóónú
Iwadi Wẹẹbu ti a ṣe sinu

Iwadi Wẹẹbu ti a ṣe sinu

Ṣètò web_search: true, model yóò sì fi àwọn abajade lọ́wọ́lọ́wọ́ gbé ìdáhùn rẹ̀ ró.

POST https://api.shannon-ai.com/v1/chat/completions

Èsì jẹ́ chat completion lásán pẹ̀lú àfikún méjì. Ìdáhùn náà tọ́ka sí àwọn abajade ìwádìí pẹ̀lú àwọn nọ́mbà nínú àwọn àkámọ́ onígun, sources sọ ohun tí nọ́mbà kọ̀ọ̀kan dúró fún, annotations sì ṣàmì ibi tí a ti tọ́ka sí kọ̀ọ̀kan:

200 JSON
{
  "id": "chatcmpl-3e5a7c9b1d2f4a6c8e0b2d4f6a8c1e3b",
  "object": "chat.completion",
  "created": 1791590400,
  "model": "shannon-3",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Saturday in Lisbon is forecast to be sunny with a high near 24 °C [1]. Sunday turns cloudy, with a chance of light rain in the afternoon [2].",
        "reasoning_content": null,
        "annotations": [
          {
            "type": "url_citation",
            "url_citation": {
              "start_index": 66,
              "end_index": 69,
              "url": "https://weather.example/lisbon/weekend",
              "title": "Lisbon weather: weekend outlook"
            }
          },
          {
            "type": "url_citation",
            "url_citation": {
              "start_index": 137,
              "end_index": 140,
              "url": "https://forecast.example/pt/lisbon/sunday",
              "title": "Sunday forecast for Lisbon"
            }
          }
        ]
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 2874,
    "completion_tokens": 41,
    "total_tokens": 2915
  },
  "sources": [
    {
      "index": 1,
      "title": "Lisbon weather: weekend outlook",
      "url": "https://weather.example/lisbon/weekend"
    },
    {
      "index": 2,
      "title": "Sunday forecast for Lisbon",
      "url": "https://forecast.example/pt/lisbon/sunday"
    },
    {
      "index": 3,
      "title": "Portugal: the week ahead",
      "url": "https://news.example/portugal/weather-week"
    }
  ]
}

Títan ìwádìí

Ìwádìí jẹ́ field ti ìbéèrè, tí a pa ní àfikún. A kì í wádìí nǹkan àyàfi tí ìbéèrè bá fi ránṣẹ́.

Field Irú Default Àpèjúwe Ó ń ṣiṣẹ́ lórí
web_search boolean false true ń ṣe ìwádìí wẹ́ẹ̀bù fún ìbéèrè yìí, ó sì ń fún model ní àwọn abajade kí ó tó dáhùn. Gbogbo model Shannon àyàfi shannon-coder-1
Endpoint Ìwádìí wẹ́ẹ̀bù Bí a ṣe ń ṣe é
/v1/chat/completions Bẹ́ẹ̀ni "web_search": true nínú body ìbéèrè.
/v1/messages Bẹ́ẹ̀ni "web_search": true nínú body ìbéèrè.
/v1/responses — Endpoint yìí ń dáhùn láti ọ̀dọ̀ model nìkan. Lo ọ̀kan nínú méjèèjì tó wà lókè fún ìdáhùn tí a wádìí.

Lórí /v1/messages, field náà wà ní ipele òkè ti body, lẹ́gbẹ̀ẹ́ model àti messages:

Body ìbéèrè
{
  "model": "shannon-3",
  "web_search": true,
  "messages": [
    {
      "role": "user",
      "content": "What is the weather forecast for Lisbon this weekend?"
    }
  ]
}

Ohun tí ìbéèrè tí a wádìí ń ṣe

  • API ń wá wẹ́ẹ̀bù fún ìfiránṣẹ́ user tó gbẹ̀yìn. Àwọn turn ìjíròrò tó ṣáájú ń fún ìwádìí ní àyíká rẹ̀.
  • Ìwádìí ń ṣiṣẹ́ lórí gbogbo ìbéèrè tó bá fi web_search: true ránṣẹ́. Model kì í yan bóyá kí ó wádìí.
  • A gbé àwọn abajade síwájú model gẹ́gẹ́ bí àwọn orísun tí a ṣe nọ́mbà, model sì kọ ìdáhùn rẹ̀ láti inú wọn.
  • Èsì ń bẹ̀rẹ̀ nígbà tí ìwádìí bá parí. Ìbéèrè tí a ṣe stream kì í fi nǹkan kan ránṣẹ́, kì í ṣe header tàbí event, títí di ìgbà náà, nítorí náà retí dídúró gígùn ṣáájú chunk àkọ́kọ́.

Ohun tí èsì ní

  • Èsì ní àwòrán àtọ̀runwá ti endpoint rẹ̀. Ìdáhùn wà nínú choices[0].message.content (block text lórí /v1/messages).
  • Ọ̀rọ̀ náà lè ní àwọn àmì bíi [1] àti [2] lẹ́yìn àwọn gbólóhùn tí wọ́n ń tì lẹ́yìn. Nọ́mbà kọ̀ọ̀kan dúró fún ọ̀kan nínú àwọn abajade tí model kà.
  • sources dárúkọ àwọn abajade wọ̀nyẹn: ẹnu-ọ̀nà kan fún abajade kọ̀ọ̀kan tí a fún model, pẹ̀lú index, title àti url. Àmì [1] ni ẹnu-ọ̀nà tí index rẹ̀ jẹ́ 1. Àwọn abajade tí ìdáhùn kò tọ́ka sí wà nínú àtòjọ náà pẹ̀lú.
  • Lórí /v1/chat/completions, message náà tún ní annotations, ní àwòrán OpenAI: url_citation kan fún orísun kọ̀ọ̀kan tí àmì kan dárúkọ, pẹ̀lú url, title, àti start_index àti end_index, ipò àmì náà nínú content tí a kà ní àwọn character (a kò ka òpin).
  • Nínú stream, sources wá pẹ̀lú chunk ìkẹyìn, àti lórí /v1/messages ó wá pẹ̀lú event message_delta. Àwọn annotation wá nínú chunk kan ṣáájú ìkẹyìn, gẹ́gẹ́ bí delta.annotations.
  • sources wà níbẹ̀ nìkan bí ìwádìí ìbéèrè yìí bá rí nǹkan. Èsì tí kò ní in ni a kọ láìsí abajade ìwádìí.

Bí a ṣe ń ka àwọn ìwádìí

Gbogbo plan ní iye ìwádìí kan lójoojúmọ́:

Plan Àwọn ìwádìí lójoojúmọ́
Ọfẹ 3
Ni afikun 30
Standard 50
Pro 60
  • Ìbéèrè tí ìwádìí rẹ̀ rí nǹkan ń lo ìwádìí kan nínú allowance ọjọ́ náà. Ìwádìí tí kò rí nǹkan kò lo kankan.
  • Chat àti API jọ ń lo allowance ti account tó ni key náà.
  • Ìkà náà ń bẹ̀rẹ̀ padà lójoojúmọ́ ní 00:00 UTC.
  • Àwọn abajade ìwádìí jẹ́ token input ti ìbéèrè náà, a sì ń gba owó wọn pẹ̀lú apá yòókù ti prompt.

Fi àwọn plan wé ara wọn

Nígbà tí ìwádìí ọjọ́ náà bá tán

A kì í kọ ìbéèrè tó fi web_search: true ránṣẹ́ lẹ́yìn ìwádìí ìkẹyìn ti ọjọ́ náà. A ń dáhùn rẹ̀ láìsí ìwádìí: status jẹ́ 200, èsì náà kò sì ní sources.

Ìwádìí gẹ́gẹ́ bí tool tìrẹ

web_search: true nìkan ni switch ti ìwádìí tí a ṣàlàyé níbí. Function tí o ṣàlàyé nínú tools tí o sì pè ní web_search jẹ́ ọ̀kan nínú tools tìrẹ: model ń dá ìpè padà, code rẹ sì ń ṣe ìwádìí náà, ó sì ń fi abajade padà ránṣẹ́.

Àwọn irú tool ìwádìí ti àwọn platform mìíràn, bíi web_search_20250305 lórí /v1/messages tàbí {"type": "web_search"} lórí /v1/responses, kì í bẹ̀rẹ̀ ìwádìí níbí.

Àwọn àṣìṣe

Ìwádìí wẹ́ẹ̀bù kì í fi status code tàbí irú àṣìṣe kún. Ìwádìí tí kò rí nǹkan, tàbí ọjọ́ tí kò ní ìwádìí kankan tó kù, ń fún ni ní ìdáhùn deede láìsí abajade ìwádìí. Gbogbo àṣìṣe mìíràn jẹ́ bákan náà bí ti ìbéèrè láìsí ìwádìí. Mimu Aṣiṣe