Integrations / OpenAI Agents SDK
OpenAI Agents SDK: a phone-call and SMS tool example
The Agents SDK turns any async function into a tool. Three Hail calls give the agent a real number for calls and texts, and an inbox for email.
01Install
Hail's SDK needs Python 3.11+.
pip install hail-sdk # .env HAIL_API_KEY="hl_live_9fa2..." pip install openai-agents
02Define function tools
function_tool reads the signature and docstring. Your agent writes the system prompt; Hail's hosted voice pipeline conducts the call from it. The call returns an id immediately; the transcript comes back as events.
from agents import Agent, Runner, function_tool
from hail import Client
@function_tool
async def place_call(to: str, system_prompt: str) -> str:
"""Call a number. Hail's voice pipeline runs the
conversation from the system prompt."""
async with Client() as hail:
call = await hail.calls.create(
to=to, system_prompt=system_prompt,
recipient_consent=True,
)
return f"dialing {call['id']}"
@function_tool
async def send_sms(to: str, body: str) -> str:
"""Text an opted-in recipient."""
async with Client() as hail:
sms = await hail.sms.create(
to=to, body=body, recipient_consent=True,
)
return f"queued {sms['id']}"03Run the agent
The model decides when to call versus text. Transcripts and delivery events stream to your webhook.
agent = Agent(
name="Scheduler",
instructions="Confirm appointments. Call if SMS gets no reply.",
tools=[place_call, send_sms],
)
result = await Runner.run(
agent, "Confirm tomorrow's 3pm with +14155550142"
)Questions
Does the agent hear the phone call?
Hail runs the call leg with turn detection and streams the transcript back as events your agent can act on.
Do I need to pick an STT or TTS vendor?
No. The voice pipeline ships tuned. Your agent passes a system prompt; Hail handles the audio and the turn-taking.
Ship it with a real number
Sign up, grab a key, and the examples above run as written. Pay per use, no subscription.
Get started →More frameworks
LangGraph · CrewAI · Vercel AI SDK · n8n · Claude