{"record":{"id":"38a2011fdcf25928","repo":"harry0703/MoneyPrinterTurbo","slug":"llm-provider-returned-an-empty-response-pleas","errorCode":null,"errorMessage":"[{llm_provider}] returned an empty response, please check your network connection and try again.","messagePattern":"\\[(.+?)\\] returned an empty response, please check your network connection and try again\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"app/services/llm.py","lineNumber":352,"sourceCode":"            logger.info(f\"requesting azure chat completion, model: {model_name}\")\n            client = AzureOpenAI(\n                api_key=api_key,\n                api_version=api_version,\n                azure_endpoint=base_url,\n            )\n            response = client.chat.completions.create(\n                model=model_name, messages=[{\"role\": \"user\", \"content\": prompt}]\n            )\n            if response:\n                if isinstance(response, ChatCompletion):\n                    return _extract_chat_completion_text(response, llm_provider)\n                else:\n                    raise Exception(\n                        f'[{llm_provider}] returned an invalid response: \"{response}\", please check your network '\n                        f\"connection and try again.\"\n                    )\n            else:\n                raise Exception(\n                    f\"[{llm_provider}] returned an empty response, please check your network connection and try again.\"\n                )\n\n        if adapter == \"modelscope\":\n            content = \"\"\n            client = OpenAI(\n                api_key=api_key,\n                base_url=base_url,\n            )\n            response = client.chat.completions.create(\n                model=model_name,\n                messages=[{\"role\": \"user\", \"content\": prompt}],\n                extra_body={\"enable_thinking\": False},\n                stream=True,\n            )\n            if response:\n                for chunk in response:\n                    if not chunk.choices:","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/harry0703/MoneyPrinterTurbo/blob/1f9f19c2021a68d04df228f33e9099a0c947f6f8/app/services/llm.py#L334-L370","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check network path to the Azure endpoint: curl -v https://<resource>.openai.azure.com/openai/models?api-version=<ver> with the api-key header","Disable or bypass VPN/proxy for the Azure endpoint, or configure proxy env vars (HTTPS_PROXY) correctly","Re-run — the outer _max_retries loop retries transient network failures; persistent recurrence means a stable network block","Verify azure_endpoint, api_version, and deployment name (model_name must be the deployment name, not the model name)"],"exampleFix":"# common mistake: model_name set to the model, not the deployment\n# before\nazure.model_name = \"gpt-4o\"\n# after\nazure.model_name = \"gpt-4o-deploy-1\"  # deployment name shown in Azure AI Foundry","handlingStrategy":"retry","validationCode":"import socket, urllib.parse\nhost = urllib.parse.urlparse(base_url).hostname\nsocket.getaddrinfo(host, 443)  # fails fast if DNS/network path to the Azure endpoint is broken","typeGuard":null,"tryCatchPattern":"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","preventionTips":["Verify the network path to <resource>.openai.azure.com before long jobs","Configure HTTPS_PROXY explicitly in corporate environments instead of relying on transparent interception","Use the connection test button before batch runs"],"tags":["llm","azure","network","proxy","vpn"],"backgroundTag":null,"analyzedSha":"1f9f19c2021a68d04df228f33e9099a0c947f6f8","analyzedAt":"2026-08-14T19:41:05.568Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}