12 customUserLocationExampleCoarse,12 customUserLocationExampleCoarse,
13 customUserLocationExampleCoarseChat,13 customUserLocationExampleCoarseChat,
14 listSourcesExample,14 listSourcesExample,
15 returnTokenBudgetExample,
15 searchContextSize,16 searchContextSize,
16} from "./web-search-examples";17} from "./web-search-examples";
17 18
28## Choose an integration29## Choose an integration
29 30
30| Use case | Recommended path | Notes |31| Use case | Recommended path | Notes |
31| --------------------------------------------- | --------------------------------------------- | ------------------------------------------------------------------------------------- |32| --------------------------------------------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
32| New web search integration | Responses API with `web_search` and `gpt-5.5` | Supports hosted web search controls such as filters, sources, and live-access control |33| New web search integration | Responses API with `web_search` and `gpt-5.5` | Supports hosted web search controls such as filters, sources, live-access control, and longer research runs |
33| Existing Chat Completions search integration | Chat Completions with `gpt-5-search-api` | Use this only when you need to preserve a Chat Completions integration |34| Existing Chat Completions search integration | Chat Completions with `gpt-5-search-api` | Use this only when you need to preserve a Chat Completions integration |
34| Multi-step research or long-running reporting | `gpt-5.5` with `high` or `xhigh` reasoning | Use background mode for reports that can take several minutes |35| Multi-step research or long-running reporting | `gpt-5.5` with `high` or `xhigh` reasoning | Use background mode for reports that can take several minutes |
35 36
36Using the [Responses API](https://developers.openai.com/api/docs/api-reference/responses), you can enable web search by configuring it in the `tools` array in an API request to generate content. Like any other tool, the model can choose to search the web or not based on the content of the input prompt.37Using the [Responses API](https://developers.openai.com/api/docs/api-reference/responses), you can enable web search by configuring it in the `tools` array in an API request to generate content. Like any other tool, the model can choose to search the web or not based on the content of the input prompt.
37 38
38For new Responses API integrations, use `{ "type": "web_search" }`. The earlier `web_search_preview` tool remains available for legacy integrations, but it does not support newer controls such as `filters` and `external_web_access`.39For new Responses API integrations, use `{ "type": "web_search" }`. The earlier `web_search_preview` tool remains available for legacy integrations, but it does not support newer controls such as `filters`, `external_web_access`, and `return_token_budget`.
39 40
40## Output and citations41## Output and citations
41 42
97## Migrating from legacy web search98## Migrating from legacy web search
98 99
99| If you use | Recommended path | Notes |100| If you use | Recommended path | Notes |
100| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |101| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
101| `web_search_preview` in Responses | Migrate to `web_search` | `web_search` supports newer controls such as `filters` and `external_web_access` |102| `web_search_preview` in Responses | Migrate to `web_search` | `web_search` supports newer controls such as `filters`, `external_web_access`, and `return_token_budget` |
102| `gpt-4o-search-preview` or `gpt-4o-mini-search-preview` | Migrate to Responses `web_search`, or use `gpt-5-search-api` if you must stay on Chat Completions | The preview search models are deprecated and shut down on 2026-07-23 |103| `gpt-4o-search-preview` or `gpt-4o-mini-search-preview` | Migrate to Responses `web_search`, or use `gpt-5-search-api` if you must stay on Chat Completions | The preview search models are deprecated and shut down on 2026-07-23 |
103| Chat Completions search integrations | Use `gpt-5-search-api`, or migrate to Responses `web_search` for more tool controls and optional search | Chat Completions search models always search before responding; Responses search is a tool |104| Chat Completions search integrations | Use `gpt-5-search-api`, or migrate to Responses `web_search` for more tool controls and optional search | Chat Completions search models always search before responding; Responses search is a tool |
104 105
108 109
109 110
110 111
112## Run longer web research
113
114`return_token_budget` controls how much web search result content the tool can return during a Responses API search run with GPT-5+ reasoning models. Keep the default for most requests. Set it to `unlimited` only for high-effort research or evaluation runs that need to inspect many pages and might otherwise stop at the standard returned-token cap.
115
116Use `unlimited` selectively because it can increase latency and cost. For long-running multi-search tasks, use background mode (`background: true`) so the request can keep running asynchronously and you can retrieve the final response later.
117
118| Value | Behavior |
119| ----------- | ---------------------------------------------------------------------------------------------------------------------------- |
120| `default` | Uses the standard returned-token budget for web search results. This is the same behavior as omitting `return_token_budget`. |
121| `unlimited` | Removes the default returned-token budget for the web search run. |
122
123This parameter applies only to the hosted Responses API `web_search` tool with GPT-5+ reasoning web search. It does not change the search context window, and it does not apply to non-reasoning web search, legacy Search API paths, container web search, Chat Completions search models, or `web_search_preview`. Only `default` and `unlimited` are supported values; `null`, numbers, and other strings are rejected.
124
125
126
111## Domain filtering127## Domain filtering
112 128
113Domain filtering in web search lets you limit results to a specific set of domains. With the `filters` parameter you can configure up to 100 `allowed_domains` or up to 100 `blocked_domains`. When formatting domains, omit the HTTP or HTTPS prefix. For example, use `openai.com` instead of `https://openai.com/`. This approach also includes subdomains in the search. Note that domain filtering is only available in the Responses API with the `web_search` tool.129Domain filtering in web search lets you limit results to a specific set of domains. With the `filters` parameter you can configure up to 100 `allowed_domains` or up to 100 `blocked_domains`. When formatting domains, omit the HTTP or HTTPS prefix. For example, use `openai.com` instead of `https://openai.com/`. This approach also includes subdomains in the search. Note that domain filtering is only available in the Responses API with the `web_search` tool.
146 162
147#### Chat Completions API163#### Chat Completions API
148 164
149The Chat Completions API supports only specialized search models for web search. These models do not support Responses API `web_search` features such as domain filters, complete source lists, live-access control.165The Chat Completions API supports only specialized search models for web search. These models do not support Responses API `web_search` features such as domain filters, complete source lists, live-access control, and returned-token budget control.
150 166
151| Model | Context window | Limitation |167| Model | Context window | Limitation |
152| ---------------------------- | -------------: | -------------------------------------------------------------------------------------------------------------------------------------------- |168| ---------------------------- | -------------: | -------------------------------------------------------------------------------------------------------------------------------------------- |
171- Web search does not support [`gpt-5`](https://developers.openai.com/api/docs/models/gpt-5) with `minimal` reasoning.187- Web search does not support [`gpt-5`](https://developers.openai.com/api/docs/models/gpt-5) with `minimal` reasoning.
172- [`gpt-5.4`](https://developers.openai.com/api/docs/models/gpt-5.4) with reasoning effort set to `none` may produce lower-quality results.188- [`gpt-5.4`](https://developers.openai.com/api/docs/models/gpt-5.4) with reasoning effort set to `none` may produce lower-quality results.
173- Responses API web search uses the underlying model's tiered rate limits.189- Responses API web search uses the underlying model's tiered rate limits.
174- `web_search_preview` does not support `filters` and ignores `external_web_access`.190- `web_search_preview` does not support `filters` or `return_token_budget`, and ignores `external_web_access`.
175- With `tool_choice: "auto"`, search is optional. Use `tool_choice: "required"` or a specific web search tool choice when search must run.191- With `tool_choice: "auto"`, search is optional. Use `tool_choice: "required"` or a specific web search tool choice when search must run.
176 192
177## Usage notes193## Usage notes