Hi LiveKit team! :wave: I'm getting a 404 error wh...
# ask-ai
a
Hi LiveKit team! đź‘‹ I'm getting a 404 error when initializing OpenAI TTS (model "tts-1-hd") in livekit-agents v1.2.12 and livekit-plugins-openai v1.2.12. During AgentSession setup, the OpenAI client is making a GET request to https://api.openai.com/v1/ which returns 404 Not Found. My OPENAI_API_KEY is correctly set and the OpenAI LLM works fine in the same session, but TTS initialization fails before making any actual TTS calls. Is this a known issue or expected behavior?
t
Thanks for reaching out, Eshan23. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm sorry to hear you're encountering a 404 error during OpenAI TTS initialization in
livekit-agents
v1.2.12 and
livekit-plugins-openai
v1.2.12. This usually happens when there's a mismatch between the API endpoint you intend to use and the one actually being accessed. Let’s walk through some steps together to help you resolve this: 1. Verify TTS Initialization Syntax: Double-check that you're using the correct syntax for your setup. For standard OpenAI, it should look like this:
Copy code
from livekit.plugins import openai
session = AgentSession(
    tts=openai.TTS(
        model="gpt-4o-mini-tts",
        voice="ash",
        instructions="Speak in a friendly and conversational tone.",
    ),
    # ... llm, stt, etc.
)
2. Check for Azure OpenAI Misconfiguration: If you’re using Azure OpenAI, it’s important to use the
.with_azure()
method like this:
Copy code
from livekit.plugins import openai
session = AgentSession(
    tts=openai.TTS.with_azure(
        model="gpt-4o-mini-tts",
        voice="coral",
        azure_endpoint="https://your-resource.openai.azure.com",
        api_key="your-api-key"
    )
)
Using the wrong method here can lead to that 404 error, so it’s a good idea to double-check. 3. Validate API Key and Environment Variables: Make sure your environment variables are set correctly: ◦ For OpenAI:
OPENAI_API_KEY
â—¦ For Azure OpenAI:
AZURE_OPENAI_API_KEY
,
AZURE_OPENAI_ENDPOINT
, and optionally
AZURE_OPENAI_AD_TOKEN
1. Review Custom Base URLs: If you’re using a custom
base_url
, please confirm it points to a valid OpenAI-compatible endpoint. If you’re not using a proxy or custom gateway, it’s best to leave
base_url
out so the default endpoint is used. 2. Confirm Model and Voice Availability: Supported models include
gpt-4o-mini-tts
,
tts-1
, and
tts-1-hd
. Please ensure the model and voice combination you’re using is valid. If after these checks the problem still persists, try enabling debug logging in your agent to capture the exact URL being requested. This can give us more clues to track down the issue. Please don’t hesitate to reach out if you need any more help—I’m here to support you! Sources: OpenAI TTS integration guide | LiveKit Docs | Docs::Agents | tests/test_tts.py | pipeline-tts/openai_tts.py | Docs::Agents
a
I've verified all the points you mentioned: 1. I'm using standard OpenAI (not Azure), so I'm initializing with openai.TTS(model="tts-1-hd", voice="ash") without any custom base_url or Azure-specific methods. 2. My OPENAI_API_KEY is correctly set in the environment and verified working - the OpenAI LLM in the same AgentSession initializes successfully without issues. 3. I'm using a supported model ("tts-1-hd") with a valid voice ("ash"). The strange part is that the 404 error shows a GET request to https://api.openai.com/v1/ (the base endpoint with no path), which isn't a valid OpenAI API endpoint. This happens during TTS initialization before any actual synthesis calls are made. Could there be an issue with how the plugin is validating the API connection on initialization, or is there additional configuration I'm missing?
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!