This message was deleted.
# ask-ai
s
This message was deleted.
t
Thanks for reaching out, Aleh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
It sounds like you want to run the OpenAI LLM standalone (not the session’s LLM) to classify STT output and detect spoken language. That’s supported: the LLM can be used independently with a streaming interface that takes a
ChatContext
and returns `ChatChunk`s. See: LLM overview, OpenAI plugin. If helpful, I can share a minimal example. To tailor it: • Which SDK are you using (Python or Node)? • Will you call the OpenAI plugin with your own
OPENAI_API_KEY
, or use LiveKit Inference models? • Do you already have transcripts from STT, or do you need guidance building a
ChatContext
from STT output? I can then show: • Instantiating
livekit.plugins.openai.LLM
standalone • Building a short
ChatContext
with the transcript and a system prompt like “Return only the ISO language code” • Consuming the streamed `ChatChunk`s to get the classification output Sources: Large language models (LLM) | LiveKit Docs | OpenAI LLM plugin guide | LiveKit Docs | OpenAI LLM models | LiveKit Docs | Speech-to-text (STT) models | LiveKit Docs
b
python session setup is the following
Copy code
tts = TTS.with_azure(
    azure_endpoint=azure_openai_tts_settings.endpoint,
    api_key=azure_openai_tts_settings.api_key,
    model=agent_settings.TTS_MODEL,
    azure_deployment=agent_settings.TTS_MODEL,
    voice=agent_settings.TTS_VOICE,
    speed=agent_settings.TTS_SPEED,
    instructions=vibe_instructions,
)

llm = RealtimeModel.with_azure(
    azure_deployment=agent_settings.LLM_MODEL,
    voice=agent_settings.LLM_VOICE,
    modalities=["text"],
    turn_detection=TurnDetection(
        type="semantic_vad",
        eagerness="auto",
        create_response=True,
        interrupt_response=True,
    ),
)
for llm i'll use
Copy code
LLM.with_azure(
    azure_deployment=judge_llm_settings.model,
)
t
It sounds like you’ll keep your session’s
RealtimeModel
for voice, and use a separate Azure-backed
LLM
for language classification. That’s supported: the LLM can run standalone with a
ChatContext
and returns streamed `ChatChunk`s (overview, Azure plugin guide). Minimal Python sketch using `LLM.with_azure`:
Copy code
from livekit.plugins.openai import LLM
from livekit.agents import ChatContext

# Ensure env vars are set: AZURE_OPENAI_API_KEY (or AZURE_OPENAI_ENTRA_TOKEN),
# AZURE_OPENAI_ENDPOINT, OPENAI_API_VERSION

judge_llm = LLM.with_azure(
    azure_deployment="your-azure-deployment-name",
    temperature=0.0,
)

# Build ChatContext from your STT transcript
transcript = "Hola, ¿cómo estás?"
ctx = ChatContext(
    system="You are a classifier. Return only the ISO 639-1 language code of the user text.",
    messages=[{"role": "user", "content": transcript}],
)

# Call standalone LLM and collect the streamed result
result_text = []
async for chunk in judge_llm.chat(ctx):
    if chunk.delta:
        result_text.append(chunk.delta)

language_code = "".join(result_text).strip()
print("Detected language:", language_code)
Notes: • Use a deterministic config (temperature 0) for classification. • Provide your Azure deployment name via
azure_deployment
and set the Azure env vars before running. Details: Azure OpenAI LLM plugin guide. Want me to adapt this to your exact transcript source or return a JSON label instead of plain text? Sources: Large language models (LLM) | LiveKit Docs | Azure OpenAI LLM plugin guide | LiveKit docs | OpenAI LLM models | LiveKit Docs | Azure OpenAI Realtime API and LiveKit | LiveKit Docs | Building voice agents | LiveKit Docs