← Back to guides

OpenAI Agents SDK + Agent Media Tools

Updated August 14, 2026 · 5 min read

The OpenAI Agents SDK lets you build autonomous AI agents that use tools. By connecting it to Agent Media Tools, your agents can resize images, scrape websites, generate PDFs, transcribe audio, and run 70+ utility operations — all from natural language instructions.

⚡ Your agents become media-capable. Give them tools for images, PDFs, web scraping, AI generation, and data processing with 5 lines of code.
Official Python SDK: agentmediatools is published on PyPI. The examples below use the released package; direct REST calls from the API reference remain fully supported.

Installation

python -m pip install openai-agents agentmediatools

Basic Setup

from agents import Agent, Runner, function_tool
from agentmediatools import Client

client = Client(api_key="mt_your_key_here")

@function_tool
async def resize_image(image_path: str, width: int, format: str = "webp") -> str:
    """Resize an image to the given width and format."""
    with open(image_path, "rb") as f:
        result = client.image.resize(f, width=width, format=format)
    out_path = f"resized_{image_path}"
    with open(out_path, "wb") as f:
        f.write(result)
    return f"Resized to {width}px → {out_path}"

@function_tool
async def screenshot_page(url: str) -> str:
    """Take a screenshot of a web page."""
    result = client.web.screenshot(url, full_page=True)
    out_path = "screenshot.png"
    with open(out_path, "wb") as f:
        f.write(result)
    return f"Screenshot saved → {out_path}"

@function_tool
async def generate_qr(text: str) -> str:
    """Generate a QR code for the given text."""
    result = client.qrcode.generate(text)
    with open("qrcode.png", "wb") as f:
        f.write(result)
    return "QR code saved → qrcode.png"

@function_tool
async def scrape_webpage(url: str) -> str:
    """Scrape a web page and return its content as markdown."""
    return client.scrape(url)

# Create an agent with these tools
agent = Agent(
    name="Media Assistant",
    instructions="You help users with media tasks. Use the available tools.",
    tools=[resize_image, screenshot_page, generate_qr, scrape_webpage],
)

# Run it
result = await Runner.run(agent, "Take a screenshot of example.com and save it")
print(result.final_output)

Using the Python SDK Directly

You can also skip the tool wrapping and let your agent code call the SDK directly:

from agentmediatools import Client

client = Client(api_key="mt_your_key_here")

# 🖼️ Image processing
client.image.resize("photo.jpg", width=1024, format="webp")
client.image.convert("photo.jpg", format="png")
client.image.compress("photo.jpg", quality=70)

# 📄 PDF operations
client.pdf.merge(["report1.pdf", "report2.pdf"])
text = client.pdf.to_text("document.pdf")

# 🌐 Web tools
screenshot = client.web.screenshot("https://example.com")
article = client.web.article_extract("https://example.com/blog")

# 🎨 AI generation
result = client.ai.generate_image("a cat in a spaceship", wait=True)
print(result["result"]["images"][0]["url"])

# 🎙️ Transcription
transcript = client.ai.transcribe(url="https://example.com/audio.mp3")

# 🔍 Intel tools
dns_info = client.intel.dns_lookup("example.com")
ssl_info = client.intel.ssl_check("example.com")

OpenAI Codex (ChatGPT Code Interpreter)

For Codex/Code Interpreter, use the Python SDK with inline pip:

# Preview for after registry publication:
!pip install agentmediatools -q

from agentmediatools import Client
client = Client(api_key="mt_your_key_here")

# Generate a QR code
qr = client.qrcode.generate("https://agentmediatools.com")
with open("/mnt/data/qrcode.png", "wb") as f:
    f.write(qr)

# Resize an uploaded image
with open("/mnt/data/photo.jpg", "rb") as f:
    result = client.image.resize(f, width=800, format="webp")
with open("/mnt/data/resized.webp", "wb") as f:
    f.write(result)

# Scrape a web page
content = client.scrape("https://example.com")
print(content[:500])

Available Tools for OpenAI Agents

CategoryTools
🖼️ Imageclient.image.resize, convert, compress, analyze, crop, batch_process
📄 PDFclient.pdf.merge, split, compress, rotate, to_text, to_images, from_images
🌐 Webclient.web.screenshot, html_to_pdf, article_extract
🎨 AI Genclient.ai.generate_image, generate_video, transcribe, ocr, remove_bg
🔍 Intelclient.intel.dns_lookup, ssl_check, og_preview, regex_test, text_stats
📦 Dataclient.tools.csv_convert, case_convert, slugify, zip_files, unzip
🔗 Utilityclient.qrcode.generate, client.pastebin.create, client.shortener.shorten
🛠️ Devclient.dev.uuid, password, hash, base64, ip, timestamp
🔑 Get your free API key → agentmediatools.com
Install the official Python SDK with python -m pip install agentmediatools.