Support for images, audio, video, and file inputs/outputs.
from agno.media import Image
class Image:
def __init__(
self,
url: Optional[str] = None,
content: Optional[Union[str, bytes]] = None,
filepath: Optional[Union[str, Path]] = None,
format: Optional[str] = None,
**kwargs
): ...
@classmethod
def from_url(cls, url: str) -> Image: ...
@classmethod
def from_path(cls, path: Union[str, Path]) -> Image: ...
def get_content_bytes(self) -> bytes:
"""Get the image content as bytes."""
def to_base64(self) -> str:
"""Convert image to base64 encoded string."""
@classmethod
def from_base64(cls, base64_str: str, format: Optional[str] = None) -> Image:
"""Create Image from base64 encoded string."""from agno.media import Audio
class Audio:
def __init__(
self,
url: Optional[str] = None,
content: Optional[Union[str, bytes]] = None,
filepath: Optional[Union[str, Path]] = None,
format: Optional[str] = None,
**kwargs
): ...
@classmethod
def from_url(cls, url: str) -> Audio: ...
@classmethod
def from_path(cls, path: Union[str, Path]) -> Audio: ...
def get_content_bytes(self) -> bytes:
"""Get the audio content as bytes."""
def to_base64(self) -> str:
"""Convert audio to base64 encoded string."""
@classmethod
def from_base64(cls, base64_str: str, format: Optional[str] = None) -> Audio:
"""Create Audio from base64 encoded string."""from agno.media import Video
class Video:
def __init__(
self,
url: Optional[str] = None,
content: Optional[Union[str, bytes]] = None,
filepath: Optional[Union[str, Path]] = None,
format: Optional[str] = None,
**kwargs
): ...
@classmethod
def from_url(cls, url: str) -> Video: ...
@classmethod
def from_path(cls, path: Union[str, Path]) -> Video: ...
def get_content_bytes(self) -> bytes:
"""Get the video content as bytes."""
def to_base64(self) -> str:
"""Convert video to base64 encoded string."""
@classmethod
def from_base64(cls, base64_str: str, format: Optional[str] = None) -> Video:
"""Create Video from base64 encoded string."""from agno.media import File
class File:
def __init__(
self,
url: Optional[str] = None,
content: Optional[Union[str, bytes]] = None,
filepath: Optional[Union[str, Path]] = None,
name: Optional[str] = None,
format: Optional[str] = None,
**kwargs
): ...
@classmethod
def from_url(cls, url: str) -> File: ...
@classmethod
def from_path(cls, path: Union[str, Path]) -> File: ...
def get_content_bytes(self) -> bytes:
"""Get the file content as bytes."""
def to_base64(self) -> str:
"""Convert file to base64 encoded string."""
@classmethod
def from_base64(cls, base64_str: str, format: Optional[str] = None) -> File:
"""Create File from base64 encoded string."""from agno.agent import Agent
from agno.media import Image
agent = Agent(model=...)
# From URL
response = agent.run(
"What's in this image?",
images=[Image.from_url("https://example.com/image.jpg")]
)
# From file
response = agent.run(
"Describe this image",
images=[Image.from_path("./photo.jpg")]
)from agno.media import Audio
response = agent.run(
"Transcribe this audio",
audio=[Audio.from_path("./recording.mp3")]
)