> ## Documentation Index
> Fetch the complete documentation index at: https://assembly-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Auto Chapters

> The Auto Chapters model summarizes audio data over time into chapters. Chapters makes it easy for users to navigate and find specific information.

Each chapter contains the following:

* Summary
* One-line gist
* Headline
* Start and end timestamps

<Warning>
  ### Auto Chapters and Summarization

  You can only enable one of the Auto Chapters and [Summarization](/docs/audio-intelligence/summarization) models in the same transcription.
</Warning>

## Quickstart

Enable Auto Chapters by setting `auto_chapters` to `true` in the transcription config. `punctuate` must be enabled to use Auto Chapters (`punctuate` is enabled by default).

<CodeGroup>
  ```python python theme={"system"}
  import assemblyai as aai

  aai.settings.api_key = "YOUR_API_KEY"

  # audio_file = "./local_file.mp3"
  audio_file = "https://assembly.ai/wildfires.mp3"

  config = aai.TranscriptionConfig(auto_chapters=True)

  transcript = aai.Transcriber().transcribe(audio_file, config)

  for chapter in transcript.chapters:
    print(f"{chapter.start}-{chapter.end}: {chapter.headline}")
  ```

  ```TypeScript TypeScript theme={"system"}
  import { AssemblyAI } from 'assemblyai'

  const client = new AssemblyAI({
    apiKey: 'YOUR_API_KEY'
  })

  // const audioFile = './local_file.mp3'
  const audioFile =
    'https://assembly.ai/wildfires.mp3'

  const params = {
    audio: audioFile,
    auto_chapters: true
  }

  const run = async () => {
    const transcript = await client.transcripts.transcribe(params)

    for (const chapter of transcript.chapters!) {
      console.log(`${chapter.start}-${chapter.end}: ${chapter.headline}`)
    }
  }

  run()
  ```

  ```Go go theme={"system"}
  package main

  import (
      "context"
      "fmt"

      aai "github.com/AssemblyAI/assemblyai-go-sdk"
  )

  func main() {
      client := aai.NewClient("YOUR_API_KEY")

      // For local files see our Getting Started guides.
      audioURL := "https://assembly.ai/wildfires.mp3"

      ctx := context.Background()

      transcript, _ := client.Transcripts.TranscribeFromURL(ctx, audioURL, &aai.TranscriptOptionalParams{
          AutoChapters: aai.Bool(true),
      })

      for _, chapter := range transcript.Chapters {
          fmt.Printf("%d-%d: %s",
              aai.ToInt64(chapter.Start),
              aai.ToInt64(chapter.End),
              aai.ToString(chapter.Headline),
          )
      }
  }
  ```

  ```Java Java theme={"system"}
  import com.assemblyai.api.AssemblyAI;
  import com.assemblyai.api.resources.transcripts.types.*;

  public final class App {
      public static void main(String[] args) {

          AssemblyAI client = AssemblyAI.builder()
                  .apiKey("YOUR_API_KEY")
                  .build();

          // For local files see our Getting Started guides.
          String audioUrl = "https://assembly.ai/wildfires.mp3";

          var params = TranscriptOptionalParams.builder()
                  .autoChapters(true)
                  .build();

          Transcript transcript = client.transcripts().transcribe(audioUrl, params);

          var chapters = transcript.getChapters().get();

          chapters.forEach(chapter -> {
              System.out.println(chapter.getStart() + " - " + chapter.getEnd() + ": " +chapter.getHeadline());
          });
      }
  }
  ```

  ```C# C# theme={"system"}
  using AssemblyAI;
  using AssemblyAI.Transcript;

  var client = new AssemblyAIClient("YOUR_API_KEY");

  var transcript = await client.Transcripts.TranscribeAsync(new TranscriptParams
  {
      // For local files see our Getting Started guides.
      AudioUrl = "https://assembly.ai/wildfires.mp3",
      AutoChapters = true
  });

  foreach (var chapter in transcript.Chapters!)
  {
      Console.WriteLine($"{chapter.Start}-{chapter.End}: {chapter.Headline}");
  }
  ```

  ```Ruby Ruby theme={"system"}
  require 'assemblyai'

  client = AssemblyAI::Client.new(api_key: 'YOUR_API_KEY')

  # For local files see our Getting Started guides.
  audio_url = 'https://assembly.ai/wildfires.mp3'

  transcript = client.transcripts.transcribe(
    audio_url: audio_url,
    auto_chapters: true
  )

  transcript.chapters.each do |chapter|
    printf(
      '%<start>d-%<end>d: %<headline>s',
      start: chapter.start,
      end: chapter.end_,
      headline: chapter.headline
    )
  end
  ```
</CodeGroup>

### Example output

```
250-28840: Smoke from hundreds of wildfires in Canada is triggering air quality alerts across US
29610-280340: High particulate matter in wildfire smoke can lead to serious health problems
```

## API reference

### Request

```bash theme={"system"}
curl https://api.assemblyai.com/v2/transcript \
--header "Authorization: YOUR_API_KEY" \
--header "Content-Type: application/json" \
--data '{
  "audio_url": "YOUR_AUDIO_URL",
  "auto_chapters": true
}'
```

| Key             | Type    | Description           |
| --------------- | ------- | --------------------- |
| `auto_chapters` | boolean | Enable Auto Chapters. |

### Response

```json theme={"system"}
{
  "chapters": [
    {
      "gist": "...",
      "headline": "...",
      "summary": "...",
      "start": 0,
      "end": 0
    }
  ]
}
```

| Key                    | Type   | Description                                                                |
| ---------------------- | ------ | -------------------------------------------------------------------------- |
| `chapters`             | array  | An array of temporally sequential chapters for the audio file.             |
| `chapters[i].gist`     | string | An short summary in a few words of the content spoken in the i-th chapter. |
| `chapters[i].headline` | string | A single sentence summary of the content spoken during the i-th chapter.   |
| `chapters[i].summary`  | string | A one paragraph summary of the content spoken during the i-th chapter.     |
| `chapters[i].start`    | number | The starting time, in milliseconds, for the i-th chapter.                  |
| `chapters[i].end`      | number | The ending time, in milliseconds, for the i-th chapter.                    |

The response also includes the request parameters used to generate the transcript.

## Frequently asked questions

<Accordion title="Can I specify the number of chapters to be generated by the Auto Chapters model?">
  No, the number of chapters generated by the Auto Chapters model isn't configurable by the user. The model automatically segments the audio file into logical chapters as the topic of conversation changes.
</Accordion>

## Troubleshooting

<Accordion title="Why am I not getting any chapter predictions for my audio file?">
  One possible reason is that the audio file doesn't contain enough variety in topic or tone for the model to identify separate chapters. Another reason could be due to background noise or low-quality audio interfering with the model's analysis.
</Accordion>
