<@U07FRRZH2GN> why I get Openairealtimeerror when ...
# ask-ai
d
@icy-policeman-64898 why I get Openairealtimeerror when I use these configs to pass language
Copy code
if "input_audio_transcription" in model_settings:
    transcription_config = model_settings.pop("input_audio_transcription")
    if isinstance(transcription_config, dict):
        transcription_config["language"] = language
        realtime_params["input_audio_transcription"] = InputAudioTranscription(**transcription_config)
else:
    realtime_params["input_audio_transcription"] = InputAudioTranscription(language=language)

realtime_params.update(model_settings)
realtime_model = openai.realtime.RealtimeModel(
    api_key=api_key,
    **realtime_params,
)
and I don't get any errors if I don't include input_audio_transcription param
t
Thanks for reaching out, Eugene. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're getting OpenaiRealtimeError because
input_audio_transcription
does not accept a
language
field. The Realtime transcription object only accepts
model
(for example
"whisper-1"
), so passing
InputAudioTranscription(language=language)
sends an invalid parameter to the backend. What you can do: • Remove
language
from
input_audio_transcription
and only pass the model:
Copy code
realtime_params["input_audio_transcription"] = InputAudioTranscription(model="whisper-1")
• If you need the model to expect a specific language, either: ◦ Add a language hint in `instructions`/`prompt` (e.g., "The user will speak Spanish"), or ◦ Use a separate STT service/plugin configured for that language (deepgram/assemblyai/etc.) and disable
input_audio_transcription
. If you want, share the exact error text and the full
model_settings
dict and I’ll suggest a minimal code change to sanitize unsupported fields before creating
RealtimeModel
. Sources: OpenAI Realtime API plugin guide | LiveKit docs | Azure OpenAI Realtime API and LiveKit | LiveKit docs | LiveKit turn detector plugin | LiveKit docs
d
but this is a class which accepts language
Copy code
class InputAudioTranscription(BaseModel):
    language: Optional[str] = None
    """The language of the input audio.

    Supplying the input language in
    [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
    format will improve accuracy and latency.
    """

    model: Optional[str] = None
    """
    The model to use for transcription, current options are `gpt-4o-transcribe`,
    `gpt-4o-mini-transcribe`, and `whisper-1`.
    """

    prompt: Optional[str] = None
    """
    An optional text to guide the model's style or continue a previous audio
    segment. For `whisper-1`, the
    [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
    For `gpt-4o-transcribe` models, the prompt is a free text string, for example
    "expect words related to technology".
    """
t
Thanks — I see you're pointing out that the SDK's
InputAudioTranscription
class includes a
language
field, and you want to know why passing it still triggers an OpenaiRealtimeError. You're right to call that out. Short answer: the SDK defines
language
, but the OpenAI Realtime backend currently rejects
language
when it is sent in the session parameters. That mismatch (SDK field present vs backend schema enforcement) causes the error. What you can do next: • Remove
language
from the
input_audio_transcription
you send to
RealtimeModel
and keep only
model
(e.g.,
whisper-1
) to avoid the error. • If you need language control: ◦ Add a language hint in `instructions`/`prompt` (e.g., "The user will speak Spanish"). ◦ Or use a separate STT provider/plugin that supports explicit
language
and feed its transcripts to the model. To help further, please share: • The exact OpenaiRealtimeError text you see, and • Your LiveKit SDK version (and OpenAI plugin version) — I can confirm whether a version mismatch may be involved and suggest the minimal code change to sanitize unsupported fields before creating
RealtimeModel
. Sources: OpenAI Realtime API plugin guide | LiveKit docs | AssemblyAI plugin guide | LiveKit Docs | ElevenLabs STT | LiveKit docs