> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vidnavigator.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Analyzing Videos

> Learn how to analyze videos to extract summaries, topics, and other insights.

## Overview

VidNavigator's analysis capabilities allow you to go beyond simple transcription and understand the content of a video at a deeper level. You can get an AI-generated summary, identify key topics and speakers, and even ask specific questions about the video's content.

## Prerequisites

* A valid VidNavigator API key.
* The Python or JavaScript SDK installed in your project.

## Billing

AI analysis consumes `analysis_request` units based on context size. One unit covers up to **15,000 total tokens**, and longer contexts are billed with `ceil(total_tokens / 15000)`. For example, a video that takes 17,000 total tokens costs 2 `analysis_request` units.

## Analyzing a Video

### Using the Python SDK

```python theme={null}
from vidnavigator import VidNavigatorClient, VidNavigatorError

client = VidNavigatorClient()

try:
    analysis = client.analyze_video(
        video_url="https://www.youtube.com/watch?v=dQw4w9WgXcQ",
        query="What is the main theme of this song?"
    )
    print("Summary:", analysis.data.transcript_analysis.summary)
    print("Answer to your query:", analysis.data.transcript_analysis.query_answer)
except VidNavigatorError as e:
    print(f"An error occurred: {e.message}")
```

### Using the JavaScript SDK

```javascript theme={null}
const { VidNavigatorClient, VidNavigatorError } = require('vidnavigator');

const client = new VidNavigatorClient({
  apiKey: process.env.VIDNAVIGATOR_API_KEY,
});

async function analyzeVideo() {
  try {
    const result = await client.analyzeVideo({
      video_url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
      query: "What is the main theme of this song?"
    });
    console.log("Summary:", result.transcript_analysis.summary);
    console.log("Answer to your query:", result.transcript_analysis.query_answer);
  } catch (error) {
    if (error instanceof VidNavigatorError) {
      console.error(`An error occurred: ${error.message}`);
    } else {
      console.error("An unexpected error occurred:", error);
    }
  }
}

analyzeVideo();
```
