# IWebSearchService

## Overview

The [IWebSearchService](/ai/components/api/services/iwebsearchservice.md) offers web search capabilities. Currently, the only implemented consumer of this service is the [`WebSearchTools`](/ai/components/api/tools/wisej.ai.tools.websearchtools.md). However, you can also incorporate this service into your own tools as needed.

Implementing this service is straightforward, as it requires only a single property and one method. The property, `MaxSites`, is used to limit the number of search results returned. The [SearchAsync(query)](/ai/components/api/services/iwebsearchservice.md#searchasync-query) method is responsible for returning the search results.

The result is a single string that is included in the RAG (Retrieve-and-Generate) context. You can format this string as you wish, but it's essential that the AI can discern both the URL and a snippet or abstract text from it. The built-in services typically format the result as follows:

```
URL: url
Abstract: text
===
```

## Default Implementation

The IWebSearchService interface offers several built-in implementations: [BingWebSearchService](/ai/components/api/services/iwebsearchservice/wisej.ai.services.bingwebsearchservice.md), [BraveWebSearchService](/ai/components/api/services/iwebsearchservice/wisej.ai.services.bravewebsearchservice.md), and [GoogleWebSearchService](/ai/components/api/services/iwebsearchservice/wisej.ai.services.googlewebsearchservice.md).

You can download the [`BingWebSearchService` ](/ai/components/api/services/iwebsearchservice/wisej.ai.services.bingwebsearchservice.md)implementation below, which serves as a basic guideline for setting up your own web search service.

{% file src="/files/rAc7PaYl2sFjb7cm2OkR" %}

{% file src="/files/ldhckdxKF1jJAPP5cUcr" %}

{% tabs %}
{% tab title="C#" %}

<pre class="language-csharp"><code class="lang-csharp">internal static class Program
<strong>{
</strong>  static Program()
  {
    Application.Services
      .AddOrReplaceService&#x3C;IWebSearchService, MySerpAPIService>();
  }
}
</code></pre>

{% endtab %}

{% tab title="VB.NET" %}

```vbnet
Module Program
    Shared Sub New()
        Application.Services.AddOrReplaceService( _
            Of IWebSearchService, MySerpAPIService)()
    End Sub
End Class
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/ai/components/built-in-services/iwebsearchservice.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
