Skip to content

Instantly share code, notes, and snippets.

@mikegc-aws
Created February 12, 2025 23:25
Show Gist options
  • Save mikegc-aws/ab395a7e2cae3303c1ce12e799ccb924 to your computer and use it in GitHub Desktop.
Save mikegc-aws/ab395a7e2cae3303c1ce12e799ccb924 to your computer and use it in GitHub Desktop.
Generate a video using Luma AI Ray2 with the Amazon Bedrock start_async_invoke call.
# Get AWS Account
# Enable access to Luma AI Ray2 in Bedrock Console (Model access from menu on left)
# Run this Python code in an environment with access to AWS account.
import boto3, time
bedrock_runtime = boto3.client('bedrock-runtime', region_name='us-west-2')
prompt = "Sci-fi city at night slow pan across the skyline"
s3_uri = 's3://[your bucket for output files]'
response = bedrock_runtime.start_async_invoke(
modelId='luma.ray-v2:0',
modelInput={
"prompt": prompt,
"aspect_ratio": "16:9",
"loop": False,
"duration": "5s",
"resolution": "720p"
},
outputDataConfig={
's3OutputDataConfig': {
's3Uri': s3_uri
}
}
)
while True:
async_invoke = bedrock_runtime.get_async_invoke(
invocationArn=response['invocationArn']
)
if async_invoke.get('status') != 'InProgress':
break
print(".", end="", flush=True)
time.sleep(5)
print("\n") # Add a newline after dots
print(f"Final status: {async_invoke.get('status')}")
print(f"Output Data Config: {async_invoke.get('outputDataConfig')}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment