To analyze YouTube video captions with OpenAI, first you need to retrieve the captions, so our first request will be to get the captions for a YouTube video.

Request to get captions and send to OpenAI

import OpenAI from 'openai';

const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

// Fetch captions for the video
const response = await fetch(
  'https://api.poix.io/captions/L_Guz73e6fw?format=text',
  { headers: { Authorization: 'Bearer poix-xxx' } }
);
const captions = await response.json();

const response = await openai.chat.completions.create({
  model: 'gpt-4o',
  messages: [
    {
      role: 'system',
      content: [
        {
          // Use better prompt for better result
          type: 'text',
          text: `You are tasked with analyzing video captions to determine
                 he most trendy topics discussed by the speaker(s) in the
                 video. Your goal is to identify and rank the top 5 trendy
                 topics based on the content of the captions.`,
        },
      ],
    },
    {
      role: 'user',
      content: [
        {
          type: 'text',
          text: captions,
        },
      ],
    },
  ],
});

This example demonstrates how to use the OpenAI API to analyze YouTube video captions. We first fetch the captions for the video using the Poix.io API, then we use the OpenAI API to analyze the captions and determine the most trendy topics discussed in the video.

GPT-4o’s model response:

Based on the content of the video captions, here are the top 5 trendy topics discussed by the speaker(s), ranked by their prominence and impact on the conversation:


  1. Artificial General Intelligence (AGI): The primary focus of the discussion revolves around AGI, its potential, development challenges, and the historical context of its perception within the AI community. This includes developments by OpenAI and DeepMind, as well as the transition from skepticism to broader acceptance.

  1. GPT-4 and Language Models: A significant portion of the video is dedicated to discussing GPT-4, its capabilities, the underlying technology, user interactions, improvements over previous models, and the concept of reinforcement learning with human feedback (RLHF).

  1. AI Safety and Alignment: The conversation delves deeply into the ethical and safety considerations around AGI, including alignment challenges, potential risks, societal impacts, and the methods employed to ensure that AI systems operate in a way that is beneficial and non-harmful to humanity.

  1. Economic and Societal Impact of AI: There is extensive discussion on how AI advancements will affect the workforce, the economy, and social systems. Topics such as Universal Basic Income (UBI) and the transformative impact on various job sectors are covered to illustrate how AI might change human life and economic structures.

  1. Collaborations and Industry Dynamics: The relationship between OpenAI and Microsoft, as well as the broader dynamics within the tech industry involving other major players like Google and Meta, is explored. This includes considerations around investment, partnership benefits, and the competitive landscape of AI development.

These topics capture the essence of the conversation, reflecting both the technical aspects of AI development and the broader implications for society.