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

# Generate Video with Audio

> Create AI-generated videos with synchronized sound, effects, and speech

This guide shows you how to generate an AI video that includes audio. With a single boolean field, the model produces synchronized ambient sound, effects, and any speech implied by your prompt, so the clip is ready to use without a separate audio pass.

## What You Will Build

<CardGroup cols={2}>
  <Card title="Synchronized Sound" icon="volume-high">
    Ambient audio and effects that match the action on screen
  </Card>

  <Card title="Spoken Lines" icon="comment">
    Dialogue or narration described in the prompt, voiced by the model
  </Card>

  <Card title="One Request" icon="bolt">
    Audio is generated together with the video, in the same job
  </Card>

  <Card title="Predictable Cost" icon="coins">
    A fixed with-audio rate per second, shown before you generate
  </Card>
</CardGroup>

## Before You Begin

Make sure you have:

* A [Pictory API key](https://app.pictory.ai/api-access)
* Node.js or Python installed on your machine
* The required packages installed

<CodeGroup>
  ```bash npm theme={null}
  npm install axios
  ```

  ```bash pip theme={null}
  pip install requests
  ```
</CodeGroup>

## Which Models Support Audio

| Model | Audio | AI Credits per Second (with audio) |
| - | - | - |
| `pixverse6` | Optional | 3.7 |
| `pixverse5.6` | Optional | 2.1 |
| `veo3.1` | Optional | 40 |
| `veo3.1_fast` | Optional | 15 |
| `omni-flash` | Always on | 13 |

<Note>
  `omni-flash` always produces audio. You do not need to send `audio: true` for it, and `audio: false` is rejected with a `400` validation error. Every other model generates a silent video unless you set `audio: true`.
</Note>

## Step-by-Step Guide

### Step 1: Set Up Your Request

Add `audio: true` to an otherwise ordinary video request. Describe the sounds you expect in the prompt: the model uses the description to decide what to voice.

<CodeGroup>
  ```javascript Node.js theme={null}
  import axios from "axios";

  const API_BASE_URL = "https://api.pictory.ai/pictoryapis";
  const API_KEY = "YOUR_API_KEY"; // Replace with your actual API key

  // Video generation with audio
  const videoRequest = {
    prompt: "Waves crash against a rocky shore at dusk while seagulls call overhead, wide shot with slow push-in",
    model: "pixverse6",
    aspectRatio: "16:9",
    duration: "8s",
    audio: true
  };
  ```

  ```python Python theme={null}
  import requests
  import time

  API_BASE_URL = "https://api.pictory.ai/pictoryapis"
  API_KEY = "YOUR_API_KEY"  # Replace with your actual API key

  # Video generation with audio
  video_request = {
      "prompt": "Waves crash against a rocky shore at dusk while seagulls call overhead, wide shot with slow push-in",
      "model": "pixverse6",
      "aspectRatio": "16:9",
      "duration": "8s",
      "audio": True
  }
  ```
</CodeGroup>

<Note>
  `audio` can be combined with every other option on the endpoint: reference images, a first frame, a first and end frame transition, or a video to extend. When extending on `veo3.1` or `veo3.1_fast`, audio applies to the new segment.
</Note>

### Step 2: Submit the Video Generation Request

Send the request to the AI Studio video generation endpoint.

<CodeGroup>
  ```javascript Node.js theme={null}
  async function generateVideoWithAudio() {
    try {
      console.log("Submitting video generation request with audio...");

      const response = await axios.post(
        `${API_BASE_URL}/v1/aistudio/videos`,
        videoRequest,
        {
          headers: {
            "Content-Type": "application/json",
            Authorization: API_KEY,
          },
        }
      );

      const jobId = response.data.data.jobId;
      console.log("Video generation started.");
      console.log("Job ID:", jobId);

      return jobId;
    } catch (error) {
      console.error("Error submitting request:", error.response?.data || error.message);
      throw error;
    }
  }
  ```

  ```python Python theme={null}
  def generate_video_with_audio():
      try:
          print("Submitting video generation request with audio...")

          response = requests.post(
              f"{API_BASE_URL}/v1/aistudio/videos",
              json=video_request,
              headers={
                  "Content-Type": "application/json",
                  "Authorization": API_KEY
              }
          )
          response.raise_for_status()

          job_id = response.json()["data"]["jobId"]
          print("Video generation started.")
          print(f"Job ID: {job_id}")

          return job_id

      except requests.exceptions.RequestException as error:
          print(f"Error submitting request: {error}")
          raise
  ```
</CodeGroup>

### Step 3: Poll for the Result

Check the job status at regular intervals until the video is ready. The completed response is the same as for a silent video; the audio track is inside the delivered MP4.

<CodeGroup>
  ```javascript Node.js theme={null}
  async function waitForVideo(jobId) {
    console.log("\nPolling for video generation result...");

    while (true) {
      const response = await axios.get(
        `${API_BASE_URL}/v1/jobs/${jobId}`,
        {
          headers: { Authorization: API_KEY },
        }
      );

      const data = response.data;
      const status = data.data.status;
      console.log("Status:", status);

      if (status === "completed") {
        console.log("\nVideo generated successfully!");
        console.log("Video URL:", data.data.url);
        console.log("Duration:", data.data.duration);
        console.log("AI Credits Used:", data.data.aiCreditsUsed);
        return data;
      }

      if (status === "failed") {
        throw new Error("Video generation failed: " + JSON.stringify(data));
      }

      // Wait 15 seconds before polling again
      await new Promise(resolve => setTimeout(resolve, 15000));
    }
  }

  // Run the complete workflow
  generateVideoWithAudio()
    .then(jobId => waitForVideo(jobId))
    .then(result => console.log("\nDone!"))
    .catch(error => console.error("Error:", error));
  ```

  ```python Python theme={null}
  def wait_for_video(job_id):
      print("\nPolling for video generation result...")

      while True:
          response = requests.get(
              f"{API_BASE_URL}/v1/jobs/{job_id}",
              headers={"Authorization": API_KEY}
          )
          response.raise_for_status()

          data = response.json()
          status = data["data"]["status"]
          print(f"Status: {status}")

          if status == "completed":
              print("\nVideo generated successfully!")
              print(f"Video URL: {data['data']['url']}")
              print(f"Duration: {data['data']['duration']}")
              print(f"AI Credits Used: {data['data']['aiCreditsUsed']}")
              return data

          if status == "failed":
              raise Exception(f"Video generation failed: {data}")

          # Wait 15 seconds before polling again
          time.sleep(15)

  # Run the complete workflow
  if __name__ == "__main__":
      job_id = generate_video_with_audio()
      result = wait_for_video(job_id)
      print("\nDone!")
  ```
</CodeGroup>

## Understanding the Parameters

| Parameter | Type | Required | Default | Description |
| - | - | - | - | - |
| `prompt` | string | Yes | - | A descriptive text of the video to generate, including the sounds you expect. Must be between 5 and 5,000 characters. |
| `audio` | boolean | No | `false` (`true` on `omni-flash`) | Generate synchronized audio with the video. Rejected on models without audio support. |
| `model` | string | No | `pixverse5.6` | The AI model to use for generation. Supported values: `pixverse6`, `pixverse5.6`, `veo3.1`, `veo3.1_fast`, `omni-flash`. See [Generate Video API](/api-reference/ai-studio/generate-video) for model capabilities and pricing. |
| `aspectRatio` | string | No | First supported ratio of the selected model | The output aspect ratio. Valid values depend on the model. |
| `duration` | string | No | First supported duration of the selected model | The video length. Valid values depend on the model. |
| `trainingPreset` | string | No | - | `sales-training`, `product-training`, or `soft-skills-training`. Steers prompt enhancement and always turns it on, even when `enhancePrompt` is `false`. |
| `enhancePrompt` | boolean | No | `false` | Set to `true` to rewrite the prompt with the AI enhancer before generation. Off by default: the prompt is sent verbatim. |
| `webhook` | string | No | - | A URL to receive a POST notification when the job completes. Must be a valid URI. |

## How Audio Is Billed

Audio is not a surcharge on top of the silent rate; it is a separate per-second rate for the model. A `8s` video on `pixverse6` costs 21.6 credits without audio and 29.6 credits with audio. Credits are reserved when the job is created and released if the generation fails. The `aiCreditsUsed` field on the completed job shows the final charge.

## Tips for Video with Audio

* **Describe the soundscape.** Mention the sounds you want ("rain on a tin roof", "a crowd cheering") as well as the visuals. The model voices what the prompt describes.
* **Quote the dialogue.** For speech, put the exact words in the prompt, for example: a barista says "Your coffee is ready."
* **Keep clips self-contained.** Audio is generated per job, so when you build multi-segment videos, describe a natural sound at the end of one segment and the start of the next to avoid abrupt cuts.
* **Check the listing.** Videos returned by [Get Generated Videos](/api-reference/ai-studio/get-videos) carry an `audio` flag so you can tell silent and sound clips apart later.

## Next Steps

* [Generate Video from Text Prompt](/guides/ai-studio/text-to-video) for the basic video workflow
* [Generate Video from Reference Images](/guides/ai-studio/video-from-reference-images) to keep subjects consistent
* [Extend Video with AI](/guides/ai-studio/extend-video) to continue an existing video
* [Generate Video API Reference](/api-reference/ai-studio/generate-video) for the complete parameter documentation


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.