> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.astropods.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.astropods.com/_mcp/server.

# Web search

The `gpt-*` models can search the web during a request and ground their answers in what they find. The search runs inside Amazon Bedrock, so there is no search API to wire up and no key to manage. The model decides on its own when a question needs current information.

The `gpt-*` models are served on both `/v1/chat/completions` and `/v1/responses`, but web search is available only on the Responses API. Call `/v1/responses`, add a `web_search` tool to the request, and set `external_web_access` to `false`.

**`Python`**

```python title="Python"
response = client.responses.create(
    model="gpt-5-6-luna",
    input="What did AWS announce this month?",
    tools=[{"type": "web_search", "external_web_access": False}],
)
print(response.output_text)
```

**`Mastra`**

```typescript title="Mastra"
import { createOpenAI } from "@ai-sdk/openai";
import { Agent } from "@mastra/core/agent";

const gateway = createOpenAI({
    apiKey: process.env.ASTRO_GATEWAY_API_KEY,
    baseURL: `${process.env.ASTRO_GATEWAY_URL}/v1`,
});

export const agent = new Agent({
    name: "my-agent",
    instructions: "You are a helpful assistant. Keep source links in your answers.",
    model: gateway("gpt-5-6-luna"),
    tools: {
        web_search: {
            ...gateway.tools.webSearch({ externalWebAccess: false }),
            id: "openai.web_search",
        },
    },
});
```

**`curl`**

```bash title="curl"
curl "$ASTRO_GATEWAY_URL/v1/responses" \
  -H "Authorization: Bearer $ASTRO_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5-6-luna",
    "input": "What did AWS announce this month?",
    "tools": [{"type": "web_search", "external_web_access": false}]
  }'
```

**Set `external_web_access` to `false`.** It defaults to `true`, which asks Bedrock to fetch live pages from the open internet. The gateway does not permit that, so a request that leaves the default gets a `403` on the fetch step: an answer still comes back grounded in search results, but with no page content behind it. With `false`, retrieval is served from Amazon's own web index and cache, and your request data stays inside AWS.

Answers carry `url_citation` annotations giving the title and URL behind each cited passage. Keep them. Amazon's terms require you to display the source citations to your end users.

## Next steps

* [Supported models](/ai-gateway/models): the `gpt-*` models that support search
* [Anthropic API](/ai-gateway/anthropic): why Claude models can't search