BerriAI/litellm · error · HTTPException

target_model_names on list files must be a list of one model

Error message

target_model_names on list files must be a list of one model name. Example: ['gpt-4o']

What it means

HTTPException(400) raised when listing files: target_model_names was supplied but does not contain exactly one model name (empty, multiple entries, or wrong type). Model-based routing for file listing only supports a single pinned deployment.

Source

Thrown at litellm/proxy/openai_files_endpoints/files_endpoints.py:1369

            data=data,
            check_file_id_encoding=False,
        )

        if should_route and credentials is not None:
            # Use model-based routing with credentials from config
            prepare_data_with_credentials(data=data, credentials=credentials)
            response = await litellm.afile_list(
                custom_llm_provider=credentials["custom_llm_provider"],
                purpose=purpose,
                **data,
            )

            verbose_proxy_logger.debug("Listed files using model: %s", model_used)

        elif target_model_names and isinstance(target_model_names, str):
            target_model_names_list: Final = target_model_names.split(",")
            if len(target_model_names_list) != 1:
                raise HTTPException(
                    status_code=400,
                    detail="target_model_names on list files must be a list of one model name. Example: ['gpt-4o']",
                )
            if llm_router is None:
                raise HTTPException(
                    status_code=500,
                    detail="LLM Router not initialized. Ensure models added to proxy.",
                )
            credentials = get_credentials_for_model(
                llm_router=llm_router,
                model_id=target_model_names_list[0],
                operation_context="file list",
            )
            prepare_data_with_credentials(data=data, credentials=credentials)
            response = await litellm.afile_list(
                custom_llm_provider=credentials["custom_llm_provider"],
                purpose=purpose,
                **data,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Pass target_model_names as a list containing exactly one model name, e.g. ['gpt-4o'].
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/openai_files_endpoints/files_endpoints.py:1369 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/0a676ba5b76b6cd4. Report an issue: GitHub.