Integration
OpenAI Agents SDK Integration
Function tool wrappers and OpenAI function calling definitions for the OpenAI Agents SDK. Two usage paths: the high-level Agents SDK or raw function calling with any OpenAI model.
Path 1: OpenAI Agents SDK
The fastest way to give an OpenAI agent email capabilities. Import the pre-built tools and pass them to your agent. Each tool has typed parameters, descriptions, and error handling baked in.
from agents import Agent from deadsimple.integrations.openai_agents import get_tools agent = Agent( name="Email Agent", tools=get_tools(api_key="dse_your_api_key"), )
That's three lines. The get_tools() function returns a list of pre-configured function tools that the Agents SDK understands natively. Your agent can now create inboxes, send emails, read messages, and more through natural language.
Path 2: Raw Function Calling
If you're using the OpenAI API directly (without the Agents SDK), you can still get pre-built function definitions and a dispatcher. This works with any model that supports function calling: GPT-4o, GPT-4o-mini, o3, and others.
import json from openai import OpenAI from deadsimple.integrations.openai_agents import ( get_function_definitions, handle_tool_call, ) client = OpenAI() tools = get_function_definitions() response = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "List my inboxes"}], tools=tools, ) for tool_call in response.choices[0].message.tool_calls: result = handle_tool_call( tool_call.function.name, json.loads(tool_call.function.arguments), ) print(result)
get_function_definitions() returns OpenAI-compatible tool schemas. handle_tool_call() dispatches the function name and arguments to the Dead Simple API and returns structured results. You handle the conversation loop; we handle the email operations.
Available Tools
Both paths expose the same set of tools. Each tool maps to a Dead Simple Email API endpoint.
| Tool | Description | Key Parameters |
|---|---|---|
send_email |
Send an email from an inbox | inbox_id, to, subject, body |
read_emails |
List recent messages in an inbox | inbox_id, limit |
read_email |
Get a single message by ID | inbox_id, message_id |
reply_to_email |
Reply to an existing message thread | inbox_id, message_id, body |
create_inbox |
Create a new email inbox | name |
list_inboxes |
List all inboxes on the account | None |
Full Example: Email Agent with Conversation Loop
Here is a complete example that creates an agent, runs a conversation, and lets the model decide when to call email tools.
import asyncio from agents import Agent, Runner from deadsimple.integrations.openai_agents import get_tools agent = Agent( name="Email Agent", instructions="You manage email for the user. Create inboxes, send messages, and read incoming mail when asked.", tools=get_tools(api_key="dse_your_api_key"), ) async def main(): result = await Runner.run( agent, messages=[{"role": "user", "content": "Create an inbox called support and send a test email to test@example.com"}], ) print(result.final_output) asyncio.run(main())
The agent handles multi-step tasks automatically. In this example, it will first call create_inbox, then use the returned inbox ID to call send_email, and summarize what happened.