Many AI applications start with a simple architecture. A user submits a question, the application sends it to a language model, and the model generates a response.
This approach works well for general questions. However, it becomes less reliable when users ask about current events, recently released software, updated documentation, product availability, or information that changes frequently.
One solution is to build a separate search service. The application sends queries to a search provider, retrieves web pages, extracts relevant information, and passes the results to the language model.
Although this approach provides flexibility, it also introduces additional infrastructure and maintenance work.
Amazon Bedrock Web Search offers another option. It provides a managed search capability that supported models can use during a request. Developers can add it to an existing AI application without hosting crawlers, maintaining a search index, or implementing their own search execution loop.
In this article, we will explore how to integrate this capability into an existing ASP.NET Core application and what developers should consider before using it in production.
Why an AI Application Needs Web Search
A language model does not automatically have access to the latest information on the internet.
Its responses depend on its trained knowledge and the context supplied by the application. When a user asks about something that happened recently, the model may provide outdated information or generate an answer without sufficient evidence.
Consider an application that helps developers troubleshoot programming problems.
A user might ask:
"What is the latest recommended configuration for authentication in ASP.NET Core?"
The answer may depend on current framework documentation. A model relying only on its existing knowledge may describe an older approach.
Web search helps solve this problem by retrieving relevant information and allowing the model to use it while generating the response.
Typical use cases include:
- Current software documentation and release information.
- Recent security advisories.
- Product updates and announcements.
- Technology comparisons based on current information.
- Troubleshooting issues involving recently changed APIs.
- Research questions that require external sources.
The goal is not to search the web for every question. It is to provide access to current information when the question requires it.
The Traditional Approach: Building Your Own Search Infrastructure
Before using a managed search capability, it is useful to understand what a traditional implementation involves.
A typical architecture looks like this:
User
|
v
AI Application
|
v
Search Provider API
|
v
Search Results
|
v
Content Extraction
|
v
Relevant Context
|
v
Language Model
|
v
Generated Answer
The application is responsible for coordinating each operation.
For example, developers may need to:
- Integrate a third-party search provider.
- Manage search API credentials.
- Process search results.
- Retrieve web page content.
- Remove unnecessary HTML and navigation elements.
- Extract relevant information.
- Control how much content is passed to the model.
- Handle provider failures and rate limits.
- Maintain citations and source information.
This architecture is useful when an application needs custom ranking, specialized indexing, or control over its retrieval process.
However, it also creates additional development and operational responsibilities.
How Amazon Bedrock Web Search Simplifies the Architecture
Amazon Bedrock provides Web Search as a built-in server-side tool for supported models.
Instead of creating a separate search service, the application adds the Web Search tool to its model request.
The architecture becomes:
User
|
v
AI Application
|
v
Amazon Bedrock Responses API
|
v
Supported Language Model
|
v
Web Search Tool
|
v
Search and Fetch
|
v
Grounded Model Response
|
v
AI Application
|
v
User
The model determines whether the request needs current information. If search is necessary, it can invoke the built-in tool.
Amazon Bedrock handles the search and retrieval operations on the server side.
There are two important operations:
Search retrieves relevant observations from Amazon's web index. Each observation can include a page title, URL, and content snippet.
Fetch retrieves content for a specific URL. Depending on the access configuration, it can use the Amazon Bedrock cache or retrieve content from the external web.
This distinction matters because Search and Fetch do not have identical data-access behavior.
The main advantage is that the application does not need to build and maintain its own search execution infrastructure.
Choose the Correct Amazon Bedrock API
One important implementation detail is that Web Search is not available through every Amazon Bedrock API.
It uses the Responses API through the Amazon Bedrock Mantle endpoint.
| API or endpoint | Web Search support |
|---|
| Bedrock Runtime InvokeModel | Not supported |
| Bedrock Runtime Converse | Not supported |
| Bedrock Mantle Responses API | Supported for eligible models |
Amazon Bedrock currently supports Web Search with OpenAI GPT-5.4 and later models through the Mantle endpoint in selected US commercial Regions.
For this example, we will use:
Model: openai.gpt-5.6-terra
Region: us-west-2
Endpoint: https://bedrock-mantle.us-west-2.api.aws/openai/v1/responses
The supported models and Regions can change, so verify availability before deploying the integration.
This is also important for applications already using the Bedrock Runtime endpoint. Adding a Web Search tool to an ordinary Runtime request will not enable the capability. The application must use the supported Mantle Responses API.
Add Web Search to an Existing ASP.NET Core Application
Let's integrate Web Search into a simple ASP.NET Core application.
We will use HttpClient to communicate with the Responses API. This keeps the example independent of a particular client SDK and makes the request structure easy to understand.
First, create a project:
dotnet new webapi -n AIWebSearchApp
cd AIWebSearchApp
Configure the application settings:
{
"Bedrock": {
"BaseUrl": "https://bedrock-mantle.us-west-2.api.aws/openai/v1",
"Model": "openai.gpt-5.6-terra"
}
}
Store the API key separately using an environment variable or a secure secrets provider.
For local development, you can use:
export BEDROCK_API_KEY="your-bedrock-api-key"
Register HttpClient in Program.cs:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHttpClient<BedrockSearchService>();
builder.Services.AddControllers();
var app = builder.Build();
app.MapControllers();
app.Run();
Now create a service named BedrockSearchService.cs.
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;
public class BedrockSearchService
{
private readonly HttpClient _httpClient;
private readonly IConfiguration _configuration;
public BedrockSearchService(
HttpClient httpClient,
IConfiguration configuration)
{
_httpClient = httpClient;
_configuration = configuration;
}
public async Task<string> AskAsync(
string question,
CancellationToken cancellationToken)
{
var apiKey = Environment.GetEnvironmentVariable(
"BEDROCK_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey))
{
throw new InvalidOperationException(
"Bedrock API key is missing.");
}
var baseUrl = _configuration["Bedrock:BaseUrl"];
var model = _configuration["Bedrock:Model"];
if (string.IsNullOrWhiteSpace(baseUrl) ||
string.IsNullOrWhiteSpace(model))
{
throw new InvalidOperationException(
"Bedrock configuration is incomplete.");
}
var endpoint = $"{baseUrl.TrimEnd('/')}/responses";
using var request = new HttpRequestMessage(
HttpMethod.Post,
endpoint);
request.Headers.Authorization =
new AuthenticationHeaderValue("Bearer", apiKey);
request.Content = JsonContent.Create(new
{
model,
input = question,
tools = new[]
{
new
{
type = "web_search",
search_context_size = "medium",
external_web_access = false
}
}
});
using var response = await _httpClient.SendAsync(
request,
cancellationToken);
var responseBody = await response.Content.ReadAsStringAsync(
cancellationToken);
if (!response.IsSuccessStatusCode)
{
throw new HttpRequestException(
$"Bedrock returned {(int)response.StatusCode}: " +
responseBody);
}
using var document = JsonDocument.Parse(responseBody);
var output = document.RootElement.GetProperty("output");
var answer = new System.Text.StringBuilder();
foreach (var item in output.EnumerateArray())
{
if (!item.TryGetProperty("type", out var type) ||
type.GetString() != "message")
{
continue;
}
if (!item.TryGetProperty("content", out var content))
{
continue;
}
foreach (var block in content.EnumerateArray())
{
if (block.TryGetProperty("type", out var blockType) &&
blockType.GetString() == "output_text" &&
block.TryGetProperty("text", out var text))
{
answer.AppendLine(text.GetString());
}
}
}
return answer.ToString();
}
}
This service sends the user question and enables Web Search through the tools array.
Notice the following configuration:
tools = new[]
{
new
{
type = "web_search",
search_context_size = "medium",
external_web_access = false
}
}
The model can decide when it needs to search. The application does not have to make a separate search-provider request or manually execute the search-and-fetch sequence.
We explicitly set external_web_access to false. This allows Search and cached Fetch operations while keeping retrieval within the AWS boundary.
Expose the Service Through an API Endpoint
The next step is to expose the functionality to application clients.
Create a controller named AIController.cs:
using Microsoft.AspNetCore.Mvc;
[ApiController]
[Route("api/ai")]
public class AIController : ControllerBase
{
private readonly BedrockSearchService _searchService;
public AIController(BedrockSearchService searchService)
{
_searchService = searchService;
}
[HttpPost("ask")]
public async Task<IActionResult> Ask(
[FromBody] AskRequest request,
CancellationToken cancellationToken)
{
if (string.IsNullOrWhiteSpace(request.Question))
{
return BadRequest(
"Question is required.");
}
var answer = await _searchService.AskAsync(
request.Question,
cancellationToken);
return Ok(new
{
Question = request.Question,
Answer = answer
});
}
}
public class AskRequest
{
public string Question { get; set; } = string.Empty;
}
The application now has a simple endpoint:
POST /api/ai/ask
Content-Type: application/json
Request:
{
"question": "What are the latest developments in .NET?"
}
The application sends the question to Amazon Bedrock. If the model determines that current information is required, it can use Web Search before generating the response.
For a production API, the response model should also preserve citation annotations rather than returning only the generated text.
Display Source Citations to Users
An AI application should not present search-grounded answers without making their sources available.
Amazon Bedrock returns URL citation annotations with the generated text. These annotations include information such as:
- Source title.
- Source URL.
- Start position in the answer.
- End position in the answer.
The application should extract and retain these annotations when processing the response.
For example, the client response could follow this structure:
{
"answer": "The latest documentation describes several changes...",
"sources": [
{
"title": "Official .NET Documentation",
"url": "https://example.com/documentation"
}
]
}
The URL in this example is illustrative. The application should use the actual citation values returned by Amazon Bedrock.
Preserving citations makes the application more transparent and allows users to verify the information independently.
Amazon's Web Search acceptable-use requirements also require applications to retain and display source citations and links when presenting outputs that incorporate Search Results to end users.
Security and Data Governance Considerations
Adding web search to an AI application introduces an important question: where does the retrieval process access information?
Amazon Bedrock provides the external_web_access setting to control whether Fetch can retrieve live content from the external web.
When it is false, Search uses the Amazon Bedrock web index and Fetch uses the Amazon Bedrock cache.
When it is true, Fetch can retrieve live external content after checking the cache, provided the calling identity has the required bedrock-websearch permission.
For applications that process sensitive business information, start with external_web_access set to false unless live external retrieval is an explicit requirement.
Also consider the following practices:
- Use IAM policies with only the permissions required by the application.
- Store credentials in AWS Secrets Manager or another secure configuration provider.
- Avoid logging API keys and sensitive user prompts.
- Configure request timeouts and cancellation.
- Handle throttling and service errors.
- Preserve source citations.
- Monitor Web Search activity through the appropriate AWS logging configuration.
- Review the latest Amazon Bedrock pricing before enabling the feature for a large user base.
Remember that the model's ability to search does not make every result accurate or authoritative. Applications should still validate important information, particularly when answers affect security, financial decisions, or production infrastructure.
When a Managed Search Service Is Not Enough
Amazon Bedrock Web Search is useful when an application needs general web information without managing its own search infrastructure.
However, it is not a replacement for every search architecture.
A custom search service may still be appropriate when an application requires:
- Searching private enterprise documents.
- Searching internal databases or knowledge bases.
- Custom ranking and relevance algorithms.
- Organization-specific content filtering.
- Specialized crawling and indexing.
- Full control over the retrieval pipeline.
- Custom search analytics and query processing.
For example, an application that searches internal engineering documentation should not assume that public web search can replace its private document retrieval system.
In such cases, a hybrid architecture can be useful. The application can retrieve internal information through its own retrieval service and use Web Search for relevant public information.
Summary
Adding web search to an AI application does not always require building a separate search service. Amazon Bedrock Web Search provides a managed capability that supported models can use through the Responses API.
By adding the Web Search tool to an existing model request, developers can avoid maintaining crawlers, search indexes, and custom search orchestration. The application can focus on its business logic, user experience, security, and response handling.
However, the integration still requires careful decisions about model and Region availability, IAM permissions, external web access, citations, and cost.
For applications that need current public information, managed Web Search can simplify the architecture significantly. For private enterprise data or specialized retrieval requirements, a custom search service may still be the better choice.
Join the conversation! Your thoughts help the community grow.