Slides Media and Rich Content
Adds images, YouTube videos, and styled backgrounds to presentations.
"""
Slides Media and Rich Content
==============================
Adds images, YouTube videos, and styled backgrounds to presentations.
The agent creates visually rich slides by embedding media content from
external URLs and Google Drive.
Key concepts:
- set_background_image: sets a slide background from a public image URL
- insert_youtube_video: embeds a YouTube player on a slide
- insert_drive_video: embeds a Google Drive video on a slide
- add_text_box: positions text annotations alongside media
Setup:
1. Create OAuth credentials at https://console.cloud.google.com (enable Slides API + Drive API)
2. Export GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, GOOGLE_PROJECT_ID env vars
3. pip install openai google-api-python-client google-auth-httplib2 google-auth-oauthlib
4. First run opens browser for OAuth consent, saves token.json for reuse
"""
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.google.slides import GoogleSlidesTools
agent = Agent(
name="Media Slides Agent",
model=OpenAIResponses(id="gpt-5.5"),
tools=[GoogleSlidesTools()],
instructions=[
"Create visually engaging slides with media content.",
"Use BLANK or TITLE_ONLY layouts for media slides.",
"Position videos and text boxes to avoid overlap.",
"Always use get_presentation_metadata to get slide IDs before modifications.",
"Add descriptive text boxes near embedded media.",
"Return the presentation URL when done.",
],
markdown=True,
)
if __name__ == "__main__":
agent.print_response(
"Create a presentation titled 'Product Launch'. "
"1. Add a TITLE_ONLY slide titled 'Product Demo'. "
"2. Embed a YouTube video with ID 'dQw4w9WgXcQ' on that slide "
"at x=2.0, y=1.8 with width=6.0 and height=3.5. "
"3. Add a text box below the video at y=5.5 with text "
"'Watch our product walkthrough'.",
stream=True,
)
# Set background image on a slide
# agent.print_response(
# "Using the presentation you just created, add a SECTION_HEADER slide "
# "titled 'Our Vision'. Then set its background image to "
# "https://images.unsplash.com/photo-1551288049-bebda4e38f71?w=1920",
# stream=True,
# )
# Combine multiple media types
# agent.print_response(
# "Add a BLANK slide to the presentation. "
# "Set a dark background image, then add a centered text box "
# "with 'Coming Soon' at y=3.0.",
# stream=True,
# )Use your own demo video ID in the prompt. All x, y, width, and height values are inches. Ask the agent to read the page dimensions before choosing geometry: the source's y=5.5 annotation with the default one-inch text-box height extends below a 5.625-inch-high slide. For that page size, a video at x=2, y=1.3, width=6, height=3.2 and a caption at x=2, y=4.7, width=6, height=0.4 fit vertically.
The toolkit embeds media references; background images must have a URL Google can fetch. Include the returned presentation ID explicitly when enabling a later prompt because conversation history is not configured.
Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno google-api-python-client google-auth google-auth-httplib2 google-auth-oauthlib openaiConfigure Google OAuth
Enable the Google API used by this example, configure the consent screen, and create a Desktop OAuth client in your Cloud project. Export its GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and GOOGLE_PROJECT_ID, or place the downloaded client JSON at credentials.json in the directory where you run Python. Google's Python quickstart shows the Desktop client setup.
The first tool call opens a browser for consent and caches credentials in token.json. Use a separate token_path when switching accounts. Passing an Agno user_id does not switch the authenticated Google account.
Export environment variables
export GOOGLE_CLIENT_ID="your_google_client_id_here"
export GOOGLE_CLIENT_SECRET="your_google_client_secret_here"
export GOOGLE_PROJECT_ID="your_google_project_id_here"
export OPENAI_API_KEY="your_openai_api_key_here"Run the example
Save the code above as media_slides.py, then run:
python media_slides.pyFull source: cookbook/91_tools/google/slides/media_slides.py