Sitemap

🚀 Building with Amazon Bedrock: How to Generate Video & Stream AI with Python

5 min readAug 6, 2025
Press enter or click to view image in full size
Image obtained from pump.co

Amazon Bedrock gives developers access to foundation models from top AI providers — without managing infrastructure. In this tutorial, I’ll guide you through building a simple generative AI pipeline using Amazon Bedrock with Python, including:

  • ✅ Generating videos
  • ✅ Creating and editing text
  • ✅ Streaming AI responses in real time

Let’s dive in! 🧠💻

🔧 Prerequisites

Before you start:

  • ✅ Python 3 installed
  • ✅ AWS CLI v2 configured with your IAM credentials
  • ✅ Jupyter Notebook installed
  • ✅ Access to Amazon Bedrock (Nova models)
  • ✅ An S3 bucket ready for storage

Install dependencies in a virtual environment:

python3 -m venv exercise1
source exercise1/bin/activate # For Mac
# Or: .\exercise1\Scripts\Activate.ps1 # For Windows

pip install boto3 jupyter

🎬 Task 1: Generate a Video with Amazon Bedrock

In your notebook:

import boto3
import json
import random

bedrock_runtime = boto3.client("bedrock-runtime", region_name="us-east-1")
s3 = boto3.client("s3")

model_id = "amazon.nova-reel-v1:0"
prompt = "A person dancing on a mountain."

video_input = {
"video": {
"prompt": prompt,
"config": {
"seed": random.randint(0, 100000),
"durationInSeconds": 4,
"format": "mp4",
"resolution": "720p",
"s3Uri": "s3://gen-ai-exercise-<YOUR_INITIALS>/video/"
}
}
}

response = bedrock_runtime.invoke_model(
modelId=model_id,
body=json.dumps(video_input),
contentType="application/json"
)

invocation_arn = json.loads(response['body'].read())['invocationArn']
print("Job submitted! Invocation ARN:", invocation_arn)
job_status = bedrock_runtime.get_async_invoke(invocationArn=invocation_arn)
print("Current Status:", job_status["status"])
Press enter or click to view image in full size
Screenshot of the AI Video Generation
Press enter or click to view image in full size
Screenshot of the AI Video Generation

✍️ Task 2: Generate Text with Bedrock

Create another notebook and run:

import boto3
import json

bedrock = boto3.client("bedrock-runtime", region_name="us-east-1")
model_id = "amazon.nova-micro-v1:0"

prompt = {
"inputText": "Rewrite the following sentence to be more formal: 'Hey, what's up?'"
}

response = bedrock.invoke_model(
modelId=model_id,
body=json.dumps(prompt),
contentType="application/json"
)

result = json.loads(response['body'].read())
print("Generated Text:", result)

Output:

{"output":
{"message":{"content":
[{"text":"You exhibit exceptional proficiency in your professional responsibilities."}],
"role":"assistant"}},
"stopReason":"end_turn",
"usage":{"inputTokens":19,"outputTokens":10,"totalTokens":29,"cacheReadInputTokenCount":0,"cacheWriteInputTokenCount":0}}

🌐 Task 3: Stream AI Responses (Real-time)

import boto3
import json

bedrock = boto3.client("bedrock-runtime", region_name="us-east-1")
model_id = "amazon.nova-micro-v1:0"

payload = {
"messages": [
{
"role": "user",
"content": "Tell me a story about a time-traveling scientist."
}
],
"stream": True
}

response = bedrock.invoke_model_with_response_stream(
modelId=model_id,
body=json.dumps(payload),
contentType="application/json"
)

for event in response['body']:
print(event.decode('utf-8'))

Output:

Receiving response stream:
There are numerous types of dances that people perform around the world, each with its own unique style, history, and cultural significance. Here are some of the most popular and widely recognized types of dances:

### Traditional and Folk Dances
1. **Ballet** - A classical dance form that originated in Italy and evolved in France and Russia. It is characterized by its grace, precision, and use of formal technique.
2. **Hip-Hop** - A street dance style that originated in African-American and Latino communities in the United States. It includes various sub-styles like breaking, locking, and popping.
3. **Salsa** - A lively Latin dance that originated in Cuba and has evolved in New York City. It is a partner dance with a strong rhythm.
4. **Tango** - An elegant and passionate dance that originated in the working-class neighborhoods of Buenos Aires, Argentina.
5. **Flamenco** - A traditional Spanish dance from the Andalusian region, characterized by its passionate music, intricate footwork, and expressive dance.
6. **Bhangra** - A traditional Punjabi dance from India, known for its energetic and fast-paced movements.
7. **Cachucha** - A Spanish folk dance that involves intricate footwork and is often performed to the rhythm of castanets.

### Social and Partner Dances
1. **Waltz** - A smooth, elegant dance that originated in Austria and Germany. It is typically danced in triple time.
2. **Tango** - As mentioned earlier, it's also known for its dramatic and passionate style.
3. **Foxtrot** - A smooth dance that originated in the early 20th century and is characterized by its flowing movements.
4. **Cha-Cha** - A Latin dance that evolved from the Cuban danzón and is known for its lively and upbeat tempo.
5. **Rumba** - A passionate and sensual dance that originated in Cuba, often characterized by hip movements.
6. **Samba** - A Brazilian dance that is known for its energetic and rhythmic movements, often associated with Carnival celebrations.

### Contemporary Dances
1. **Contemporary Dance** - A style that blends elements of ballet, modern dance, and other styles. It focuses on expressive movement and often tells a story.
2. **Modern Dance** - A dance style that emerged in the early 20th century as a reaction against the constraints of classical ballet. It emphasizes freedom of movement and expression.
3. **Jazz Dance** - A style that combines elements of tap, ballet, and modern dance. It is often seen in musical theater and film.

### Cultural and Regional Dances
1. **Bollywood Dance** - Dance styles popularized by Indian cinema, often combining classical Indian dance with Western styles.
2. **K-Pop Dance** - Dance styles associated with Korean pop music, known for their high-energy and synchronized choreography.
3. **Irish Step Dancing** - A traditional dance from Ireland characterized by rapid movements of the feet while the body remains almost motionless.
4. **Zulu Dance** - A traditional dance from South Africa, often performed during celebrations and featuring rhythmic movements and clapping.

### Performance Dances
1. **Tap Dance** - A style of dance that uses the sounds of tap shoes striking the floor as a form of percussion.
2. **Breakdancing** - A dynamic and acrobatic style of dance that is part of the hip-hop culture.
3. **Ballroom Dance** - A category of partner dances that includes many of the styles mentioned above, often performed in formal settings.

### Dances by Region
1. **African Dance** - Diverse styles that vary widely across different ethnic groups and regions in Africa, often involving complex rhythms and communal participation.
2. **Middle Eastern Dance** - Includes styles like belly dance, characterized by intricate movements and storytelling through dance.

These are just a few examples of the many types of dances that people perform around the world. Each type of dance has its own unique characteristics and cultural significance.

🧠 Summary

You’ve just learned how to:

  • Launch generative AI jobs with Amazon Bedrock
  • Generate videos and text via simple Python calls
  • Stream responses in real time
  • Store AI-generated media in S3

Bedrock is perfect for building scalable, production-ready GenAI apps with minimal setup.

📚 Helpful Links

--

--

George Pipis
George Pipis

Written by George Pipis

Sr. Director, Data Scientist @ Persado | Co-founder of the Data Science blog: https://predictivehacks.com/