# AI Search Tool - Real-Time Web Search (`abotapi/ai-web-search-tool`) Actor

Give your AI agents real-world knowledge.

This Actor provides high-quality web, news, image, video, and book search results using a multi-backend DuckDuckGo–powered infrastructure, with automatic fallbacks to Brave, Bing, Yahoo, Google (where available).

- **URL**: https://apify.com/abotapi/ai-web-search-tool.md
- **Developed by:** [Abot API](https://apify.com/abotapi) (community)
- **Categories:** AI, Agents, News
- **Stats:** 58 total users, 7 monthly users, 100.0% runs succeeded, 3 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## AI Search Tool - Real-Time Web Search

A powerful web search actor designed for **AI agents and LLM applications** that need real-time knowledge.

### Why This Actor?

**Break Through Knowledge Cutoffs** - Give your LLM agents access to current information beyond their training data cutoff dates.

**Built for AI Agents** - Structured JSON output perfect for LangGraph, AutoGPT, LangChain, and custom AI agent frameworks.

**Reliable Results** - Multi-backend architecture with automatic fallback ensures you get results even when one search engine is rate-limited.

### Features

- **Multi-Backend Search** - Automatically falls back between DuckDuckGo, Bing, Brave, Google, and Yahoo
- **5 Search Types** - Web, Images, Videos, News, and Books
- **10+ Regions** - Localized search results (US, UK, AU, JP, and more)
- **Smart Filtering** - Safe search, time range filters, and result limits
- **Proxy Support** - Apify Proxy (residential/datacenter/SERP) and custom proxies
- **AI-Ready Output** - Clean JSON output in both Dataset and Key-Value Store

### Perfect For

- **LangGraph/LangChain Tools** - Real-time web search for agent workflows
- **ChatGPT Plugins** - External knowledge retrieval
- **RAG Systems** - Current web data for retrieval augmented generation
- **AI Research Assistants** - Fetch latest information on any topic
- **Autonomous Agents** - AutoGPT, BabyAGI, and similar frameworks

### Input Configuration

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `query` | string | **required** | Search query string |
| `maxResults` | int | 50 | Maximum number of results (1-500) |
| `resultType` | string | "web" | Type: `web`, `images`, `videos`, `news`, `books` |
| `region` | string | "us-en" | Region code (see below) |
| `safeSearch` | string | "moderate" | Options: `off`, `moderate`, `strict` |
| `timeRange` | string | "" | Filter: `d` (day), `w` (week), `m` (month), `y` (year) |
| `proxy` | object | null | Proxy configuration (optional) |

#### Advanced Configuration

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `dev_transform_fields` | array | \[] | Transform output to include only specified fields. Use dot notation for nested objects (e.g., `["title", "link", "snippet"]`) |
| `dev_dataset_name` | string | "default" | Save results into a custom named Dataset. Supports placeholders: `{ACTOR}`, `{DATE}`, `{TIME}` |
| `dev_dataset_clear` | boolean | false | Clear the dataset before inserting new data |

#### Example Input - Basic Web Search

```json
{
  "query": "artificial intelligence trends 2024",
  "maxResults": 10,
  "resultType": "web",
  "region": "us-en",
  "safeSearch": "moderate"
}
```

#### Example Input - Recent News with Time Filter

```json
{
  "query": "OpenAI GPT-5",
  "maxResults": 20,
  "resultType": "news",
  "region": "us-en",
  "timeRange": "w",
  "safeSearch": "off"
}
```

#### Example Input - With Apify Proxy

```json
{
  "query": "machine learning datasets",
  "maxResults": 50,
  "resultType": "web",
  "region": "us-en",
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"],
    "apifyProxyCountry": "US"
  }
}
```

### Supported Regions

| Code | Region | Code | Region |
|------|--------|------|--------|
| `us-en` | United States | `uk-en` | United Kingdom |
| `au-en` | Australia | `ca-en` | Canada |
| `nz-en` | New Zealand | `jp-jp` | Japan |
| `de-de` | Germany | `fr-fr` | France |
| `es-es` | Spain | `it-it` | Italy |
| `nl-nl` | Netherlands | `br-pt` | Brazil |

### Search Types

#### 1. Web Search (`resultType: "web"`)

Returns standard web search results with titles, snippets, and URLs.

**Output Fields:**

- `position` - Result ranking (1, 2, 3...)
- `title` - Page title
- `link` - Full URL
- `snippet` - Text excerpt
- `domain` - Domain name
- `query` - Original search query

#### 2. Image Search (`resultType: "images"`)

Returns image search results with thumbnails and metadata.

**Output Fields:**

- `position`, `title`, `link`
- `image` - Full-size image URL
- `thumbnail` - Thumbnail URL
- `source` - Source website
- `height`, `width` - Image dimensions

#### 3. Video Search (`resultType: "videos"`)

Returns video search results from multiple platforms.

**Output Fields:**

- `position`, `title`, `link`
- `description` - Video description
- `thumbnail` - Video thumbnail URL
- `duration` - Video length
- `published` - Publication date
- `publisher` - Source (YouTube, Vimeo, etc.)

#### 4. News Search (`resultType: "news"`)

Returns recent news articles with publication dates.

**Output Fields:**

- `position`, `title`, `link`
- `snippet` - Article excerpt
- `date` - Publication date
- `source` - News source name
- `image` - Article image URL

#### 5. Books Search (`resultType: "books"`)

Returns book search results from Anna's Archive and other sources.

**Output Fields:**

- `position`, `title`, `link`
- `author` - Book author
- `publisher` - Publisher and year
- `info` - Format and size info (e.g., "English \[en], .epub, 0.5MB")
- `thumbnail` - Book cover image URL

### Output Format

Results are stored in **two locations** for maximum flexibility:

#### 1. Dataset (Individual Results)

Each search result is stored as a separate item in the dataset:

```json
{
  "position": 1,
  "title": "Artificial intelligence",
  "link": "https://en.wikipedia.org/wiki/Artificial_intelligence",
  "snippet": "Artificial intelligence (AI) is the capability of computational systems...",
  "domain": "en.wikipedia.org",
  "query": "artificial intelligence"
}
```

#### 2. Key-Value Store (Complete Output)

Three keys are stored for different use cases:

**OUTPUT** - Full output with results and metadata:

```json
{
  "results": [
    {
      "position": 1,
      "title": "...",
      "link": "...",
      "snippet": "..."
    }
  ],
  "metadata": {
    "query": "artificial intelligence",
    "totalScraped": 10,
    "region": "us-en",
    "resultType": "web",
    "scrapeDuration": "2.18s"
  }
}
```

**RESULTS** - Just the results array for direct use

**METADATA** - Just the metadata object

### Proxy Configuration

#### Apify Proxy (Recommended)

```json
{
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"],
    "apifyProxyCountry": "US"
  }
}
```

**Available Proxy Groups:**

- `RESIDENTIAL` - High-quality residential IPs
- `DATACENTER` - Fast datacenter proxies
- `SERP` - Specialized for search engines

#### Custom Proxy URLs

```json
{
  "proxy": {
    "proxyUrls": [
      "http://user:pass@proxy1.example.com:8080",
      "http://user:pass@proxy2.example.com:8080"
    ]
  }
}
```

#### Manual Proxy Configuration

```json
{
  "proxy": {
    "protocol": "http",
    "hostname": "proxy.example.com",
    "port": 8080,
    "username": "user",
    "password": "pass"
  }
}
```

### Use Cases

#### 1. Real-Time Knowledge for LLMs

Give your AI assistant access to current events, latest research, or breaking news:

```json
{
  "query": "latest developments in quantum computing",
  "maxResults": 10,
  "timeRange": "w"
}
```

#### 2. Fact-Checking & Verification

Verify claims by searching recent news and authoritative sources:

```json
{
  "query": "climate change statistics 2024",
  "resultType": "news",
  "timeRange": "m",
  "safeSearch": "strict"
}
```

#### 3. Research Assistant

Gather information on specific topics for reports or analysis:

```json
{
  "query": "best practices machine learning deployment",
  "maxResults": 50,
  "resultType": "web"
}
```

#### 4. Content Discovery

Find images, videos, or news for content creation:

```json
{
  "query": "startup funding 2024",
  "resultType": "news",
  "maxResults": 20
}
```

# Actor input Schema

## `query` (type: `string`):

The search query to scrape results for

## `maxResults` (type: `integer`):

Maximum number of search results to scrape (1-500)

## `region` (type: `string`):

Region/language code for search results (e.g., us-en, uk-en, de-de, fr-fr, jp-jp)

## `safeSearch` (type: `string`):

Safe search filter level

## `timeRange` (type: `string`):

Filter results by time range (optional)

## `resultType` (type: `string`):

Type of search results to scrape

## `proxy` (type: `object`):

Optional proxy settings for web scraping. Supports Apify Proxy, custom proxy URLs, or manual configuration

## `dev_transform_fields` (type: `array`):

Transform output to include only specified fields. Use dot notation for nested objects.

## `dev_dataset_name` (type: `string`):

Save results into a custom named Dataset. Placeholders: {ACTOR}, {DATE}, {TIME}

## `dev_dataset_clear` (type: `boolean`):

Clear the dataset before inserting new data

## Actor input object example

```json
{
  "query": "python web scraping",
  "maxResults": 50,
  "region": "us-en",
  "safeSearch": "moderate",
  "timeRange": "",
  "resultType": "web",
  "proxy": {
    "useApifyProxy": false,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": ""
  },
  "dev_transform_fields": [],
  "dev_dataset_name": "default",
  "dev_dataset_clear": false
}
```

# Actor output Schema

## `searchResults` (type: `string`):

Individual search result items in the default dataset. Fields vary by resultType: web (position, title, link, snippet, domain, query), images (+ image, thumbnail, source, height, width), videos (+ description, thumbnail, duration, published, publisher), news (+ date, source, image), books (+ author, publisher, info, thumbnail).

## `completeOutput` (type: `string`):

Full output object containing both the results array and metadata object in a single response.

## `metadata` (type: `string`):

Execution metadata including query, totalScraped, region, resultType, and scrapeDuration.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "query": "Tesla",
    "proxy": {
        "useApifyProxy": false,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ],
        "apifyProxyCountry": ""
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("abotapi/ai-web-search-tool").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "query": "Tesla",
    "proxy": {
        "useApifyProxy": False,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxyCountry": "",
    },
}

# Run the Actor and wait for it to finish
run = client.actor("abotapi/ai-web-search-tool").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "query": "Tesla",
  "proxy": {
    "useApifyProxy": false,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": ""
  }
}' |
apify call abotapi/ai-web-search-tool --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=abotapi/ai-web-search-tool",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/VpVrm1iIlddRiCsVD/builds/Atdea3zXFKr3pxWjS/openapi.json
