Skip to content
Speech to speech (fluid-1)

Limits and usage

See how long a session can run, how much you can send, what counts as usage, what to do when a session is refused and how calls are recorded during the beta.

On this page

Limits

LimitValue
Session length1 hour
instructions16,384 tokens, counted with the o200k_base encoding
input (earlier conversation)128 messages and 8,192 tokens
content of a commentary, thinking or instructions event500 tokens
session.kugel.tools64 tools
event_id512 characters
Model calls in one hosted delegation16
Wait for tool results in a hosted delegation60 seconds

Rate limits

Speech to speech has the same per-organization rate limits and plan tiers as text to speech, counted separately: a session takes nothing from your speech generation limits, and a speech generation takes nothing from your sessions. A session holds one concurrent slot and one open connection until it ends, and takes one request from the per-minute limit when it starts.

Retry a refused session

A refused session gets an error event with the code rate_limit_exceeded, then close code 1013. The close reason says which of two things happened:

Close reasonWhat happenedWhat to do
fluid at capacityFluid holds as many sessions as it can right now.Open a new session after a short pause, with backoff.
organization limit reachedYour organization reached a limit of its plan: it already has as many sessions open as the plan allows, or started as many this minute.End a session, wait a minute, or contact us to raise the limit. A retry right away is refused again.

The error event's message says the same to a person:

Close reasonMessage
fluid at capacityFluid is at capacity right now; open a new session in a few seconds.
organization limit reachedYour organization already has as many sessions open as its plan allows; end a session, or contact us to raise the limit.
organization limit reachedYour organization has started as many sessions this minute as its plan allows; wait a minute, or contact us to raise the limit.

Branch on the close reason, not on the message. Depending on when the refusal arrives, the SDK raises it from session.start or from the event loop, so catch both. This sample retries only when Fluid is at capacity:

retry.py
import asyncio
import os
import random

from openai import AsyncOpenAI, WebSocketConnectionClosedError
from websockets.exceptions import ConnectionClosedError

CLOSED = (ConnectionClosedError, WebSocketConnectionClosedError)
ORGANIZATION_LIMIT = "organization limit reached"


def asked_to_retry(error: Exception) -> bool:
    closed = error if isinstance(error, ConnectionClosedError) else error.__cause__
    if not isinstance(closed, ConnectionClosedError) or closed.rcvd is None:
        return False
    # Your organization's limit holds until one of its sessions ends: a retry now fails again.
    return closed.rcvd.code == 1013 and closed.rcvd.reason != ORGANIZATION_LIMIT


async def run_session(client: AsyncOpenAI) -> None:
    async with client.live.connect() as connection:
        await connection.session.start(session={"model": "fluid-1"})
        async for event in connection:
            if event.type == "session.started":
                print("Session started")
                await connection.session.close()
            elif event.type == "session.closed":
                return


async def main() -> None:
    async with AsyncOpenAI(
        api_key=os.environ["KUGELAUDIO_API_KEY"],
        base_url="https://api.elbic.com/v1",
    ) as client:
        for attempt in range(6):
            try:
                return await run_session(client)
            except CLOSED as error:
                if not asked_to_retry(error):
                    raise
                delay = min(2**attempt, 30) + random.random()
                print(f"Refused, retrying in {delay:.1f} s")
                await asyncio.sleep(delay)
        raise SystemExit("Still refused after 6 attempts")


if __name__ == "__main__":
    asyncio.run(main())

The same close code also means the server is restarting, with another close reason and no error event first, and a retry is right for that too.

Usage

Usage starts with the first audio in either direction and runs until the session ends, in exact seconds. A socket waiting for session.start costs nothing. Time counts whether anyone is speaking or not. session.usage.updated and session.closed report the seconds so far. A delegated model you run yourself is yours to pay for. In hosted delegation the service runs the model, and the tokens its calls use (input, cached input and output) are charged in addition to the seconds, at that model's token price. Welcome and promotional credit can pay for the seconds and tokens from kugel-llm-1. The other hosted back-office models need paid credit. A session that names one without paid credit is refused at session.start with paid_balance_required. If paid credit runs out during a call, the next job fails with paid_balance_required and the call goes on. The events report seconds only. For rates, see pricing.

When the credits run out during a call, you get an error event with the code billing_limit_reached, and the socket closes with 1008.

Recordings during the beta

During the beta, KugelAudio records calls made with an API key or from the dashboard so it can debug the model. A recording holds both sides of the audio, your session configuration including its instructions, and the session's events and transcripts. Recordings are not used for training. They are deleted after 14 days, and backups keep them for up to about 60 more days.

Next steps

Look up every error and close code

See what carries over and what differs