{"record":{"id":"fc5288be39e955c2","repo":"BerriAI/litellm","slug":"models-param-not-in-kwargs","errorCode":null,"errorMessage":"'models' param not in kwargs","messagePattern":"'models' param not in kwargs","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/batch_completion/main.py","lineNumber":230,"sourceCode":"            - Other keyword arguments to be passed to the completion function.\n\n    Returns:\n        list: A list of responses from the language models that responded.\n\n    Note:\n        This function utilizes a ThreadPoolExecutor to parallelize requests to multiple models.\n        It sends requests concurrently and collects responses from all models that respond.\n    \"\"\"\n    import concurrent.futures\n\n    # ANSI escape codes for colored output\n\n    if \"model\" in kwargs:\n        kwargs.pop(\"model\")\n    if \"models\" in kwargs:\n        models = kwargs.pop(\"models\")\n    else:\n        raise Exception(\"'models' param not in kwargs\")\n\n    if isinstance(models, str):\n        models = [models]\n    elif isinstance(models, (list, tuple)):\n        models = list(models)\n    else:\n        raise TypeError(\"'models' must be a string or list of strings\")\n\n    if len(models) == 0:\n        return []\n\n    responses: Final = []\n\n    with concurrent.futures.ThreadPoolExecutor(max_workers=len(models)) as executor:\n        futures: Final = [executor.submit(litellm.completion, *args, model=model, **kwargs) for model in models]\n\n        for future in futures:\n            try:","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/batch_completion/main.py#L212-L248","documentation":"Generic Exception raised by litellm.batch_completion_models when the kwargs dict does not contain a 'models' key. The function is designed to be called as batch_completion_models(**kwargs) with 'models' supplied among the kwargs; it pops 'models' (and 'model') out and fans the rest out to litellm.completion per model. Without 'models' there is nothing to parallelize.","triggerScenarios":"Calling litellm.batch_completion_models() without a models kwarg, e.g. passing models as a positional arg (unsupported) or forgetting it entirely: litellm.batch_completion_models(prompt='hi'). Note 'model' is silently popped first, so passing only model=... does not help.","commonSituations":"Confusing batch_completion_models (list of models, one prompt) with batch_completions (list of prompts); passing models positionally because the signature accepts *args for completion args; refactoring that drops the kwarg.","solutions":["Call it as litellm.batch_completion_models(models=['gpt-4o', 'claude-3-5-sonnet'], messages=[...]).","If you meant many prompts for one model, use litellm.batch_completion(models='gpt-4o', messages=[...]) instead.","Ensure 'models' is a keyword argument, not positional."],"exampleFix":"# before\nlitellm.batch_completion_models([\"gpt-4o\", \"claude-3-5-sonnet\"], messages=[{\"role\": \"user\", \"content\": \"hi\"}])\n\n# after\nlitellm.batch_completion_models(models=[\"gpt-4o\", \"claude-3-5-sonnet\"], messages=[{\"role\": \"user\", \"content\": \"hi\"}])","handlingStrategy":"validation","validationCode":"if \"models\" not in kwargs or not kwargs[\"models\"]:\n    raise ValueError(\"batch_completion_models requires a non-empty 'models' kwarg\")\nkwargs.setdefault(\"models\", list(kwargs[\"models\"]))","typeGuard":"def is_valid_batch_models_arg(kwargs: dict) -> bool:\n    return isinstance(kwargs.get(\"models\"), (str, list, tuple)) and len(kwargs.get(\"models\", ())) or isinstance(kwargs.get(\"models\"), str)","tryCatchPattern":null,"preventionTips":["Always call batch_completion_models(models=..., ...) with models as a keyword.","Use batch_completion (singular model, many prompts) when you have one model.","Add a wrapper function with an explicit models: list[str] parameter to get static checking."],"tags":["batch-completion","api-misuse","validation","python"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}