Gafee gaa n'ọdịnaya
Chọọ weebụ

Chọọ weebụ

Tọọ web_search: true ma model na-eji results dị ndụ akwado azịza ya.

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

Azịza bụ chat completion nkịtị nwere ihe abụọ e tinyere. Azịza na-ezo aka na search results site na ọnụọgụ n'ime square brackets, sources na-agwa ihe ọnụọgụ ọ bụla na-anọchi, annotations na-egosikwa ebe e kwuru ọ bụla:

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

Ịmepe search

Search bụ field nke request, emechiri na default. Enweghị ihe a na-achọ belụsọ request zipụrụ ya.

Field Ụdị Default Nkọwa Ndị na-etinye ya
web_search boolean false true na-agba web search maka request a ma nye model results tupu ọ zaa. Shannon model ọ bụla ewezuga shannon-coder-1
Endpoint Web search Otu esi eme
/v1/chat/completions Ee "web_search": true n'ime request body.
/v1/messages Ee "web_search": true n'ime request body.
/v1/responses — Endpoint a na-aza site na model naanị. Jiri otu n'abụọ dị n'elu maka azịza nwere search.

Na /v1/messages field ahụ dị n'ọkwa elu nke body, n'akụkụ model na messages:

Request body
{
  "model": "shannon-3",
  "web_search": true,
  "messages": [
    {
      "role": "user",
      "content": "What is the weather forecast for Lisbon this weekend?"
    }
  ]
}

Ihe request nwere search na-eme

  • API na-achọ weebụ maka user message ikpeazụ. Turns gara aga nke mkparịta ụka na-enye search ọnọdụ ya.
  • Search na-agba na request ọ bụla na-ezipu web_search: true. Model anaghị ahọrọ ma ọ ga-achọ.
  • A na-etinye results n'ihu model dị ka isi mmalite nwere ọnụọgụ, model na-ede azịza ya site na ha.
  • Azịza na-amalite mgbe search gwụchara. Request stream anaghị ezipu ihe ọ bụla, ọ bụghị headers ma ọ bụghị events, ruo mgbe ahụ, ya mere kwadebe maka ichere ogologo tupu chunk mbụ.

Ihe azịza nwere

  • Azịza nwere ụdị nkịtị nke endpoint ya. Azịza dị na choices[0].message.content (text block na /v1/messages).
  • Text nwere ike ibu akara dị ka [1] na [2] mgbe okwu ha na-akwado. Ọnụọgụ ọ bụla na-anọchi otu n'results model gụrụ.
  • sources na-akpọ results ndị ahụ aha: otu entry maka result ọ bụla e nyere model, nwere index, title na url. Akara [1] bụ entry nwere index 1. A depụtakwara results azịza na-ekwughị.
  • Na /v1/chat/completions message ahụ nwekwara annotations, n'ụdị OpenAI: otu url_citation maka isi mmalite ọ bụla akara na-akpọ aha, nwere url, title, na start_index na end_index, ọnọdụ akara ahụ na content e gụrụ n'mkpụrụedemede (a gụnyeghị njedebe).
  • Na stream sources na-abịa na chunk ikpeazụ, na na /v1/messages ya na event message_delta. Annotations na-abịa n'otu chunk tupu nke ikpeazụ, dị ka delta.annotations.
  • sources dị naanị ma search nke request a chọtara ihe. Azịza na-enweghị ya, e dere ya na-enweghị search results.

Otu a na-agụ searches

Plan ọ bụla nwere ọnụọgụ searches kwa ụbọchị:

Plan Searches kwa ụbọchị
N'efu 3
Tụkwasị 30
Standard 50
Ọkachamara 60
  • Request nke search ya chọtara ihe na-eji otu search nke allowance ụbọchị. Search chọtaghị ihe anaghị eji ọ bụla.
  • Chat na API na-ekekọrịta allowance nke akaụntụ nwe key.
  • Ọnụọgụ na-amalite ọzọ kwa ụbọchị na 00:00 UTC.
  • Search results bụ input tokens nke request ma a na-akwụ ụgwọ ha ya na prompt ndị ọzọ.

Tụnyere plans

Mgbe searches nke ụbọchị gwụrụ

A naghị ajụ request na-ezipu web_search: true mgbe search ikpeazụ nke ụbọchị gasịrị. A na-aza ya na-enweghị search: status bụ 200 azịza enweghịkwa sources.

Search dị ka tool nke gị

web_search: true bụ naanị switch nke search akọwara ebe a. Function ị kọwara na tools ma kpọọ web_search bụ otu n'tools nke gị: model na-eweghachi call, koodu gị na-agba search ma zighachi result.

Search tool types nke platforms ndị ọzọ, dị ka web_search_20250305 na /v1/messages ma ọ bụ {"type": "web_search"} na /v1/responses, anaghị amalite search ebe a.

Njehie

Web search anaghị agbakwunye status code ma ọ bụ error type. Search chọtaghị ihe, ma ọ bụ ụbọchị na-enweghị searches fọdụrụ, na-enye azịza nkịtị na-enweghị search results. Njehie ọ bụla ọzọ bụ otu ihe ahụ dị ka maka request na-enweghị search. Njikwa njehie