harry0703/MoneyPrinterTurbo · error · ValueError

{llm_provider}: {field.config_suffix} is not set, please set

Error message

{llm_provider}: {field.config_suffix} is not set, please set it in the config.toml file.

What it means

Raised by _generate_response() in app/services/llm.py when a provider declares an extra required field (provider.extra_fields with required=True) but its resolved value is empty. The value comes from config.app[provider.config_key(field.config_suffix)] or the field's default_value, so it fires before any network call. It is a configuration validation error, not an API error.

Source

Thrown at app/services/llm.py:211

            for field in provider.extra_fields
        }

        if provider.requires_api_key and not api_key:
            raise ValueError(
                f"{llm_provider}: api_key is not set, please set it in the config.toml file."
            )
        if provider.requires_model_name and not model_name:
            raise ValueError(
                f"{llm_provider}: model_name is not set, please set it in the config.toml file."
            )
        if provider.requires_base_url and not base_url:
            raise ValueError(
                f"{llm_provider}: base_url is not set, please set it in the config.toml file."
            )

        for field in provider.extra_fields:
            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}"'

View on GitHub (pinned to 1f9f19c202)

Solutions

  1. Find the missing key: the message names the provider and field.config_suffix (e.g. 'cloudflare_ai_gateway: account_id'); add {provider}.{suffix} to config.toml under [app]
  2. If the value is provider-specific (account_id, gateway_id, api_version), copy it from the provider console/dashboard and set it in config.toml
  3. Restart/reload the app after editing config.toml, since runtime_app_config may be a snapshot taken at task submission
  4. If the field should not be mandatory, verify the provider definition in app/models/llm_provider.py sets required=False or provides default_value

Example fix

# before (config.toml)
[app]
llm_provider = "cloudflare_ai_gateway"
# account_id / gateway_id missing -> ValueError at llm.py:211

# after
[app]
llm_provider = "cloudflare_ai_gateway"
cloudflare_ai_gateway.account_id = "abc123"
cloudflare_ai_gateway.gateway_id = "gw-456"
Defensive patterns

Strategy: validation

Validate before calling

# before calling generation, verify provider extra fields
from app.config import config
from app.models.llm_provider import get_llm_provider

provider = get_llm_provider(cfg.get('llm_provider', '').lower())
missing = [
    f.config_suffix for f in provider.extra_fields
    if f.required and not (config.app.get(provider.config_key(f.config_suffix), '') or f.default_value)
]
assert not missing, f"missing required config: {missing}"

Try / catch

catch ValueError and surface it to the user as a config-fix action, distinguishing it (by the 'is not set, please set it in the config.toml file' suffix) from transient API errors that deserve retry

Prevention

When it happens

Trigger: Calling _generate_response() with a provider whose adapter requires extra fields (e.g. azure's api_version-style extras, or cloudflare_ai_gateway's account_id/gateway_id) while the matching config.toml key (e.g. {provider}.account_id) is missing, empty string, or has no default_value in the provider registry.

Common situations: Switching llm_provider to cloudflare_ai_gateway or azure in config.toml without adding the provider-specific keys; renaming the config section so the key no longer resolves; using an older config.toml after a provider gained a new required field; empty string from the WebUI config save overwriting a previously set value.

Related errors


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