Models Lab Tools
Configure ModelsLabTools agents for image, video, and audio generation, then run image and sound-effect prompts.
The script runs image and sound-effect generation. It constructs a video agent but does not call it. Returned media URLs may describe queued outputs that are not ready to download.
The current adapter polls using a local artifact UUID instead of the provider’s request ID and can return a success message after polling times out. wait_for_completion=True does not fix this. For reliable completion tracking, use the provider API directly and retain the request ID for bounded status polling.
"""Run `uv pip install requests` to install dependencies."""
from agno.agent import Agent
from agno.models.response import FileType
from agno.tools.models_labs import ModelsLabTools
from agno.utils.media import download_audio
from agno.utils.pprint import pprint_run_response
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
# Create an image agent (PNG, using the Flux model)
image_agent = Agent(
tools=[
ModelsLabTools(file_type=FileType.PNG, model_id="flux", width=1024, height=1024)
],
send_media_to_model=False,
)
# Create a video agent (set to make MP4)
video_agent = Agent(
tools=[ModelsLabTools(file_type=FileType.MP4)], send_media_to_model=False
)
# Create audio agent (set to make WAV)
audio_agent = Agent(
tools=[ModelsLabTools(file_type=FileType.WAV)], send_media_to_model=False
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
# Generate an image
image_response = image_agent.run(
"Generate an image of a beautiful sunset over the ocean"
)
pprint_run_response(image_response, markdown=True)
# Generate a sound effect
response = audio_agent.run("Generate a SFX of a ocean wave", markdown=True)
pprint_run_response(response, markdown=True)
if response.audio and response.audio[0].url:
download_audio(
url=response.audio[0].url,
output_path="./tmp/nature.wav",
)Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno openai requestsExport your API keys
export MODELS_LAB_API_KEY="your_models_lab_api_key_here"
export OPENAI_API_KEY="your_openai_api_key_here"Separate submission from download
Remove the final download_audio(...) block before running. Inspect the returned audio URL and download it separately only after the provider reports completion. The adapter does not expose the provider request ID, so use a direct provider integration when your application must track a queued job.
Run the example
Save the code above as models_lab_tools.py, then run:
python models_lab_tools.pyFull source: cookbook/91_tools/models_lab_tools.py