Guide
Run your LiveKit agent on Fullplex
Keep your LiveKit Agents code. Point the GPT-Live model at Resia, and your agent listens while it speaks.
- base_urlIn place of https://api.openai.com/v1wss://api.resia.ai/v1/live/sessions
- api_keyIn place of OPENAI_API_KEYRESIA_API_KEY
- modelIn place of gpt-live-1resia-fullplex-1
Three arguments change. Your Agent classes, tools and room code stay the same.
Before you start
LiveKit Agents 1.8 or later
The Python framework with its GPT-Live plugin, and a LiveKit project to run the agent in.
A Resia API key
With editor or owner scope. Keep it on your server, in the agent's environment.
A backend model
A model that is available to your organization. It runs your function tools.
Five steps to a Fullplex agent.
From an empty folder to an agent you can talk to.
Install LiveKit Agents
Fullplex uses the GPT-Live session protocol, so LiveKit's GPT-Live plugin connects to it. No Resia package is needed.
pip install "livekit-agents[openai]~=1.8" python-dotenvAdd your keys
Put them in a
.envfile beside the agent. Leave out the voice to use the Fullplex default.# Your LiveKit project LIVEKIT_URL=wss://your-project.livekit.cloud LIVEKIT_API_KEY=your-livekit-key LIVEKIT_API_SECRET=your-livekit-secret # Resia RESIA_API_KEY=your-resia-api-key FULLPLEX_BACKEND_MODEL=a-backend-model-of-your-organization # Optional: <provider>:<voice id> from GET /v1/live/available-voices # FULLPLEX_VOICE=Point the model at Fullplex
Change three values from a GPT-Live agent: the address, the key and the model. The backend model runs the tools of your Agent.
def fullplex() -> openai.realtime.GPTLiveModel: """LiveKit's GPT-Live model, pointed at Resia Fullplex.""" return openai.realtime.GPTLiveModel( model="resia-fullplex-1", base_url="wss://api.resia.ai/v1/live/sessions", api_key=os.environ["RESIA_API_KEY"], # Unset: the Fullplex default voice. voice=os.environ.get("FULLPLEX_VOICE"), # The backend model that runs your function tools. responses_options={"model": os.environ["FULLPLEX_BACKEND_MODEL"]}, )Stop playback when Fullplex stops a reply
When Fullplex gives way to the caller, it sends
session.output_audio.cleared. Some audio of the reply can still wait to play. This handler drops it, so the agent goes quiet at once.class FullplexAgent(Agent): """Stops playback when Fullplex stops a reply.""" async def on_enter(self) -> None: live = self.realtime_llm_session.duplex_session live.on("openai_server_event_received", self._on_fullplex_event) def _on_fullplex_event(self, event: dict) -> None: if event.get("type") == "session.output_audio.cleared": self.session.interrupt(force=True)Run it
Your agent classes extend
FullplexAgent. Start the agent in console mode first, then in dev mode with your LiveKit project.# Talk to the agent in your terminal python agent.py console # Or connect it to your LiveKit project, then join a room python agent.py dev
The whole agent.
One file, a dental receptionist with one tool. Copy it, add your keys, and run python agent.py console.
import os
from dotenv import load_dotenv
from livekit.agents import (
Agent,
AgentServer,
AgentSession,
JobContext,
RunContext,
cli,
function_tool,
)
from livekit.plugins import openai
load_dotenv()
def fullplex() -> openai.realtime.GPTLiveModel:
"""LiveKit's GPT-Live model, pointed at Resia Fullplex."""
return openai.realtime.GPTLiveModel(
model="resia-fullplex-1",
base_url="wss://api.resia.ai/v1/live/sessions",
api_key=os.environ["RESIA_API_KEY"],
# Unset: the Fullplex default voice.
voice=os.environ.get("FULLPLEX_VOICE"),
# The backend model that runs your function tools.
responses_options={"model": os.environ["FULLPLEX_BACKEND_MODEL"]},
)
class FullplexAgent(Agent):
"""Stops playback when Fullplex stops a reply."""
async def on_enter(self) -> None:
live = self.realtime_llm_session.duplex_session
live.on("openai_server_event_received", self._on_fullplex_event)
def _on_fullplex_event(self, event: dict) -> None:
if event.get("type") == "session.output_audio.cleared":
self.session.interrupt(force=True)
class Receptionist(FullplexAgent):
def __init__(self) -> None:
super().__init__(
instructions=(
"You answer the phone for Brightside Dental. "
"Help the caller book a cleaning."
),
)
@function_tool
async def check_openings(self, context: RunContext, day: str) -> str:
"""Find open cleaning times on a day."""
return f"On {day}, 10:30 and 14:00 are open."
server = AgentServer()
@server.rtc_session()
async def entrypoint(ctx: JobContext) -> None:
session = AgentSession(llm=fullplex())
await session.start(agent=Receptionist(), room=ctx.room)
if __name__ == "__main__":
cli.run_app(server)
# Your LiveKit project
LIVEKIT_URL=wss://your-project.livekit.cloud
LIVEKIT_API_KEY=your-livekit-key
LIVEKIT_API_SECRET=your-livekit-secret
# Resia
RESIA_API_KEY=your-resia-api-key
FULLPLEX_BACKEND_MODEL=a-backend-model-of-your-organization
# Optional: <provider>:<voice id> from GET /v1/live/available-voices
# FULLPLEX_VOICE=# Talk to the agent in your terminal
python agent.py console
# Or connect it to your LiveKit project, then join a room
python agent.py devYour tools work as before.
Each @function_tool on your Agent goes to the backend model. When the backend calls a tool, the function runs in your agent. Fullplex tells the caller that it is checking, and answers when the result comes back.
- Backend tools
- The default. Set the backend model with
responses_options. You can also give itinstructions,tool_choiceandmax_output_tokens. - Your own code
- Set
delegation="client"to get each task as adelegation_createdevent. Send the result back withappend_commentaryon the session. - Phone calls
- A caller that LiveKit connects to a room is one more participant, so the same agent answers. For phone numbers from Resia, use a Call Agent instead.
What changes from GPT-Live
The rest of the session protocol is the same. The migration guide lists every event.
- Voices
- GPT-Live voice names such as
maringet aninvalid_valueerror. Leavevoiceunset, or use<provider>:<voice id>fromGET /v1/live/available-voices. - Delegation
- Use
"responses", the default, or"client". Fullplex does not serve"decisions",triggersorservice_tier. - Session limits
- 60 minutes for one session, and 5 sessions at the same time for each organization by default. A session with no audio ends 30 seconds after it starts.
- Language
- English.
- Price
- $0.025 a minute of session, counted by the second, plus the tokens of your backend model.
Troubleshooting
The errors a new Fullplex agent meets most, and their fixes.
The agent keeps talking after the caller cuts in.
FullplexAgent handler of step 4, and make each of your Agent classes extend it. Without it, audio of a reply that Fullplex stopped can still play. If the agent still talks over the caller, look for session.output_audio.cleared in the session's events. If the event does not come, the handler cannot act.The session ends with invalid_value on the voice.
FULLPLEX_VOICE to <provider>:<voice id> from GET /v1/live/available-voices.The session ends with an error on delegation.responses.model.
FULLPLEX_BACKEND_MODEL to one that is.The connection is refused with 401, 402, 403 or 429.
Where do I see my sessions and what they cost?
GET /v1/live/session-history lists your sessions. GET /v1/live/sessions/{session_id}/charge returns the charge of one session after it closes.Put Fullplex in your LiveKit agent.
Sign up, create an API key, and talk to your agent in the terminal.
