web_search tool in the Responses API.
In the Azure OpenAI Responses API, use the
web_search tool for web search.
The preview version of the web search tool (web_search_preview) is supported but not recommended. It has limitations.- Web Search uses Grounding with Bing Search and/or Grounding with Bing Custom Search, which are First Party Consumption Services governed by these Grounding with Bing terms of use and the Microsoft Privacy Statement.
- The Microsoft Data Protection Addendum doesn’t apply to data sent to Grounding with Bing Search and/or Grounding with Bing Custom Search. When you use Grounding with Bing Search and/or Grounding with Bing Custom Search, your data flows outside your compliance and geo boundary.
- Use of Grounding with Bing Search and Grounding with Bing Custom Search incurs costs. To learn more, see pricing.
- Learn more about how Azure admins can manage access to the use of Web search.
Prerequisites
- An Azure OpenAI model deployed.
- An authentication method:
- API key, or
- Microsoft Entra ID.
- Install the client library for your language:
- Python:
pip install openai azure-identity - .NET:
dotnet add package OpenAIanddotnet add package Azure.Identity - JavaScript/TypeScript:
npm install openai @azure/identity - Java: Add
com.openai:openai-javaandcom.azure:azure-identityto your project.
- Python:
- For REST examples, set
AZURE_OPENAI_API_KEY(API key flow) orAZURE_OPENAI_AUTH_TOKEN(Microsoft Entra ID flow).
Options to use web search
Web search supports three modes. Choose the mode based on the depth and speed you need.Web search without reasoning
The model forwards the user query directly to the web search tool and uses top-ranked sources to ground the response. There’s no multi-step planning. This mode is fast and best for quick lookups and timely facts.Agentic search with reasoning models
The model actively manages the search process and can perform web searches as part of its chain of thought, analyze results, and decide whether to keep searching. This flexibility makes agentic search well suited for complex workflows, but it also means searches take longer than quick lookups. For example, usegpt-5.5 with reasoning.effort set to medium or high to balance search depth and latency.
Deep research
Deep Research is an agent-driven mode designed for extended investigations. The model performs multi-step reasoning, opens and reads many pages, and synthesizes findings into a comprehensive, citation-rich response. Use this mode witho3-deep-research, or with gpt-5.5 and reasoning.effort set to high or xhigh.
Deep Research can run for several minutes and is best for background-style workloads that prioritize completeness over speed.
How it works
You use web search by declaring the tool{"type": "web_search"} in your request. The model decides whether to call the tool based on the user’s prompt and your configuration.
Web Search in the Responses API works with GPT-4 models and later.
gpt-5.5 with the name of your own model deployment. The same assert pattern shown in the basic Microsoft Entra ID snippets applies to the API-key snippets and the user-location and domain-filtering examples.
- Python
- C#
- JavaScript
- Java
- REST
Microsoft Entra ID:API key:
Response shape
A successful response that uses web search typically contains two parts:- A
web_search_calloutput item that records the action performed:search: a web search action, including the query (and optionally the searched domains). Search actions incur tool call costs (see pricing).open_page: indicates the agent opened a page. Available with all reasoning models.find_in_page: indicates the agent searched within an opened page. Available with all reasoning models.
- A message output item containing:
- The grounded text in
message.content[0].text. - URL citations in
message.content[0].annotations, one or moreurl_citationobjects that include the URL, title, and character ranges.
- The grounded text in
output array also contains a reasoning item alongside web_search_call and message. Parse the array by type rather than by position.
Control results by user location
You can refine search results by passing the approximate user location. The following fields are supported:The
city, region, and timezone fields are only supported when you use the web_search tool.Domain filtering
You can limit results to a specific set of domains by using domain filtering. Use theallowed_domains field to allowlist up to 100 URLs, or the blocked_domains field to exclude domains from results. You can omit the HTTP or HTTPS prefix when formatting the URLs. For example, use microsoft.com instead of https://www.microsoft.com/. Subdomains are also included in the search. Domain filtering works with the web_search tool only in the Responses API.
The OpenAI .NET and Java SDKs don’t yet expose typed builders for
blocked_domains. The C# and Java examples here use the SDKs’ public escape hatches (JsonPatch.Set for .NET, putAdditionalProperty for Java) to set the field. When typed builders ship, replace those calls with the typed equivalents.include to ["web_search_call.action.sources"]. The matched source URLs appear in the action.sources array of the web_search_call output item. Each entry contains a type and a url. Page titles aren’t returned in action.sources; the model’s grounded text includes titles in the url_citation annotations on the message item instead.
To return the search result snippets the model consulted, set include to ["web_search_call.results"]. The web_search_call.results option is supported only when you use a reasoning model.
Limitations
- Live internet access isn’t supported. Azure OpenAI always treats the
external_web_accessparameter asfalse. - The domain allow list supports up to 100 URLs.
- Web search call actions incur tool call costs. For more information, see pricing.
- The preview version of the web search tool (
web_search_preview) is supported but not recommended. - The
open_pageandfind_in_pageactions are available only with reasoning models.
Manage web search tool
You can enable or disable theweb_search tool in the Responses API at the subscription level by using Azure CLI. This setting applies to all accounts within the specified subscription.
Prerequisites
Before running the following commands, make sure you have the following prerequisites:- Azure CLI installed.
- You’re signed in to Azure by using
az login. - You have Owner or Contributor access to the subscription.
Disable web search
To disable theweb_search tool for all accounts in a subscription:
Enable web search
To enable theweb_search tool:
Troubleshooting
- No citations returned: Confirm your request includes
tools: [{"type": "web_search"}]. If the model doesn’t call the tool, prompt more explicitly to browse the web or ask for citations. - Tool is blocked: Ask your subscription admin to verify the subscription feature setting for blocked tools. See Manage web search tool.
- Authentication errors: For API keys, verify you set
AZURE_OPENAI_API_KEY. For Microsoft Entra ID, verify your token scope ishttps://ai.azure.com/.default.