---
title: How to Use Web Search (public)
description: Add the web search server-side tool to DigitalOcean Inference requests so the model can search for real-time information during a turn.
product: Inference
url: https://docs.digitalocean.com/products/inference/how-to/use-server-side-tools/use-web-search/
last_updated: "2026-08-24"
---

> **For AI agents:** The documentation index is at [https://docs.digitalocean.com/llms.txt](https://docs.digitalocean.com/llms.txt). Markdown versions of pages use the same URL with `index.html.md` in place of the HTML page (for example, append `index.html.md` to the directory path instead of opening the HTML document).

# How to Use Web Search (public)

Inference provides a single control plane for managing inference workflows. It includes a Model Catalog where you can view available foundation models, including both DigitalOcean-hosted and third-party commercial models, compare model capabilities and pricing, use routing to match inference requests to the best-fit model, and run inference using serverless or dedicated deployments.

**Note**:

  This feature is in [public preview](https://docs.digitalocean.com/platform/product-lifecycle/index.html.md#public-preview). To use it, opt in from the [**Feature Preview** page](https://cloud.digitalocean.com/account/feature-preview).

Web search is a built-in tool that gives the model access to real-time web content during inference. When you add web search in your API request, the model decides when a web search is needed, and the results are incorporated into the model’s response.

We use a third-party web search service (Exa.ai) for all models.

To enable web search, include a tool object with `type` set to `web_search` in the `tools` array of your request. When the model determines that a prompt benefits from web search, it searches for relevant information and incorporates the results into its response.

The following examples send Responses API requests with web search enabled:

### Python

```python
import os
from pydo.inference import Client

client = Client(token=os.environ.get("MODEL_ACCESS_KEY"))

resp = client.responses.create(
    model="openai-gpt-4o",
    input="What are the latest pricing changes for DigitalOcean Droplets?",
    tools=[
        {
            "type": "web_search",
            "max_uses": 3,
            "max_results": 5,
        }
    ],
    max_output_tokens=1024,
    stream=False,
)

print(resp)
```

### JavaScript

```javascript
import { InferenceClient } from "@digitalocean/dots";

const client = new InferenceClient({
    apiKey: process.env.MODEL_ACCESS_KEY,
});

const resp = await client.responses.create({
    model: "openai-gpt-4o",
    input: "What are the latest pricing changes for DigitalOcean Droplets?",
    tools: [
        {
            type: "web_search",
            max_uses: 3,
            max_results: 5,
        },
    ],
    max_output_tokens: 1024,
    stream: false,
});

console.log(resp);
```

### cURL

```shell
curl -X POST https://inference.do-ai.run/v1/responses \
  -H "Authorization: Bearer $MODEL_ACCESS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai-gpt-4o",
    "input": "What are the latest pricing changes for DigitalOcean Droplets?",
    "tools": [
      {
        "type": "web_search",
        "max_uses": 3,
        "max_results": 5
      }
    ],
    "max_output_tokens": 1024,
    "stream": false
  }'
```

Alternatively, specify `model: <model_name>:web` to enable model access to web search and web fetch. This is particularly useful in coding agents where you can only change the model name.

You can optionally limit the number of searches the model performs per request from 1 to 5 with `max_uses` and the number of results each search returns from 1 to 10 with `max_results` (defaults to 5). When the request reaches the limit, the model produces a final response using the results collected so far. For the full set of web search parameters, see the [Serverless Inference API reference](https://docs.digitalocean.com/products/inference/reference/api/serverless-inference/index.html.md).

The response looks similar to the following:

```js
{
  ...
  "output": [
    {
      "action": {
        "queries": [
          "DigitalOcean AI platform features"
        ],
        "query": "DigitalOcean AI platform features",
        "type": "search"
      },
      "id": "ws_call_t7eyYNbAWQOcEln1Ns2TxuOv",
      "status": "completed",
      "type": "web_search_call"
    },
    {
      "content": [
        {
          "annotations": [
            {
              "end_index": 1501,
              "start_index": 1439,
              "title": "DigitalOcean AI Platform Features | DigitalOcean Documentation",
              "type": "url_citation",
              "url": "https://docs.digitalocean.com/products/inference/details/features"
            },
            {
              "end_index": 1800,
              "start_index": 1729,
              "title": "DigitalOcean Inference Details | DigitalOcean Documentation",
              "type": "url_citation",
              "url": "https://docs.digitalocean.com/products/inference/details"
            },
            {
              "end_index": 2085,
              "start_index": 2028,
              "title": "Agent Platform | Build AI Agents with DigitalOcean",
              "type": "url_citation",
              "url": "https://www.digitalocean.com/products/inference/platform"
            }
          ],
          "logprobs": [],
          "text": "The DigitalOcean AI Platform offers a variety of features:\n\n1. **AI Agent Development**: Build fully-managed AI ...",
          "type": "output_text"
        }
      ],
...
  }
}
```