llm field accepts any OpenAI-compatible chat completions endpoint. Pointing it at SambaCloud lets an AssemblyAI voice agent answer with SambaNova models. Because voice depends on how fast the first sound arrives, this guide also measures that for each model.
Prerequisites
- A SambaCloud account and API key.
- An AssemblyAI account and API key. Copy the key from the API keys page of the dashboard.
- Python 3.10 or higher.
Installation and setup
1
Create a virtual environment
2
Install the dependencies
requests 2.34.2 and websockets 17.4 on Python 3.12.3
Set your API keys
Connect a voice agent to SambaCloud
You create the agent with an HTTP request and connect to it over a WebSocket. The part that changes for SambaNova is thellm field:
base_urlis the SambaCloud base URL. AssemblyAI calls{base_url}/chat/completions, so keep the/v1.modelis a SambaCloud model ID.api_keyis your SambaCloud key. AssemblyAI encrypts it and never returns it in a response.- The list takes one entry. The model must support streamed chat completions, which SambaCloud models do.
This guide works with SambaCloud only. AssemblyAI requires the
base_url to use https and a public host, so it cannot reach a private SambaStack instance.llm entry, connects to it, and types a question to the agent with a conversation.message event instead of speaking it, so you can test without a microphone. It prints the reply and the time from the request to the first sound, and saves the spoken reply as reply.wav. The agent is deleted at the end, because it holds your SambaCloud key.
voice_agent.py
Output
Time to first audio is measured on the client, from the moment the script asks for a reply to the first audio chunk. It includes the model’s first token and AssemblyAI’s text-to-speech. Because this test sends text, it does not include speech-to-text time. Your numbers depend on the model, the prompt, and your network.
Choose a model for voice
The script usesMiniMax-M3.1-Flash. Voice is where first-sound latency matters most, so it is worth comparing models. Each row is the time to first audio over 5 runs of the script above, changing only MODEL, measured on 6 November 2026:
Meta-Llama-3.3-70B-Instruct is not in the table because SambaCloud deprecated it on 17 November 2026. A request for it returns HTTP 503, and the script ends with reply.error: llm_provider_error. See Deprecations for the replacement, and confirm that GET https://api.sambanova.ai/v1/models lists any model before you choose it.First-audio times vary between runs and between days. Every model except
MiniMax-M3.1-Flash had at least one run about 2 seconds or more slower than its usual time, and gemma-4-31B-it was slower and less steady than the others. Measure over several runs before you quote a latency number.Troubleshooting
KeyError: 'ASSEMBLYAI_API_KEY' or 'SAMBANOVA_API_KEY'
KeyError: 'ASSEMBLYAI_API_KEY' or 'SAMBANOVA_API_KEY'
An environment variable is not set in the shell you run Python from. Set it as shown in Installation and setup, then run the script again from the same shell.
422 Client Error: Unprocessable Content for url: https://agents.assemblyai.com/v1/agents
422 Client Error: Unprocessable Content for url: https://agents.assemblyai.com/v1/agents
AssemblyAI validated the agent and refused it. Print
agent.text to read the reason. For example, llm[0].base_url ... must use https:// means the base_url starts with http://. Use https://api.sambanova.ai/v1.The script finishes with a 0-byte reply.wav and no reply text
The script finishes with a 0-byte reply.wav and no reply text
A failed model request does not stop the session. AssemblyAI sends a
reply.error event and then a normal reply.done, so the script ends quietly. Read the reply.error line the script prints for the cause. The reply.error event is not listed in AssemblyAI’s events reference, but the API sends it.A test agent is left in your account
A test agent is left in your account
The script deletes its agent when it finishes, even after an error in the session. If the process is killed before then, delete the agent with
DELETE https://agents.assemblyai.com/v1/agents/<agent-id>, because it stores your SambaCloud key.
