harry0703/MoneyPrinterTurbo · error · Exception

[{llm_provider}] returned an error response: "{response}"

Error message

[{llm_provider}] returned an error response: "{response}"

What it means

Raised in the qwen adapter branch of _generate_response() after dashscope.Generation.call() returns a GenerationResponse whose status_code is not 200. Dashscope does not raise on API errors; it packs the HTTP status and code/message into the response object, so this check is the only error surfacing. The full response object is embedded in the message for diagnosis.

Source

Thrown at app/services/llm.py:228

            if field.required and not extra_values[field.config_suffix]:
                raise ValueError(
                    f"{llm_provider}: {field.config_suffix} is not set, "
                    "please set it in the config.toml file."
                )

        if adapter == "qwen":
            import dashscope
            from dashscope.api_entities.dashscope_response import GenerationResponse

            dashscope.api_key = api_key
            response = dashscope.Generation.call(
                model=model_name, messages=[{"role": "user", "content": prompt}]
            )
            if response:
                if isinstance(response, GenerationResponse):
                    status_code = response.status_code
                    if status_code != 200:
                        raise Exception(
                            f'[{llm_provider}] returned an error response: "{response}"'
                        )

                    return _extract_qwen_generation_text(response)
                else:
                    raise Exception(
                        f'[{llm_provider}] returned an invalid response: "{response}"'
                    )
            else:
                raise Exception(f"[{llm_provider}] returned an empty response")

        if adapter == "gemini":
            from google import genai
            from google.genai import types

            http_options = types.HttpOptions(base_url=base_url) if base_url else None
            generation_config = types.GenerateContentConfig(
                temperature=0.5,

View on GitHub (pinned to 1f9f19c202)

Solutions

  1. Inspect the embedded response: response.code and response.message inside the f-string identify the exact DashScope error (InvalidApiKey, Throttling, InvalidParameter, etc.)
  2. For 401/403 fix [qwen].api_key in config.toml (or set it via WebUI) and re-run test_connection()
  3. For 429 throttle, slow down generation requests or upgrade the DashScope quota tier
  4. For invalid model errors, set [qwen].model_name to a currently valid model (e.g. qwen-turbo/qwen-plus) and upgrade the dashscope package
  5. For 5xx or intermittent SDK errors, retry — the caller already wraps this in a retry loop (_max_retries = 5) so repeated failures indicate a persistent issue

Example fix

# before
response = dashscope.Generation.call(
    model=model_name, messages=[{"role": "user", "content": prompt}]
)
if status_code != 200:
    raise Exception(f'[{llm_provider}] returned an error response: "{response}"')

# after (log the structured fields instead of the whole object)
if status_code != 200:
    raise Exception(
        f"[qwen] API error {status_code}: {response.code} - {response.message}"
    )
Defensive patterns

Strategy: retry

Try / catch

except Exception as e: — inspect the embedded DashScope code; retry only on 429/5xx-type codes (Throttling, ServiceUnavailable), fail fast on 401/403 (InvalidApiKey) since retries cannot fix credentials

Prevention

When it happens

Trigger: dashscope.Generation.call(model=..., messages=[...]) returning status_code 400/401/403/429/500 — e.g. invalid DASHSCOPE API key (401 InvalidApiKey), rate limiting (429 Throttling), nonexistent model_name, or DashScope service outage; also SDK-level errors reported through the response envelope.

Common situations: Expired or mistyped qwen api_key in config.toml; using a model name not available to the account's region; hitting free-tier QPS limits during batch video generation; dashscope SDK version drift changing status_code semantics; mainland vs international DashScope endpoint mismatch.

Related errors


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