_main_task Nov 21 13:09:25 vps-50c0f19b python3[72...
# ask-ai
b
_main_task Nov 21 130925 vps-50c0f19b python3[72593]: raise Nov 21 130925 vps-50c0f19b python3[72593]: APIConnectionError( Nov 21 130925 vps-50c0f19b python3[72593]: f"failed to Nov 21 130925 vps-50c0f19b python3[72593]: generate LLM Nov 21 130925 vps-50c0f19b python3[72593]: completion after Nov 21 130925 vps-50c0f19b python3[72593]: {self._conn_options. Nov 21 130925 vps-50c0f19b python3[72593]: max_retry + 1} Nov 21 130925 vps-50c0f19b python3[72593]: attempts", # noqa: Nov 21 130925 vps-50c0f19b python3[72593]: E501 Nov 21 130925 vps-50c0f19b python3[72593]: ) from e Nov 21 130925 vps-50c0f19b python3[72593]: livekit.agents._exce Nov 21 130925 vps-50c0f19b python3[72593]: ptions.APIConnection Nov 21 130925 vps-50c0f19b python3[72593]: Error: failed to Nov 21 130925 vps-50c0f19b python3[72593]: generate LLM Nov 21 130925 vps-50c0f19b python3[72593]: completion after 4 Nov 21 130925 vps-50c0f19b python3[72593]: attempts (body=None, when using open azure llm
t
Thanks for reaching out, timothe. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m looking at the log excerpt showing an
APIConnectionError: failed to generate LLM completion after 4 attempts
when using Azure OpenAI with LiveKit Agents. I can help troubleshoot this. Can you provide the following so I can pinpoint the cause quickly? 1. The code snippet where you configure
openai.LLM.with_azure(...)
(redact secrets). 2. Values (redacted okay) of these environment variables:
AZURE_OPENAI_ENDPOINT
,
AZURE_OPENAI_API_KEY
or
AZURE_OPENAI_ENTRA_TOKEN
, and
OPENAI_API_VERSION
. 3. Result of this connectivity test run from the same VPS:
Copy code
curl -v "https://<your-resource>.openai.azure.com/openai/deployments?api-version=<OPENAI_API_VERSION>" -H "api-key: $AZURE_OPENAI_API_KEY"
Copy the HTTP status and any error body or connection error. 1. Whether the VPS is behind a firewall/proxy, or in a restricted hosting provider (OVH/Hetzner/etc.), and whether outbound HTTPS is allowed. 2. The deployment name you’re using (e.g.,
gpt-4o
) and whether that deployment exists and is healthy in the Azure portal. What I’ll check once you provide those: • Endpoint format and credentials correctness. • Network reachability and DNS/SSL issues from the VPS. • Any retry/connection options in your LiveKit config that may need adjustment. Send those details and I’ll propose targeted next steps. Sources: Azure OpenAI Realtime API and LiveKit | LiveKit Docs | AI Service Plugin Ecosystem | livekit/livekit_composite | DeepWiki | Azure OpenAI LLM plugin guide | LiveKit docs | Troubleshooting Guide | livekit/livekit_composite | DeepWiki
b
"/home/ubuntu/.local/ Nov 21 130931 vps-50c0f19b python3[72593]: lib/python3.13/site-p Nov 21 130931 vps-50c0f19b python3[72593]: ackages/livekit/agent Nov 21 130931 vps-50c0f19b python3[72593]: s/inference/llm.py", Nov 21 130931 vps-50c0f19b python3[72593]: line 341, in _run Nov 21 130931 vps-50c0f19b python3[72593]: raise Nov 21 130931 vps-50c0f19b python3[72593]: APIStatusError( Nov 21 130931 vps-50c0f19b python3[72593]: ...<5 lines>... Nov 21 130931 vps-50c0f19b python3[72593]: ) from None Nov 21 130931 vps-50c0f19b python3[72593]: livekit.agents._excep Nov 21 130931 vps-50c0f19b python3[72593]: tions.APIStatusError: Nov 21 130931 vps-50c0f19b python3[72593]: Error code: 404 - Nov 21 130931 vps-50c0f19b python3[72593]: {'error': {'code': Nov 21 130931 vps-50c0f19b python3[72593]: '404', 'message': Nov 21 130931 vps-50c0f19b python3[72593]: 'Resource not Nov 21 130931 vps-50c0f19b python3[72593]: found'}} Nov 21 130931 vps-50c0f19b python3[72593]: (status_code=404, Nov 21 130931 vps-50c0f19b python3[72593]: request_id=None, Nov 21 130931 vps-50c0f19b python3[72593]: body={'code': '404', Nov 21 130931 vps-50c0f19b python3[72593]: 'message': 'Resource Nov 21 130931 vps-50c0f19b python3[72593]: not found'
t
Thanks — I see a second error: an
APIStatusError
404 with body
{'code':'404','message':'Resource not found'}
from livekit.agents when calling Azure OpenAI. That tells us the request reached Azure but the specific resource or deployment couldn’t be found. To diagnose quickly, please provide: 1. The
openai.LLM.with_azure(...)
call (redact secrets) — especially the
azure_deployment
and
azure_endpoint
values. 2. The exact
AZURE_OPENAI_ENDPOINT
and
azure_deployment
you’re using (redact resource name if you prefer). 3. Output of this curl run from the same VPS (copy status and body):
Copy code
curl -v "https://<your-resource>.openai.azure.com/openai/deployments?api-version=<OPENAI_API_VERSION>" -H "api-key: $AZURE_OPENAI_API_KEY"
1. Confirm
OPENAI_API_VERSION
value and whether the named deployment exists and is listed in the Azure portal for that resource. 2. Any recent changes to the Azure resource (deleted/renamed deployment, region change) or use of a wrong resource name / trailing slash in the endpoint. What I’ll check once you send those: endpoint/deployment mismatch, wrong API version, or calling a deployment name that doesn’t exist.
b
we have gpt-4.1
t
Thanks — confirming you’re using the
gpt-4.1
deployment. A 404 means Azure reached your request but couldn’t find the named deployment/resource. Please check and share the following so I can help you fix it quickly: 1. The
openai.LLM.with_azure(...)
call (redact keys) — show
azure_deployment
and
azure_endpoint
. 2. Exact
AZURE_OPENAI_ENDPOINT
and
azure_deployment
values you set (redact resource name if preferred). 3.
OPENAI_API_VERSION
value. 4. Output of this curl run from the same VPS (status and response body):
Copy code
curl -v "https://<your-resource>.openai.azure.com/openai/deployments?api-version=<OPENAI_API_VERSION>" -H "api-key: $AZURE_OPENAI_API_KEY"
1. Confirm in the Azure portal that a deployment named exactly
gpt-4.1
exists under that OpenAI resource (deployment names are case-sensitive and must match exactly). Common causes to double-check: • Deployment name typo or missing deployment. • Using the wrong OpenAI resource/endpoint (must be https://<your-resource>.openai.azure.com/). • Incompatible or incorrect
OPENAI_API_VERSION
. Share the requested values/output and I’ll point out the mismatches and next steps.
b
gpt4-1 is the name of the model that we used
t
Thanks — I understand you used the model name
gpt4-1
. To resolve the 404, I need a couple quick confirmations and one test run from your VPS. Please provide or confirm: 1. The
openai.LLM.with_azure(...)
call (redact secrets) — show
azure_deployment
and
azure_endpoint
. 2. The
AZURE_OPENAI_ENDPOINT
and
azure_deployment
values you set (exact strings). 3. The
OPENAI_API_VERSION
value. 4. From the same VPS, run and paste the HTTP status + response body:
Copy code
curl -v "https://<your-resource>.openai.azure.com/openai/deployments?api-version=<OPENAI_API_VERSION>" -H "api-key: $AZURE_OPENAI_API_KEY"
1. Confirm in the Azure portal that a deployment named exactly
gpt4-1
exists (deployment names are case-sensitive and must match the
azure_deployment
you use). If
gpt4-1
is the model name but your deployment uses a different deployment name (common), tell me the deployment name shown in the Azure portal. Once you share the above, I’ll point out the exact mismatch and next steps.
b
do we need to enter the name of the deployed project
t
You must use the exact Azure deployment name (the name you created when deploying the model), not the generic model name. That is why you saw a 404. Please confirm/provide these exact values (redact secrets) so I can pinpoint the mismatch and give a fix: •
azure_deployment
you’re passing to
openai.LLM.with_azure(...)
•
AZURE_OPENAI_ENDPOINT
(exact string) •
OPENAI_API_VERSION
value • The deployment name shown in the Azure portal under your OpenAI resource (copy exact spelling/case) • Output (status + body) of this run from the same VPS:
Copy code
curl -v "https://<your-resource>.openai.azure.com/openai/deployments?api-version=<OPENAI_API_VERSION>" -H "api-key: $AZURE_OPENAI_API_KEY"
If your portal shows a deployment name different from
gpt4-1
(or
gpt-4.1
), use that exact deployment name for
azure_deployment
. Once you share the values/output above, I’ll tell you the exact change to make. Sources: Azure OpenAI LLM plugin guide | LiveKit docs | Azure OpenAI Realtime API and LiveKit | LiveKit Docs