# **AI Dataset Search** (`dtrungtin/ai-dataset-search`) Actor

The actor lets you query any dataset using **plain English** instead of code. Point it at a dataset — for example the output of a scraper run — describe what you're looking for ("videos about race day at the Belgian Grand Prix", "items with more than 100k plays"), and it returns the matching items.

- **URL**: https://apify.com/dtrungtin/ai-dataset-search.md
- **Developed by:** [Tin](https://apify.com/dtrungtin) (community)
- **Categories:** AI
- **Stats:** 4 total users, 2 monthly users, 50.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.10 / actor start

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js/docs.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python/docs.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/integrations/mcp.md).

If your project is in a different language, use 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 Dataset Search

### What does AI Dataset Search do?

**AI Dataset Search** lets you query any [Apify dataset](https://docs.apify.com/platform/storage/dataset) using **plain English** instead of code. Point it at a dataset — for example the output of a scraper run — describe what you're looking for ("videos about race day at the Belgian Grand Prix", "posts by verified authors", "items with more than 100k plays"), and it returns the matching items **ranked by relevance**.

Under the hood, an AI model inspects the dataset's structure and turns your prompt into a search plan: fuzzy text search with [Fuse.js](https://www.fusejs.io/) across the most relevant fields, plus exact and numeric filters. You don't need to know the dataset's field names — the Actor figures them out for you.

Running on the Apify platform gives you API access, scheduling, integrations (Make, Zapier, webhooks), and run monitoring out of the box.

### Why use AI Dataset Search?

- **No query language to learn** — describe what you want in natural language.
- **Works with any dataset** — the schema is inferred automatically from the data, including nested fields.
- **Typo-tolerant** — fuzzy matching finds "Belgain GP" even when you meant "Belgian GP".
- **Ranked results** — every result carries a match score, best matches first.
- **Composable** — chain it after any scraper: scrape first, then search the results with a prompt.

### How to use AI Dataset Search

1. Open the Actor and go to the **Input** tab.
2. Paste the **dataset ID or URL** of the dataset you want to search — or, instead, enter an **Actor** (e.g. `apify/instagram-scraper`) to search the dataset of its latest successful run.
3. Write a **search prompt** describing what to find.
4. Set your **OpenAI API key** as the `OPENAI_API_KEY` environment variable (the Actor uses an OpenAI model to plan the search).
5. Click **Start** and open the **Output** tab when the run finishes.

### Input

| Field | Type | Description |
| --- | --- | --- |
| `datasetId` | string | Dataset ID (e.g. `wqoOfQSYVPInyFZhd`) or a dataset URL from the API or Console. |
| `actorId` | string | Alternative to `datasetId`: an Actor ID, `username/actor-name`, or Store URL — the default dataset of its latest successful run is searched. Ignored when `datasetId` is set. |
| `prompt` | string | Natural-language description of what to find. **Required.** |
| `maxItems` | integer | Maximum number of items loaded from the dataset (default `5000`). |

Provide either `datasetId` or `actorId`.

```json
{
    "datasetId": "wqoOfQSYVPInyFZhd",
    "prompt": "Find TikTok videos about race day at the Belgian Grand Prix",
    "maxItems": 5000
}
````

### Output

Matching items are pushed to the default dataset, sorted by relevance. Each item is the original dataset item plus a `score` field (lower = better match). You can download the dataset in various formats such as JSON, HTML, CSV, or Excel.

```json
{
    "score": 0.0016,
    "caption": "Come with us to tour F1 hospitality! #f1 #formula1 #f1spa #spagp ...",
    "url": "https://www.tiktok.com/@.../video/...",
    "author": { "uniqueId": "...", "verified": true },
    "stats": { "playCount": 518100, "diggCount": 39300 }
}
```

The columns after `score` depend entirely on the dataset you search — the Actor preserves the original items untouched.

### How much does it cost to search a dataset?

Each run makes **one small OpenAI API call** (the search planning step) — typically a fraction of a cent with a mini-class model — plus standard Apify platform usage for the compute. Searching thousands of items completes in seconds, so runs stay well within the free tier limits of both platforms for typical use.

### Tips for better results

- **Be specific in the prompt.** "Videos mentioning Mercedes with over 100k plays" gives the planner both a search phrase and a numeric filter to work with.
- **Limit `maxItems`** if you only need a quick answer from a huge dataset — fewer items means faster runs.
- **Check the run log.** The Actor logs the generated search plan (`PLAN`), so you can see exactly which fields were searched and which filters were applied.
- The Actor returns at most 100 top results per run.

### FAQ and support

**Which datasets can I search?** Any dataset your Apify account can read: your own runs' outputs or publicly accessible datasets.

**Does it modify the source dataset?** No — the source dataset is only read; results go to the run's own output dataset.

**Is my data sent anywhere?** Only the dataset's *field structure* with one example value per field is sent to OpenAI for planning — not the full dataset contents.

Found a bug or missing a feature? Please open an issue on the Actor's **Issues** tab — feedback is welcome. Custom solutions (different search backends, embedding-based semantic search, other LLM providers) can be built on request.

# Actor input Schema

## `datasetId` (type: `string`):

The Apify dataset to search. Accepts a dataset ID (e.g. "wqoOfQSYVPInyFZhd") or a dataset URL from the API or Console. Leave empty to use an Actor's latest run instead (see below).

## `actorId` (type: `string`):

Alternative to Dataset ID: an Actor whose latest successful run's default dataset will be searched. Accepts an Actor ID, "username/actor-name", or a Store URL (e.g. "apify/instagram-scraper"). Ignored when Dataset ID is set.

## `prompt` (type: `string`):

Natural language description of what to find in the dataset, e.g. 'products under $50 with rating above 4'. An AI model converts this into a fuse search plan.

## `maxItems` (type: `integer`):

Maximum number of items to load from the dataset for searching.

## Actor input object example

```json
{
  "datasetId": "r2GW9j1omvxGZ4fET",
  "prompt": "Find items matching...",
  "maxItems": 5000
}
```

# 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 = {
    "prompt": "Find items matching..."
};

// Run the Actor and wait for it to finish
const run = await client.actor("dtrungtin/ai-dataset-search").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 = { "prompt": "Find items matching..." }

# Run the Actor and wait for it to finish
run = client.actor("dtrungtin/ai-dataset-search").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 '{
  "prompt": "Find items matching..."
}' |
apify call dtrungtin/ai-dataset-search --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "**AI Dataset Search**",
        "description": "The actor lets you query any dataset using **plain English** instead of code. Point it at a dataset — for example the output of a scraper run — describe what you're looking for (\"videos about race day at the Belgian Grand Prix\", \"items with more than 100k plays\"), and it returns the matching items.",
        "version": "0.0",
        "x-build-id": "LFyaUTizSSQmDyvkF"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/dtrungtin~ai-dataset-search/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-dtrungtin-ai-dataset-search",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/dtrungtin~ai-dataset-search/runs": {
            "post": {
                "operationId": "runs-sync-dtrungtin-ai-dataset-search",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/dtrungtin~ai-dataset-search/run-sync": {
            "post": {
                "operationId": "run-sync-dtrungtin-ai-dataset-search",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "prompt"
                ],
                "properties": {
                    "datasetId": {
                        "title": "Dataset ID or URL",
                        "type": "string",
                        "description": "The Apify dataset to search. Accepts a dataset ID (e.g. \"wqoOfQSYVPInyFZhd\") or a dataset URL from the API or Console. Leave empty to use an Actor's latest run instead (see below).",
                        "default": "r2GW9j1omvxGZ4fET"
                    },
                    "actorId": {
                        "title": "Actor (latest run's dataset)",
                        "type": "string",
                        "description": "Alternative to Dataset ID: an Actor whose latest successful run's default dataset will be searched. Accepts an Actor ID, \"username/actor-name\", or a Store URL (e.g. \"apify/instagram-scraper\"). Ignored when Dataset ID is set."
                    },
                    "prompt": {
                        "title": "Search Prompt",
                        "type": "string",
                        "description": "Natural language description of what to find in the dataset, e.g. 'products under $50 with rating above 4'. An AI model converts this into a fuse search plan."
                    },
                    "maxItems": {
                        "title": "Max Items to Load",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Maximum number of items to load from the dataset for searching.",
                        "default": 5000
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
