Patlo ya webe
Beha web_search: true mme model e tšehetsa karabo ea eona ka liphetho tse phelang.
POST https://api.shannon-ai.com/v1/chat/completions
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.shannon-ai.com/v1")
response = client.chat.completions.create(
model="shannon-3",
messages=[{"role": "user", "content": "What is the weather forecast for Lisbon this weekend?"}],
extra_body={"web_search": True}, # a Shannon field, so it goes in extra_body
)
print(response.choices[0].message.content) import OpenAI from "openai";
const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://api.shannon-ai.com/v1" });
const response = await client.chat.completions.create({
model: "shannon-3",
messages: [{ role: "user", content: "What is the weather forecast for Lisbon this weekend?" }],
web_search: true,
});
console.log(response.choices[0].message.content); curl https://api.shannon-ai.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "shannon-3",
"messages": [
{"role": "user", "content": "What is the weather forecast for Lisbon this weekend?"}
],
"web_search": true
}' Karabo ke chat completion e tloaelehileng e nang le tse peli tse eketsehileng. Karabo e supa liphetho tsa patlo ka linomoro ka har'a masakana a mahlakore, sources e re nomoro e 'ngoe le e 'ngoe e emela eng, mme annotations e tšoaea moo e 'ngoe le e 'ngoe e boleloang teng:
{
"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"
}
]
} Ho bulela patlo
Patlo ke field ea kopo, e tima ka default. Ha ho letho le batloang ntle le haeba kopo e e romela.
| Field | Mofuta | Default | Tlhaloso | E sebelisoa ke |
|---|---|---|---|---|
web_search | boolean | false | true e etsa web search bakeng sa kopo ena mme e fa model liphetho pele e araba. | Model e 'ngoe le e 'ngoe ea Shannon ntle le shannon-coder-1 |
| Endpoint | Web search | Joang |
|---|---|---|
/v1/chat/completions | Ee | "web_search": true ho body ea kopo. |
/v1/messages | Ee | "web_search": true ho body ea kopo. |
/v1/responses | — | Endpoint ena e araba ho tsoa ho model feela. Sebelisa e 'ngoe ea tse peli tse ka holimo bakeng sa karabo e nang le patlo. |
Ho /v1/messages field e boemong bo holimo ba body, haufi le model le messages:
{
"model": "shannon-3",
"web_search": true,
"messages": [
{
"role": "user",
"content": "What is the weather forecast for Lisbon this weekend?"
}
]
} Seo kopo e nang le patlo e se etsang
- API e batla webeng molaetsa oa ho qetela oa user. Li-turn tse fetileng tsa moqoqo li fa patlo context ea eona.
- Patlo e etsoa ho kopo e 'ngoe le e 'ngoe e romelang
web_search: true. Model ha e khethe hore na e batle kapa che. - Liphetho li behoa ka pel'a model e le mehloli e nomoroang, mme model e ngola karabo ea eona ho tsoa ho tsona.
- Karabo e qala ha patlo e fela. Kopo ea streaming ha e romele letho, esita le li-header kapa li-event, ho fihlela ka nako eo, kahoo lokisetsa ho ema nako e telele pele ho chunk ea pele.
Seo karabo e se nkang
- Karabo e na le sebopeho se tloaelehileng sa endpoint ea eona. Karabo e ho
choices[0].message.content(block eatextho/v1/messages). - Mongolo o ka nka matšoao a kang
[1]le[2]ka mor'a lipolelo tseo a li tšehetsang. Nomoro e 'ngoe le e 'ngoe e emela e 'ngoe ea liphetho tseo model e li balileng. sourcese reha liphetho tseo: entry e le 'ngoe bakeng sa sephetho seseng le se seng seo model e se file, e nang leindex,titleleurl. Letšoao[1]ke entry e nang leindex1. Liphetho tseo karabo e sa li boleleng le tsona lia thathamisoa.- Ho
/v1/chat/completionsmolaetsa o boetse o na leannotations, ka sebopeho sa OpenAI:url_citatione le 'ngoe bakeng sa mohloli o mong le o mong oo letšoao le o rehang, e nang leurl,title, lestart_indexleend_index, e leng sebaka sa letšoao hocontentse balehiloeng ka litlhaku (qetello ha e kenyelletsoe). - Ho stream
sourcese tla le chunk ea ho qetela, mme ho/v1/messagese tla le event eamessage_delta. Annotations li tla ka chunk e le 'ngoe pele ho ea ho qetela, e ledelta.annotations. sourcese teng feela haeba patlo ea kopo ena e fumane eng kapa eng. Karabo e se nang eona e ngotsoe ntle le liphetho tsa patlo.
Hore na lipatlo li baloa joang
Plan e 'ngoe le e 'ngoe e kenyelletsa palo ea lipatlo ka letsatsi:
| Plan | Lipatlo ka letsatsi |
|---|---|
| Mahala | 3 |
| Hape | 30 |
| Standard | 50 |
| Setsebi | 60 |
- Kopo eo patlo ea eona e fumaneng ntho e sebelisa patlo e le 'ngoe ea allowance ea letsatsi. Patlo e sa fumaneng letho ha e sebelise letho.
- Chat le API li arolelana allowance ea akhaonte e nang le senotlolo.
- Palo e qala hape letsatsi le letsatsi ka 00:00 UTC.
- Liphetho tsa patlo ke input tokens tsa kopo mme li lefisoa hammoho le karolo e setseng ea prompt.
Ha lipatlo tsa letsatsi li felile
Kopo e romelang web_search: true ka mor'a patlo ea ho qetela ea letsatsi ha e hanoe. E arajoa ntle le patlo: boemo ke 200 mme karabo ha e na sources.
Patlo e le tool ea hau
web_search: true ke switch e le 'ngoe feela ea patlo e hlalositsoeng mona. Function eo u e hlalosang ho tools mme u e rehe web_search ke e 'ngoe ea lisebelisoa tsa hau: model e khutlisa kopo, mme code ea hau e etsa patlo mme e romela sephetho hape.
Mefuta ea lisebelisoa tsa patlo ea literale tse ling, tse kang web_search_20250305 ho /v1/messages kapa {"type": "web_search"} ho /v1/responses, ha e qale patlo mona.
Liphoso
Web search ha e kenye khoutu ea boemo kapa mofuta oa phoso. Patlo e sa fumaneng letho, kapa letsatsi le se nang lipatlo tse setseng, e fana ka karabo e tloaelehileng ntle le liphetho tsa patlo. Phoso e 'ngoe le e 'ngoe e tšoana le ea kopo e se nang patlo. Diphoso