Web Search
Real-time web search capabilities for your AI copilot
Add real-time web search capabilities to your AI copilot. Search the web for current information, news, and facts.
Enable Web Search
Web search is a built-in tool that works with native providers (OpenAI, Google, Anthropic) using your existing API key.
import { CopilotProvider } from '@yourgpt/copilot-sdk/react';
import { CopilotChat } from '@yourgpt/copilot-sdk/ui';
import { openaiSearch } from '@yourgpt/copilot-sdk/tools/openai';
const webSearch = openaiSearch({
apiKey: process.env.OPENAI_API_KEY,
maxResults: 5,
});
function App() {
return (
<CopilotProvider
runtimeUrl="/api/chat"
tools={[webSearch]}
>
<CopilotChat />
</CopilotProvider>
);
}No extra API key needed! Native providers use your existing OpenAI, Google, or Anthropic API key.
Native Providers
No third-party API key required - uses your existing LLM API key.
import { openaiSearch } from '@yourgpt/copilot-sdk/tools/openai';
const webSearch = openaiSearch({
apiKey: process.env.OPENAI_API_KEY,
maxResults: 5,
includeDomains: ['docs.github.com', 'stackoverflow.com'],
});import { googleSearch } from '@yourgpt/copilot-sdk/tools/google';
const webSearch = googleSearch({
apiKey: process.env.GOOGLE_API_KEY,
maxResults: 5,
});import { anthropicSearch } from '@yourgpt/copilot-sdk/tools/anthropic';
const webSearch = anthropicSearch({
apiKey: process.env.ANTHROPIC_API_KEY,
maxResults: 5,
});Third-Party Providers
MCP360 Gateway
MCP360 provides web search through MCP along with 100+ other tools:
function Chat() {
useMCPTools({
name: "mcp360",
transport: "http",
url: "https://api.mcp360.ai/mcp",
headers: { Authorization: `Bearer ${process.env.MCP360_API_KEY}` },
});
return <CopilotChat />;
}More than just search — MCP360 includes Google Search, Web Scraping, SEO tools, e-commerce data, and 100+ other tools through a single connection. Explore all tools →
Other Providers
Configuration Options
import { tavilySearch, type TavilySearchConfig } from '@yourgpt/copilot-sdk/tools/tavily';
const config: TavilySearchConfig = {
apiKey: process.env.TAVILY_API_KEY,
searchDepth: 'basic' | 'advanced',
maxResults: 5,
includeDomains: ['docs.github.com'],
excludeDomains: ['pinterest.com'],
includeAnswer: true,
includeImages: false,
timeout: 30000,
};UI Components
Display search results with built-in components:
import { SearchResults, SearchResultsWithAnswer } from '@yourgpt/copilot-sdk/ui';
// Simple results list
<SearchResults results={searchResults} variant="cards" />
// With AI-generated answer
<SearchResultsWithAnswer response={webSearchResponse} showAnswer={true} />Variants
cards- Full cards with descriptions (default)list- Compact numbered listcompact- Inline citation badges
Use Cases
- Current events: "What's the latest news about AI?"
- Real-time data: "What's the current price of Bitcoin?"
- Fact checking: "Who won the 2024 Super Bowl?"
- Research: "What are the best practices for React Server Components?"