BerriAI/litellm · error · Exception

Invalid hf task - . Valid formats - .

Error message

Invalid hf task - {task}. Valid formats - {hf_tasks}.

What it means

Error "Invalid hf task - {task}. Valid formats - {hf_tasks}." thrown in BerriAI/litellm.

Solutions

  1. Use a valid HuggingFace task from the list in the error, e.g. feature-extraction or sentence-similarity.

When it happens

Trigger: Thrown at litellm/llms/huggingface/embedding/transformation.py:211 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/092a3abb7b3f99ee. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/huggingface/embedding/transformation.py:211

        elif model in conversational_models:
            return "conversational", model
        elif "roneneldan/TinyStories" in model:
            return "text-generation", model
        else:
            return "text-generation-inference", model  # default to tgi

    def transform_request(
        self,
        model: str,
        messages: list[AllMessageValues],
        optional_params: dict,
        litellm_params: dict,
        headers: dict,
    ) -> dict:
        task: Final = litellm_params.get("task", None)
        ## VALIDATE API FORMAT
        if task is None or not isinstance(task, str) or task not in hf_task_list:
            raise Exception(f"Invalid hf task - {task}. Valid formats - {hf_tasks}.")

        ## Load Config
        config: Final = litellm.HuggingFaceEmbeddingConfig.get_config()
        for k, v in config.items():
            if (
                k not in optional_params
            ):  # completion(top_k=3) > huggingfaceConfig(top_k=3) <- allows for dynamic variables to be passed in
                optional_params[k] = v

        ### MAP INPUT PARAMS
        #### HANDLE SPECIAL PARAMS
        special_params: Final = self.get_special_options_params()
        special_params_dict: Final = {}
        # Create a list of keys to pop after iteration
        keys_to_pop: Final = []

        for k, v in optional_params.items():
            if k in special_params:

View on GitHub (pinned to 77b7c6c40c)