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

# ModelsLabs

> ModelsLabTools generates images, video, and audio from text prompts using the ModelsLab API.

## Prerequisites

You need to install the `requests` and `openai` libraries.

```bash theme={null}
uv pip install requests openai
```

Set the `MODELS_LAB_API_KEY` environment variable.

```bash theme={null}
export MODELS_LAB_API_KEY=****
```

## Example

The following agents use ModelsLabs to generate images, videos, and audio from text prompts.

```python cookbook/91_tools/models_lab_tools.py theme={null}
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 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
)

# 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",
    )
```

## Toolkit Params

| Parameter             | Type            | Default        | Description                                                                           |
| --------------------- | --------------- | -------------- | ------------------------------------------------------------------------------------- |
| `api_key`             | `Optional[str]` | `None`         | The ModelsLab API key for authentication. Uses `MODELS_LAB_API_KEY` if not set        |
| `wait_for_completion` | `bool`          | `False`        | Whether to wait for the video to be ready                                             |
| `add_to_eta`          | `int`           | `15`           | Time to add to the ETA to account for the time it takes to fetch the video            |
| `max_wait_time`       | `int`           | `60`           | Maximum time to wait for the video to be ready                                        |
| `file_type`           | `FileType`      | `FileType.MP4` | The type of file to generate (MP4, GIF, PNG, JPG, WAV, MP3)                           |
| `model_id`            | `Optional[str]` | `None`         | ModelsLab model ID. Defaults per file type (`flux` for images, `cogvideox` for video) |
| `width`               | `int`           | `512`          | Width of the generated media                                                          |
| `height`              | `int`           | `512`          | Height of the generated media                                                         |

## Toolkit Functions

| Function         | Description                                                          |
| ---------------- | -------------------------------------------------------------------- |
| `generate_media` | Generates media (video, GIF, image, or audio) based on a text prompt |

## Developer Resources

* [Tools](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/models_labs.py)
