Use web search when your agent needs fresh information from the internet, such as news, product launches, docs updates, or recent events. You can give your agent web search capabilities with a couple of changes on the backend.Documentation Index
Fetch the complete documentation index at: https://docs.openchatwidget.com/llms.txt
Use this file to discover all available pages before exploring further.
Build an AI SDK agent with web search
Add web search directly in your/api/chat streaming handler:
tools.web_search registration. Once this is present, the model can call web search during generation.
How web search works
At runtime, the model decides when to callweb_search based on your prompt and the user question.
Typical flow:
- User asks a question that likely needs current information.
- Model triggers
web_search. - Tool returns web context to the model.
- Model uses that context to generate a final answer.
- The full response is streamed back to Open Chat Widget.
Pricing for web search
Web search usually adds cost in two ways:- Model token usage: The request still consumes input/output tokens.
- Tool usage: Provider-specific web search calls may have additional per-call or usage-based charges.
What this looks like in Open Chat Widget
Open Chat Widget renders tool activity and reasoning as streamed message parts:- When the model is thinking, users see a collapsible reasoning panel.
- When a tool runs, users see a tool card (for example
Web Search), with status like running, complete, denied, or failed. - If a tool requires approval, the widget shows Approve/Reject controls and resumes automatically after the response.
Example
