Generate Video (ModelsLabTools)

Generate a video from a text prompt with ModelsLabTools and read the result from response.videos.

Create an agent that requests video generation using the ModelsLab API and reports the returned artifact URL.

Code

generate_video_using_models_lab.py
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.models_labs import ModelsLabTools

video_agent = Agent(
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[ModelsLabTools()],
    description="You are an AI agent that can generate videos using the ModelsLabs API.",
    instructions=[
        "When the user asks you to create a video, use the `generate_media` tool to create the video.",
        "Return the artifact URL and any estimated wait time. A future URL may still be processing.",
        "Do not promise playback or completed generation merely because a URL was returned.",
    ],
    markdown=True,
)

video_agent.print_response("Generate a video of a cat playing with a ball")
# To access the generated videos:
# response = video_agent.run("Generate a video of a cat playing with a ball")
# print(response.videos)

The local script prints text; it does not configure video playback. Generated artifacts are available in response.videos, but an artifact can contain a future URL while the provider is still processing. The current adapter's wait_for_completion=True path polls a local UUID instead of the provider job ID and can report success after its wait expires. Manage readiness through the provider API before downloading or displaying a completed video; enabling that flag alone is insufficient.

Usage

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno openai requests

Export your API keys

  export OPENAI_API_KEY="your_openai_api_key_here"
  export MODELS_LAB_API_KEY="your_models_lab_api_key_here"

Run Agent

python generate_video_using_models_lab.py