harry0703/MoneyPrinterTurbo · error · Exception

[{llm_provider}] returned an empty response, please check yo

Error message

[{llm_provider}] returned an empty response, please check your network connection and try again.

What it means

Raised in the azure branch when client.chat.completions.create() returns a falsy response. The message adds 'please check your network connection' because in practice this correlates with proxy/VPN interference or SDK/network stack issues rather than a normal Azure API error (which raises instead of returning empty).

Source

Thrown at app/services/llm.py:352

            logger.info(f"requesting azure chat completion, model: {model_name}")
            client = AzureOpenAI(
                api_key=api_key,
                api_version=api_version,
                azure_endpoint=base_url,
            )
            response = client.chat.completions.create(
                model=model_name, messages=[{"role": "user", "content": prompt}]
            )
            if response:
                if isinstance(response, ChatCompletion):
                    return _extract_chat_completion_text(response, llm_provider)
                else:
                    raise Exception(
                        f'[{llm_provider}] returned an invalid response: "{response}", please check your network '
                        f"connection and try again."
                    )
            else:
                raise Exception(
                    f"[{llm_provider}] returned an empty response, please check your network connection and try again."
                )

        if adapter == "modelscope":
            content = ""
            client = OpenAI(
                api_key=api_key,
                base_url=base_url,
            )
            response = client.chat.completions.create(
                model=model_name,
                messages=[{"role": "user", "content": prompt}],
                extra_body={"enable_thinking": False},
                stream=True,
            )
            if response:
                for chunk in response:
                    if not chunk.choices:

View on GitHub (pinned to 1f9f19c202)

Solutions

  1. Check network path to the Azure endpoint: curl -v https://<resource>.openai.azure.com/openai/models?api-version=<ver> with the api-key header
  2. Disable or bypass VPN/proxy for the Azure endpoint, or configure proxy env vars (HTTPS_PROXY) correctly
  3. Re-run — the outer _max_retries loop retries transient network failures; persistent recurrence means a stable network block
  4. Verify azure_endpoint, api_version, and deployment name (model_name must be the deployment name, not the model name)

Example fix

# common mistake: model_name set to the model, not the deployment
# before
azure.model_name = "gpt-4o"
# after
azure.model_name = "gpt-4o-deploy-1"  # deployment name shown in Azure AI Foundry
Defensive patterns

Strategy: retry

Validate before calling

import socket, urllib.parse
host = urllib.parse.urlparse(base_url).hostname
socket.getaddrinfo(host, 443)  # fails fast if DNS/network path to the Azure endpoint is broken

Try / catch

except Exception as e: if 'check your network' in str(e): retry with backoff up to _max_retries; persistent failure → check proxy/VPN and azure_endpoint URL

Prevention

When it happens

Trigger: AzureOpenAI chat completion call returning None/empty — corporate proxy or mitm-proxy returning empty bodies, VPN dropping responses, a mocked client returning None in tests, or severe openai SDK/network-stack corruption.

Common situations: Corporate networks with SSL-inspecting proxies that mangle Azure endpoints; unstable VPN tunnel to Azure regions; mainland-China network access issues reaching *.openai.azure.com; test fakes without proper return values.

Related errors


AI-assisted analysis of harry0703/MoneyPrinterTurbo@1f9f19c202 (2026-08-14). Data as JSON: /api/errors/38a2011fdcf25928. Report an issue: GitHub.