Skip to main content
A support line that answers by voice needs three models and one rule: never say anything about an order you have not looked up. This pipeline transcribes the caller, streams a tool-calling model that must call your order system first, and hands each finished sentence to text-to-speech while the model is still writing the next one. On the proof run the first spoken sentence was ready 4.1 seconds after the caller stopped, for 0.8 cents a call at the 2026-10-31 prices; transcription and speech cost less now.

Build it in your project

Paste this line into your agent (Claude Code, Codex, Cursor, OpenCode, Cline). It sets up your key, then builds the pipeline in your project:

The code

One file per language. Both read RUNCRATE_API_KEY from the environment; nothing secret is in the code.

What the proof run cost

The Python file on a 5.7-second spoken question (“Hi there. I’m calling about my delivery. Where is my order A one zero four two?”), recorded with a synthetic voice. Times are from the start of the script. Measured on 2026-10-31 against api.runcrate.ai; costs are what the account was billed, read from each response’s X-LLM-Cost header or usage.cost. Transcription and speech were billed at their 2026-10-31 prices; both cost less now, at the rates on the live model pricing page. A second Python run had its first audio at 3.1 s for $0.0082. Two runs of the TypeScript file had their first audio at 5.9 s and 2.7 s, for $0.0080 and $0.0108. Every run looked the order up before answering.

Scale it

  • This is turn-based, a few seconds a turn. For sub-second replies, run an open speech model and LLM on one GPU instance next to your telephony and keep the same tool loop.
  • The model is the latency dial: on 2026-10-31, with the lookup_order tool, the median first-token time over three tries was gpt-oss-20b 0.72 s, gpt-oss-120b 1.39 s (free tier) and DeepSeek V4.1 Flash 1.59 s (free tier), and all three called the tool every time. Llama 4 Scout answered first in 0.62 s but wrote the tool call out as text in all nine of its tries, so it never looked the order up. Set VOICE_LLM to switch.
  • Calls in parallel: each call is independent; the account’s rate limit is the ceiling, not the code.

Gotchas found in the proof run

  • Asked “what are your opening hours?” with no tool to look them up, three of the four models tried (gpt-oss-20b, Llama 4 Scout, Mistral Small 3.2) invented hours; DeepSeek V4.1 Flash offered a transfer instead. The system prompt makes the lookup mandatory, and the agent says nothing about an order before the tool answers.
  • Kokoro’s response is chunked but not generated incrementally: for a one-line sentence the first 4 KB arrived after 0.85 to 0.89 s as PCM and 0.47 to 1.12 s as MP3, with the whole sentence done in 0.72 to 1.34 s. Split into sentences and send them in parallel; one long request is slower.
  • Whisper heard “A1042” for “A one zero four two”, and in a run before the id fix the lookup missed, so the agent told the caller it could not find the order. Normalize ids in the tool (upper case, no spaces, the dash put back) rather than trusting the transcript or the model.