By Sagar Shankaran, Founder of CallSphere
AGI is the script-per-call hand-off. AMI is the firehose of events and commands. Both still ship in Asterisk 22 and both still matter for AI voice if you know where each one breaks at scale.
Key takeaways
AGI is the original AI hook for Asterisk: dialplan calls a script, script reads stdin, writes stdout, and Asterisk obeys. AMI is the panopticon: every channel event, every CDR, every registration, fanned out over TCP. ARI superseded both for new builds, but in 2026 AGI and AMI are still load-bearing in shops with seven years of dialplan they cannot rewrite.
Asterisk Gateway Interface (AGI) was introduced in Asterisk 1.0 in 2004 as a process-spawn protocol. Your dialplan runs AGI(myscript.py), Asterisk forks the script, the script reads channel variables and DTMF from stdin, writes commands like SAY DIGITS, EXEC, GET DATA to stdout, and returns control. FastAGI is the same protocol over TCP so you do not pay the fork cost.
Asterisk Manager Interface (AMI) is the older event/command socket on port 5038. Clients log in with a username and shared secret, subscribe to event classes (call, agent, system), and issue Action: commands like Originate, Hangup, Redirect, ChannelStatus. AMI is the substrate behind every Asterisk GUI, FOP/FOP2, queuemetrics integration.
For AI voice in 2026, both have real limits. AGI's per-call process spawn caps at maybe a few hundred concurrent calls; FastAGI helps but the synchronous request-response model still blocks. AMI is global state, not per-call control, so you cannot use it to inject barge-in audio mid-utterance.
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
graph TD
A[Inbound SIP] --> B[Asterisk 22 Dialplan]
B -->|AGI legacy path| C[FastAGI listener / Python]
B -->|Stasis handoff| D[ARI WebSocket]
C --> E[OpenAI / Deepgram]
D --> E
F[AMI Listener] -->|events| G[Analytics + CRM]
B -.->|every event| F
The 2026 best practice is hybrid: keep AGI for legacy dialplan branches (IVR menus, time conditions, queue routing decisions) and move real-time AI conversations to ARI with externalMedia or AudioSocket. Use AMI as the read-only event tap for analytics, do-not-touch for control.
# FastAGI hello world for an AI handoff
from asterisk.fastagi import FastAGIServer
class AIHandler(FastAGIServer):
def handle(self, agi):
agi.answer()
agi.exec_command('Set', 'AI_SESSION_ID=' + agi.unique_id)
agi.exec_command('Stasis', 'ai-app,realtime')
CallSphere terminates every call on Twilio across all six verticals (Healthcare AI, Real Estate AI, Sales Calling AI, Salon AI, IT Helpdesk AI, After-Hours AI). Healthcare AI is a FastAPI service on :8084 that streams audio to OpenAI Realtime; Sales Calling AI fires 5 concurrent outbound calls per tenant; After-Hours AI rings staff with simul call+SMS and a 120-second timeout. We do not run Asterisk in production, but several of our enterprise prospects in the IT Helpdesk vertical are migrating from on-prem Asterisk PBXes. Our migration playbook keeps their AGI scripts intact for IVR and adds an ARI Stasis branch that hands the call to a Twilio SIP domain via SIP REFER, where our 37 agents and 90+ tools take over inside HIPAA + SOC 2 boundaries on $149/$499/$1499 plans.
Is AGI deprecated? No, but it is no longer the recommended path for new AI builds. ARI is. AGI remains supported in Asterisk 22 LTS through 2030.
Can AGI handle real-time AI conversations? Poorly. The synchronous model means every AI call blocks the channel thread. AudioSocket plus ARI is the modern equivalent.
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
What is AsyncAGI? AGI requests dispatched over AMI rather than spawned as processes; better than fork-AGI, worse than ARI. Decent middle ground for legacy modernization.
How do I rate-limit AMI events to my consumer? Filter in manager.conf with read=call,user instead of read=all, and set eventfilter to drop chatty events.
Is AMI safe over the public internet? With TLS and IP allowlisting, yes, but most teams run it inside the VPC. Asterisk 22 supports manager.conf TLS natively.
Start a 14-day trial to migrate your AGI dialplan to managed AI voice, see pricing for the right tier, or contact us about Asterisk-to-Twilio migration playbooks.
Written by
Sagar Shankaran· Founder, CallSphere
Sagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
A founder's guide to the female voice generator landscape: AI female voices, Japanese voices, robot voices, and how CallSphere ships 57+ voices live.
MOS 4.3+ is the band where AI voice feels human. Drop below 3.6 and conversations break. Here is how to measure, improve, and alert on MOS in production AI voice using G.711, Opus, and the underlying packet loss / jitter / latency math.
Asterisk + ARI + AudioSocket + an open LLM = a voice agent that drops into your existing PBX. No SIP-trunking provider lock-in — full Python orchestration.
Texas SB 1188 requires US-resident EHRs from January 1, 2026; Nevada's consumer-health-data law constrains health data; Colorado AI Act takes effect June 30, 2026. AI voice agents must architect for state-by-state data localization.
When your AI voice agent gets one-way audio, missed DTMF, or codec mismatch, sngrep and Wireshark are still the fastest path to root cause in 2026. Here is the playbook.
PCI DSS 4.0.1 future-dated requirements went mandatory March 31, 2025. AI voice agents that take card payments on behalf of healthcare providers — copays, deductibles, payment plans — must meet 12 requirements with DTMF masking and scope reduction.
© 2026 CallSphere LLC. All rights reserved.