mira-llm is the language model our voice agents run on, offered on its own.
It answers on POST /v2/chat/completions, with the same request and response
as OpenAI’s chat completions, so the stock openai package and any framework
with an OpenAI LLM integration can call it. You change the base URL, the key
and the model name, and the rest of your code stays as it is.
It was built for voice agents in India. It does best with the Hinglish real
customers speak, Hindi and English in one sentence, in either script, and it
calls tools the OpenAI way, with a tool_calls array.
If you build agents on this platform, you don’t need this page: your agents
already run on this model.
On the production address, a key from a workspace that has not gone live gets
403 production_workspace_required.
https://llm.scalefrequency.com/v2 serves the language model alone, from our
edge in Delhi. It takes production keys, under the same rules as
prod.voice.miraiminds.co.
POST /v1/chat/completions, OpenAI’s own path, still works and behaves
exactly the same. Code already pointed at a /v1 base URL does not need to
change. Use /v2 for new code, like the rest of the API.1. Get a key
Open Developers in the sandbox console and press Create key. The key is ask_live_ secret and the console shows
it only once. It is the same key you use for text to speech, speech to text
and the rest of the v2 API. See
Get a key for the first-time email check.
Call the API from your server. Never put the key in a web page or a mobile
app. There is no browser token for this route.
2. One request
200 OK
"stream": true, the whole reply arrives as one JSON document once
the model has finished. That suits work nobody is waiting on, such as
classification, extraction or a summary after a call. When a person is waiting,
stream the reply.
model must be mira-llm, and model in the response is always mira-llm.
Any other value, including one an OpenAI client carries over such as
gpt-4o-mini, returns 400 invalid_request with a message that names the
model to use.
3. Stream it
Add"stream": true. The reply comes back as server-sent events
(Content-Type: text/event-stream), one chat.completion.chunk per data:
line:
200 OK · text/event-stream
- The first chunk usually carries only
role, with empty content. Start your timer, or your speech, on the first chunk that has text. - Join the
delta.contentpieces in order. The last chunk carries an emptydeltaand thefinish_reason. - The stream ends with the line
data: [DONE], which is not JSON. Check for it before you parse a line. - If the model stops part-way, the stream ends without a
finish_reasonand withoutdata: [DONE]. Treat that reply as incomplete.
4. Call tools
Send atools array of function schemas. When the model decides a function
applies, it answers with tool_calls instead of text and stops with
finish_reason: "tool_calls":
200 OK
function.arguments is a JSON-encoded string, as on OpenAI. Parse it
(json.loads, JSON.parse) before you read a field, and handle a parse
failure: a model can produce malformed JSON.
To finish the turn, run the function yourself, then send the conversation
again with two more messages: the assistant message exactly as it came back,
tool_calls and all, and a tool message with the matching tool_call_id and
your result as a string. The model reads the result and answers in text:
The two messages you add
tool_choice takes auto, none, required, or one function as
{"type": "function", "function": {"name": "book_slot"}}. Leave it at auto
on a live call: forcing a call on a turn that was only “हाँ ठीक है” makes the
model invent arguments. Use required only when the turn cannot end any other
way.
Tool calls also stream. With "stream": true they arrive as
delta.tool_calls fragments, each with an index: the name in one chunk,
pieces of the arguments string in the next. Join the fragments that share an
index before you parse the arguments. The Python example below does this.
5. Python
The stockopenai package, with the base URL and key changed. This example
streams the reply, joins tool-call fragments on their index, runs the
function and sends the result back:
6. Pipecat
Pipecat’sOpenAILLMService works with a base URL change, the same swap the
TTS quickstart describes for speech:
llm where your LLM service was, between the user context aggregator and
your TTS service. End your system prompt with the
phone rules. Three more things to know on a
real call:
- Pipecat sometimes adds
developermessages, for example when the tool set changes mid-call or a function runs withcancel_on_interruption=False. This API reads adevelopermessage as asystemmessage. The subclass above has Pipecat send those messages asusermessages instead. - A long call can pass the request limits. Pipecat keeps the whole conversation in its context, and each turn adds at least two messages. A request takes up to 100 messages and 16,000 characters of message text. Most calls never get close. For longer ones, use Pipecat’s context summarization with thresholds below those limits. Keep the system message, and change the start of the conversation as rarely as you can, because cached input only applies to a start that repeats.
- Pipecat’s sampling settings reach the model.
temperature,top_p,seed, the penalties,max_tokensandstream_options.include_usageall work. See What the API reads.
model= to the
constructor still works but is deprecated in favour of
settings=...Settings(model=...).
7. Vercel AI SDK
The AI SDK’s OpenAI-compatible provider works with the base URL and key changed:ai 7.0.155 and
@ai-sdk/openai-compatible 3.0.80. generateText, streamText, a tool run
over several steps and Output.object all work.
8. Prompt it for a phone call
On this platform, the engine adds call rules to every agent’s prompt and catches voicemail before the model hears it. When you run your own voice agent on this API, adding those rules is your job. Without them, the model sometimes writes down what it is doing instead of what it would say, and your text-to-speech reads that out as well:Two replies from real calls, spoken word for word
Phone rules
- Give the agent a tool that ends the call, named and described for what it
does, such as
end_callwith “End the call.” With one, a voicemail ends in silence. Without one, the agent says a short goodbye to the recording. In our runs, a tool namedhangupwas sometimes written out as text on a Hindi voicemail greeting instead of being called, whichend_call,endCallandend_conversationnever were. - Turn on voicemail detection in your pipeline if it has it. The rules handle whatever gets past it.
- Back every fact a caller may ask for with a tool or a line in the prompt: the price, the order status, the delivery date. A question with neither behind it is where the model starts describing what it would do.
- Leave the temperature where it suits you. Lowering it does not stop the notes: at 0.0, 11 of 16 voicemail replies still had one. The default is 0.3.
end_call, hangup, end_conversation or endCall, with no hang-up
tool and with no tools at all, and an EMI reminder agent in Hindi.
What the API reads
We read the fields below and ignore everything else, so a body written for another provider still runs, with fewer of its settings in effect:n, logprobs, logit_bias, parallel_tool_calls, reasoning,
reasoning_effort, thinking, chat_template_kwargs and user are ignored.
So is the name field on a message. The model answers without thinking first,
and no field turns thinking on: an answer has no reasoning content and no
reasoning tokens, only the reply and its tool calls. A value of the wrong type for a field we
read (a seed that is not an integer, five stop strings) is
400 invalid_request.
Limits
Each refusal says which limit you hit. The model’s context is 32,768 tokens,
the request and the reply together. We can raise the text limit for your
account: ask us.
Price
Cached input is the part of a prompt that repeats the start of a recent
request, so the model reads it from cache instead of processing it again. To
get the cached rate on more of your tokens, keep the parts of the prompt that
stay the same (system prompt, tool definitions, reference text) at the start,
in the same order, and put what changes at the end. Prices are billed in INR
and exclude GST; USD amounts are for reference.
Usage is charged to your workspace wallet. We add up each workspace’s tokens
over ten-minute windows and charge each window once, a few minutes after it
closes; it shows on your statement under Language model. A request that
fails on our side is not charged. If you close a stream early, you pay for the
tokens generated up to that point.
When your wallet is empty, counting usage that has not been charged yet,
requests return
402 insufficient_balance until you add funds. The request
rate limit applies as well.
Your request log
Every request your keys make is logged, whether it completed or failed. Open the console’s Language Model page and choose Logs. Each row shows the time and request id, a preview of the last user message, the time to the first token, the total time, the tokens in (and how many were cached) and out when the model reported them, tool calls, and the status. Requests from the console’s playground are in the same table, tagged. Pick 24 hours, 7 days or 30 days. The log holds your workspace’s latest 1,000 requests. It stores metadata and the first 140 characters of the last user message, never the whole conversation. Requests refused for a missing, unknown or revoked key, or for the rate limit, are not logged. The log is in the console only. There is no API for it yet.Try it in the console
The Playground tab on the same page is a chat with the model. You can set a system prompt and switch three demo tools on or off (book_slot,
check_order_status and send_payment_link). When the model calls one, the
playground shows the arguments it extracted and the raw messages going each
way. The tool results are simulated: nothing is booked, looked up or sent.
Code for this message gives you the cURL command for what you just sent.
The playground takes the same 16,000 characters as the API, with smaller
limits on the rest: 20 messages and 6 tools per request, and replies of up to
400 tokens.
Postman
The language model collection has three requests: a chat completion, one with tools (with the follow-up turn after the function has run) and a streaming one, each with a worked example response. Import it with the sandbox environment, or the production environment once you have gone live, and setapi_key. See
Postman collection for how to import.
When something fails
Errors use the same envelope as the rest of the API:
A stream that has already started cannot change its status code. If the model
fails after the first chunk, the stream just ends, without
data: [DONE].
TTS quickstart
Speak the model’s reply with Mira TTS.
Pipecat
Mirai’s own Pipecat services for speech.