# YouTube Content Brief Agent (`thirdwatch/youtube-content-brief-agent`) Actor

Give it a topic. It finds the most-viewed YouTube videos, reads how they open, and writes a content brief with the winning hooks, the patterns behind them, and script ideas to make next.

- **URL**: https://apify.com/thirdwatch/youtube-content-brief-agent.md
- **Developed by:** [Thirdwatch](https://apify.com/thirdwatch) (community)
- **Categories:** AI, Videos
- **Features:** Limited permissions
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## YouTube content brief agent

The finished agent from the workshop. Give it a topic, and it tells a creator what is winning on
YouTube for that topic and what to make next.

### What it does

1. Searches YouTube for the most-viewed videos on the topic with
   [thirdwatch/youtube-scraper](https://apify.com/thirdwatch/youtube-scraper).
2. Reads how the strongest videos open, from their transcripts, with
   [thirdwatch/youtube-transcripts-scraper](https://apify.com/thirdwatch/youtube-transcripts-scraper).
3. Writes a brief: the winning videos, each hook quoted word for word, the patterns behind the
   hooks, and three script ideas.

The agent decides which videos are worth reading and whether it needs to read more. That is the
ReAct loop: reason, act, observe, repeat.

### Input

| Field | Type | What it is |
| --- | --- | --- |
| `topic` | string, required | The topic or niche, written the way a viewer would search for it |
| `maxVideos` | integer, default 5 | How many top videos the agent reads the opening of |
| `modelName` | string, default `deepseek/deepseek-v4.1-flash` | Any [OpenRouter model slug](https://openrouter.ai/models) |
| `debug` | boolean, default false | Writes the full tool results to the log |

### Output

One dataset item per run:

```json
{
    "topic": "how to start investing",
    "summary": "What wins in this topic and what to do about it.",
    "winning_videos": [
        {
            "title": "...",
            "url": "https://www.youtube.com/watch?v=...",
            "channel": "...",
            "views": 1234567,
            "hook": "The opening line, quoted from the transcript.",
            "why_it_works": "Why this opening keeps people watching."
        }
    ],
    "hook_patterns": ["A pattern specific enough to copy."],
    "script_ideas": [
        {
            "title": "...",
            "hook": "The first sentences to say on camera.",
            "outline": ["Beat 1", "Beat 2", "Beat 3"]
        }
    ]
}
```

The same brief is saved as a readable report under the `brief.md` key in the run's key-value
store.

### Where to look in the code

- [`my_actor/tools.py`](./my_actor/tools.py) - the two tools. Each one runs a Store Actor and
  returns a trimmed result.
- [`my_actor/models.py`](./my_actor/models.py) - the shape of the tool results and of the brief.
- [`my_actor/main.py`](./my_actor/main.py) - the input, the LLM, the agent loop, and the output.
- [`my_actor/utils.py`](./my_actor/utils.py) - the log lines you see in the Log tab, and the
  Markdown report.

### Run it

```bash
apify push
```

Then start it in Apify Console. It runs only on the Apify platform, because the LLM goes through
the [Apify OpenRouter proxy](https://apify.com/apify/openrouter). Your account must be able to
run public Actors: the free plan can, the Creator plan cannot.

Pick a topic where people talk on camera. Music-only videos have no transcript to read. A run
takes one to two minutes.

# Actor input Schema

## `topic` (type: `string`):

The topic or niche you make videos about, written the way a viewer would search for it.

## `maxVideos` (type: `integer`):

How many top videos the agent reads the opening of. More videos give a richer brief and a longer run.

## `modelName` (type: `string`):

OpenRouter model slug (see https://openrouter.ai/models). The model is called through the Apify OpenRouter proxy, so no provider API key is needed.

## `debug` (type: `boolean`):

If enabled, the full tool results are written to the log.

## Actor input object example

```json
{
  "topic": "how to start investing",
  "maxVideos": 5,
  "modelName": "deepseek/deepseek-v4.1-flash",
  "debug": false
}
```

# Actor output Schema

## `brief` (type: `string`):

No description

## `results` (type: `string`):

No description

# 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 = {
    "topic": "how to start investing",
    "modelName": "deepseek/deepseek-v4.1-flash"
};

// Run the Actor and wait for it to finish
const run = await client.actor("thirdwatch/youtube-content-brief-agent").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 = {
    "topic": "how to start investing",
    "modelName": "deepseek/deepseek-v4.1-flash",
}

# Run the Actor and wait for it to finish
run = client.actor("thirdwatch/youtube-content-brief-agent").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "topic": "how to start investing",
  "modelName": "deepseek/deepseek-v4.1-flash"
}' |
apify call thirdwatch/youtube-content-brief-agent --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,thirdwatch/youtube-content-brief-agent"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/gbMR3HTcHteFFyjT1/builds/ZU64ietMdLY7PbGpG/openapi.json
