# AIMLAPITools gives agents image, video, speech and transcription

> Agno's AIMLAPITools toolkit connects an agent to AI/ML API's media models with one AIMLAPI_API_KEY and puts the generated images, videos and audio on the run output.

- Published: 2026-10-01
- Author: Hugo
- Categories: Changelog
- Canonical: https://www.agno.com/blog/aimlapitools-gives-agents-image-video-speech-and-transcription
- Markdown: https://www.agno.com/blog/aimlapitools-gives-agents-image-video-speech-and-transcription.md

Agno's `AIMLAPITools` puts each media capability behind its own `enable_*` flag and its own model setting, so an agent gets only the tools you pick. Out of the box it uses `openai/gpt-image-2` for images, `bytedance/seedance-2-5` for video, `openai/tts-1` for speech and `deepgram/nova-3` for transcription, and every model can be swapped for another one on the gateway.

![The four AIMLAPITools tools and what each returns. generate_image calls /v1/images/generations and returns an Image on response.images. generate_video calls /v2/video/generations, polls the job, and returns a Video on response.videos. generate_speech calls /v1/tts and returns an Audio on response.audio. transcribe_audio calls /v1/stt/create, polls the job, and returns the transcript text to the model.](https://www.agno.com/images/v3-1-0-aimlapi-tools.png)

The toolkit reads the same `AIMLAPI_API_KEY` as the `AIMLAPI` chat model, so one key runs both:

```python
from agno.agent import Agent
from agno.models.aimlapi import AIMLAPI
from agno.tools.models.aimlapi import AIMLAPITools

tools = AIMLAPITools(enable_generate_video=False, base_dir="tmp")
print([tool.__name__ for tool in tools.tools])
# ['generate_image', 'generate_speech', 'transcribe_audio']

agent = Agent(
    model=AIMLAPI(id="gpt-5.6-luna"),
    tools=[tools],
    send_media_to_model=False,
)

response = agent.run("Generate an image of a lighthouse in a storm")
for image in response.images or []:
    print(image.mime_type, len(image.content))
```

The image, video and speech tools download the finished file and return a `ToolResult` with an Agno `Image`, `Video` or `Audio` holding the bytes, the MIME type and, for images and video, the original prompt. `transcribe_audio` hands the transcript straight back to the model as text.

Video and transcription run as jobs on AI/ML API's side. The toolkit submits the job and polls it, every 5 seconds for up to 900 for video and every 2 seconds for up to 300 for a transcript, and it retries a transient poll failure up to three times so a network blip doesn't abandon a job that is still billing. Async agents get the same tools as coroutines under `arun`.

`transcribe_audio` takes an https URL or a path inside `base_dir`, and with `restrict_to_base_dir=True` it refuses anything outside that folder, which keeps a prompt from making the agent upload an arbitrary file. Asset downloads never carry your API key.

See the [cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/91_tools/models/aimlapi_tools.py), and learn more about [AI/ML API](https://docs.agno.com/models/providers/gateways/aimlapi/overview) in the documentation.
