huggingface/smolagents · error · ValueError

Unsupported model type: {model_type}

Error message

Unsupported model type: {model_type}

What it means

Raised by load_model in the smolagents CLI when the --model-type argument does not match any of the supported backends (e.g. OpenAI, LiteLLM, Transformers, Hugging Face API). The dispatcher checks known model types and falls through to this ValueError for anything unrecognized. It is purely an input-validation error, not a model or network problem.

Source

Thrown at src/smolagents/cli.py:216

            api_base=api_base or "https://api.fireworks.ai/inference/v1",
            model_id=model_id,
        )
    elif model_type == "LiteLLMModel":
        return LiteLLMModel(
            model_id=model_id,
            api_key=api_key,
            api_base=api_base,
        )
    elif model_type == "TransformersModel":
        return TransformersModel(model_id=model_id, device_map="auto")
    elif model_type == "InferenceClientModel":
        return InferenceClientModel(
            model_id=model_id,
            token=api_key or os.getenv("HF_API_KEY"),
            provider=provider,
        )
    else:
        raise ValueError(f"Unsupported model type: {model_type}")


def run_smolagent(
    prompt: str,
    tools: list[str],
    model_type: str,
    model_id: str,
    api_base: str | None = None,
    api_key: str | None = None,
    imports: list[str] | None = None,
    provider: str | None = None,
    action_type: str = "code",
) -> None:
    load_dotenv()

    model = load_model(model_type, model_id, api_base=api_base, api_key=api_key, provider=provider)

    available_tools = []

View on GitHub (pinned to 30bb116109)

Solutions

  1. Check the exact supported --model-type values in smolagents/cli.py load_model and correct the argument (e.g. 'openai', 'litellm', 'transformers', 'huggingface').
  2. If you need another provider, use LiteLLM as the model type since it proxies many providers, or instantiate the model programmatically instead of via the CLI.
  3. Upgrade smolagents — newer releases may add the backend you want.

Example fix

# before
smolagent --model-type gpt --prompt "hi"
# after
smolagent --model-type openai --model-id gpt-4o-mini --prompt "hi"
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED = {'openai','litellm','transformers','huggingface'}
import sys
if sys.argv[sys.argv.index('--model-type')+1] not in SUPPORTED: sys.exit(f'model-type must be one of {SUPPORTED}')

Prevention

When it happens

Trigger: Running `smolagent --model-type <invalid>` (e.g. a typo like 'openaai', 'anthropic' when unsupported in this version, or a new backend name not yet in the CLI dispatch chain). Any value that doesn't match the exact strings handled before the else branch in load_model.

Common situations: Typos in --model-type, expecting a provider supported elsewhere in the library but not wired into the CLI loader, or version drift where model type names changed between smolagents releases.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of huggingface/smolagents@30bb116109 (2026-08-28). Data as JSON: /api/errors/5a203ec87f61dfcd. Report an issue: GitHub.