---
title: "Summarise YouTube with OpenAI Agents SDK | EnConvert"
description: "YouTube summarisation in OpenAI Agents SDK: EnConvert Distill returns schema-defined fields from up to 50 video URLs in one synchronous call, no HTML parsing"
canonical: "https://www.enconvert.com/solutions/summarise-youtube-with-openai-agents-sdk-enconvert"
locale: "en"
---

# How to Summarise YouTube with OpenAI Agents SDK

A developer building an OpenAI Agents SDK agent that processes YouTube videos needs structured content from the page before the agent can reason or answer questions about it. YouTube watch pages mix the video title and description with channel info, comment threads, related video panels, and recommendations, and scraping them requires HTML parsing that breaks when YouTube updates its layout. EnConvert Distill accepts a YouTube URL and a schema the agent defines, and returns structured fields in one synchronous call. The @function_tool returns schema-defined video content ready for the agent to reason over with no HTML parsing dependency.

## Example

```python
import os

import requests
from agents import Agent, Runner, function_tool

# The OpenAI Agents SDK reads OPENAI_API_KEY from the environment

BASE_URL = "https://api.enconvert.com/v2"
headers = {
    "X-API-Key": os.environ["ENCONVERT_API_KEY"],
    "Content-Type": "application/json",
}

VIDEO_SCHEMA = {
    "title": "The video title",
    "channel": "The name of the channel that published the video",
    "description_summary": "A two sentence summary of the video description",
    "main_topics": "The main topics the video covers, as a list",
    "transcript_summary": (
        "A three sentence summary of the spoken transcript. "
        "Return an empty string if the transcript text is not on the page."
    ),
}


@function_tool
def summarise_youtube_videos(urls: list[str]) -> str:
    """Reads YouTube watch pages and returns structured fields for each video:
    title, channel, description summary, main topics, and transcript summary.
    Accepts up to 50 URLs."""
    if len(urls) > 50:
        return "Too many URLs. Distill accepts at most 50 per call."

    # One synchronous call: no job_id, no polling, no download step
    response = requests.post(
        f"{BASE_URL}/distill",
        headers=headers,
        json={"urls": urls, "schema": VIDEO_SCHEMA},
        timeout=300,
    )

    # Distill runs on paid plans only, and the free tier returns 402
    if response.status_code == 402:
        return "Distill requires a paid plan."
    response.raise_for_status()

    videos = []
    for result in response.json()["results"]:
        if result["status"] != "completed":
            videos.append(f"Source: {result['url']}\nCould not be read ({result['status']}).")
            continue

        render_quality = result.get("render_quality", 1.0)
        if render_quality < 0.5:
            videos.append(
                f"Source: {result['url']}\nLow render quality ({render_quality}), skipped."
            )
            continue

        data = result["data"]  # keys match VIDEO_SCHEMA exactly
        topics = data["main_topics"]
        transcript = data["transcript_summary"] or "Not available on the page."
        videos.append(
            f"Source: {result['url']}\n"
            f"Title: {data['title']}\n"
            f"Channel: {data['channel']}\n"
            f"Topics: {', '.join(topics) if isinstance(topics, list) else topics}\n"
            f"Description summary: {data['description_summary']}\n"
            f"Transcript summary: {transcript}"
        )
    return "\n\n---\n\n".join(videos)


agent = Agent(
    name="Video Assistant",
    instructions=(
        "You answer questions about YouTube videos. Use summarise_youtube_videos to read the "
        "videos you need, answer only from what it returns, and cite the video URL for every "
        "statement. If a transcript summary is not available, say the answer rests on the "
        "title and description only."
    ),
    tools=[summarise_youtube_videos],
    model="gpt-4.1",
)

result = Runner.run_sync(
    agent,
    "Read https://www.youtube.com/watch?v=zjkBMFhNj_g and summarise what the video covers.",
)
print(result.final_output)
```

## Output

Distill returns schema-defined fields inline as structured JSON in the data object, with no polling, no job_id, and no signed URL to fetch. The render_quality score lets the agent detect a challenge page before reasoning over incomplete content. Scraping YouTube watch pages directly returns HTML containing embedded player markup, structured data scripts, and recommendation panels mixed throughout, and a dedicated parser needs CSS selectors that break when YouTube changes its layout.

## Get started

[Get free API key — 500 ops per month, no card required. Note: Distill runs on paid plans. Free tier returns 402.](https://www.enconvert.com/auth?mode=signup)

## Related solutions

- [How to Summarise GitHub with Pydantic AI](https://www.enconvert.com/solutions/summarise-github-with-pydantic-ai-enconvert.md)
- [How to Summarise Google Docs with LangGraph](https://www.enconvert.com/solutions/summarise-google-docs-with-langgraph-enconvert.md)
- [How to Summarise GitHub with LlamaIndex](https://www.enconvert.com/solutions/summarise-github-with-llamaindex-enconvert.md)
- [How to Summarise Google Docs with Pydantic AI](https://www.enconvert.com/solutions/summarise-google-docs-with-pydantic-ai-enconvert.md)
- [How to Summarise YouTube Transcripts with LlamaIndex](https://www.enconvert.com/solutions/summarise-youtube-transcripts-with-llamaindex-enconvert.md)
- [How to Summarise GitHub Issues with CrewAI](https://www.enconvert.com/solutions/summarise-github-issues-with-crewai-enconvert.md)
