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.
agentmediatools package is not published to PyPI yet. The examples below document the reviewed source API for the upcoming release; use direct REST calls from the API reference in production today.# Preview for after the Agent Media Tools SDK is published: pip install openai-agents agentmediatools
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)
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")
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])
| Category | Tools |
|---|---|
| ๐ผ๏ธ Image | client.image.resize, convert, compress, analyze, crop, batch_process |
| ๐ PDF | client.pdf.merge, split, compress, rotate, to_text, to_images, from_images |
| ๐ Web | client.web.screenshot, html_to_pdf, article_extract |
| ๐จ AI Gen | client.ai.generate_image, generate_video, transcribe, ocr, remove_bg |
| ๐ Intel | client.intel.dns_lookup, ssl_check, og_preview, regex_test, text_stats |
| ๐ฆ Data | client.tools.csv_convert, case_convert, slugify, zip_files, unzip |
| ๐ Utility | client.qrcode.generate, client.pastebin.create, client.shortener.shorten |
| ๐ ๏ธ Dev | client.dev.uuid, password, hash, base64, ip, timestamp |