The AgentMail Toolkit integrates popular agent frameworks including OpenAI Agents SDK, LangChain, and LiveKit Agents with the AgentMail API.
Get your API key from AgentMail
pip install agentmail-toolkitexport AGENTMAIL_API_KEY=your-api-keyfrom agentmail_toolkit.openai import AgentMailToolkit
from agents import Agent
agent = Agent(
name="Email Agent",
instructions="You are an agent created by AgentMail that can send, receive, and manage emails.",
tools=AgentMailToolkit().get_tools(),
)A failed tool call (an AgentMail API error, or any other exception) is surfaced
as a real failure, not a disguised success — each adapter raises the way its
framework expects: RuntimeError (OpenAI Agents SDK), ToolException
(LangChain, which becomes an error ToolMessage), or ToolError (LiveKit
Agents).
get_attachment's text extraction (PDF/DOCX) only follows https://
download URLs, applies a 15-second fetch timeout, and caps the downloaded
body at 25MB — attachments outside these bounds, or that fail to parse, are
returned without extracted text instead of raising.