Skip to content
Speech to speech (fluid-1)

Let KugelAudio run the back office

List your tools and let a model KugelAudio runs decide when to use them, so your code only runs each tool.

On this page

Set delegation.type to responses. KugelAudio then runs the model that works on a delegation, and your client runs its tools. Everything the model writes is spoken, and it can ask the caller something and carry on with the answer. When it cannot finish without that answer, such as a detail it needs or a yes before it acts, its question is said word for word and the caller's reply goes back to the model. An offer the caller is free to pass over is said like any result, and what the caller says next is the agent's to handle. There is one exception. When the caller has already spoken on while a question for them was being written, the question is not said. The model answers once more with what the caller said. The same holds for a tool call the model wrote before the caller went on: it is not sent, and the model decides again with the caller's newer words. A note your client adds with session.thinking.append or session.instructions.append while a delegation runs reaches the model too, which answers once more with it. When speech recognition is unsure how a word of the caller's turn is spelled, the model gets the likely other spellings with that turn (the ones kugel.input_transcript.alternatives carries) and tries them before asking the caller again; a tool call it wrote with one of those words before they arrived is not sent, and it decides again with them.

Confirmations follow the caller. When the caller gives the details and says yes or go ahead, the model acts without reading them back again. When the caller has said go ahead and then gives the one detail the model asked for, the model acts; only for something that cannot easily be undone does it first say the complete details once and wait for a yes. When the caller says go ahead without answering the model's question, the model takes the answer the call makes most likely, acts, and says which one it used. If nothing in the call points to an answer, such as a time nobody mentioned, it asks once more instead of acting. When the caller later asks about something they wanted changed and the change was not made, the model says first that it was not made, then what stands now, so the old value does not sound like the result.

Asked about the assistant itself, such as who made it or what it runs on, the model answers as the agent does: from your instructions, or else that it runs on Fluid by KugelAudio. It never names another model or company.

Run a call with a tool

Save this next to talk.py from the quickstart:

back_office.py
import asyncio
import json
import os

from openai import AsyncOpenAI

from talk import RATE, Speaker, Transcript, stream_microphone


def find_order(number: str) -> dict[str, str]:
    """Your system: replace this with a real lookup."""
    return {"number": number, "status": "shipped", "arrives": "tomorrow"}


def run_tool(name: str, arguments: str) -> str:
    """The service asks for a tool, and your code runs it and returns text."""
    if name == "find_order":
        return json.dumps(find_order(**json.loads(arguments)))
    return json.dumps({"error": f"unknown tool {name}"})


async def main() -> None:
    tasks: set[asyncio.Task[None]] = set()
    speaker = Speaker()
    transcript = Transcript()

    async with (
        AsyncOpenAI(
            api_key=os.environ["KUGELAUDIO_API_KEY"],
            base_url="https://api.elbic.com/v1",
        ) as client,
        client.live.connect() as connection,
    ):
        await connection.session.start(
            session={
                "model": "fluid-1",
                "instructions": "You answer the phone for a parcel service. Keep replies short.",
                "audio": {"format": {"type": "audio/pcm", "rate": RATE}},
                "delegation": {
                    "type": "responses",
                    "responses": {
                        "model": "mistral-medium-3.5-128b",
                        "instructions": "You are the back office of a parcel service.",
                        "tools": [
                            {
                                "type": "function",
                                "name": "find_order",
                                "description": "Find an order by its number.",
                                "parameters": {
                                    "type": "object",
                                    "properties": {"number": {"type": "string"}},
                                    "required": ["number"],
                                },
                            }
                        ],
                    },
                },
            }
        )
        with speaker.stream:
            async for event in connection:
                if event.type == "session.started":
                    tasks.add(asyncio.create_task(stream_microphone(connection)))
                    print("Talk now. Press Ctrl+C to hang up.", end="")
                elif event.type == "session.output_audio.delta":
                    speaker.play(event.delta)
                elif event.type == "session.input_transcript.delta":
                    transcript.add("You", event.delta)
                elif event.type == "session.output_transcript.delta":
                    transcript.add("Agent", event.delta)
                elif event.type == "response.event" and event.event["type"] == "response.output_item.done":
                    item = event.event["item"]
                    await connection.send(
                        {
                            "type": "response.item.create",
                            "item": {
                                "type": "function_call_output",
                                "call_id": item["call_id"],
                                "output": run_tool(item["name"], item["arguments"]),
                            },
                        }
                    )
                    await connection.send({"type": "response.create"})
                elif event.type == "error":
                    print("Error:", event.error.code, event.error.message)
                elif event.type == "session.closed":
                    break


if __name__ == "__main__":
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        print("\nHung up.")

Run it with python back_office.py and ask about order 4711. The agent's words print as it speaks, and the tool's result is in what it says.

Return tool results

Return every tool call of a response, then send one response.create. KugelAudio waits 60 seconds for it. After that the response fails with tool_output_timeout, the caller hears that it failed, and the call goes on. If another tool of that delegation had already returned its output, the caller hears instead that the outcome could not be confirmed, and is asked to check. When a delegation fails after every tool call returned, for example because the model wrote no answer, the caller hears what the tools returned.

A delegation makes at most 16 model calls. When the caller speaks while a question for them is being written, the delegation answers once more with what they said. A model call that fails after a tool returned its output is made once more. Both count toward the 16. The conversation carries across the delegations of a call.

Choose the model

Omit responses.model for the default. Without paid credit, you get kugel-llm-1. With paid credit: a wallet balance, a paid plan, or a contract with KugelAudio, you get mistral-medium-3.5-128b and can choose other supported models. Where a region serves kugel-llm-1, every account can name it. With paid credit it is charged at its published price.

responses.modelRuns onWhere the conversation and your tool results go
kugel-llm-1Kugel back-office modelParis, France; EU and EFTA data centres once your organisation agrees in the app; from any host
mistral-medium-3.5-128bMistral Medium 3.5Scaleway's API in Paris, from any host
gpt-6.1-sol, gpt-6-astra or gpt-6.1-terraThat OpenAI modelOpenAI's API, from any host

The back office reaches OpenAI only when you name an OpenAI model.

Models free credit covers

Welcome and promotional credit covers kugel-llm-1. Without paid credit, a session that names another model is refused before the call starts: session.start gets an error event with the code paid_balance_required, and a WebRTC create gets HTTP 402 with the same code. The message names the models your free credit covers and links the top-up page, for example:

gpt-6.1-sol needs paid credit. Your free credit covers kugel-llm-1. Top up at https://kugelaudio.com/dashboard/billing?add_credits=1 to use gpt-6.1-sol.

In the dashboard playground, the back-office model list marks each model Covered by your free credit or Needs paid credit, and offers only the covered ones until you add credit.

Pricing

Without paid credit, the Kugel back-office model (kugel-llm-1) is the default. Welcome and promotional credits can pay for it. With paid credit, you can keep using it where the region serves it, or choose other supported models at their published prices. Pass-through prices apply only where KugelAudio adds no margin.

The Kugel back-office model costs EUR 2.16 per million input tokens, including cached input, and EUR 6.60 per million output tokens.

APIOther modelInputCached inputOutputPricing
Speech to Speechmistral-medium-3.5-128bEUR 1.50EUR 1.50EUR 7.50Pass-through
Speech to Speechgpt-6.1-solEUR 1.9257EUR 0.0963EUR 9.6285Published price
Speech to Speechgpt-6-astraEUR 9.6285EUR 0.9629EUR 48.1427Published price
Speech to Speechgpt-6.1-terraEUR 0.9629EUR 0.0481EUR 4.8143Published price
Hosted agentsqwen3.8-27bEUR 0.80EUR 0.16EUR 4.40Published price
Hosted agentsmistral-medium-3.5-128bEUR 1.5825EUR 1.5825EUR 7.9125Published price

The table shows standard rates per million tokens, rounded for display.

GET/v1/back-office/pricing

The public response includes the default model and wallet policy in back_office. The other_speech_to_speech_models and other_hosted_agent_models arrays list alternate models by API surface, with pricing set to pass_through or published_price. All amounts in prices_eur_per_million_tokens are standard published rates. An organization with a negotiated rate may pay a different price.

Supported settings

responses takes model, instructions, tools, tool_choice (auto, none or required), parallel_tool_calls and reasoning.effort. Only function tools work: hosted tools and MCP from OpenAI's delegation guide are refused with invalid_event.

The agent hands a turn to the back office when answering it needs one of your tools, and it judges that from each tool's name and description. A description that names what callers ask for works best: "Get current weather for a city. Use whenever the caller asks about weather."

Next steps

Handle interruptions, pick a voice, mute and restart

See session, rate and size limits