{"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":"validation","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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/batch_completion/main.py#L212-L248","documentation":"batch_completion_models_all_responses() fans a prompt out to several models concurrently and requires the model list via a models kwarg (it even strips a conflicting model kwarg first). If models is not present in kwargs it raises this generic Exception before doing any work. The sibling batch_completion() uses positional model args, which is why callers frequently mix the two conventions up.","triggerScenarios":"Calling batch_completion_models_all_responses(prompt=..., model=[\"a\",\"b\"]) — model is popped and discarded, models is missing; passing models positionally; refactoring from batch_completion(model=[...], ...) without renaming the kwarg to models.","commonSituations":"Confusing the two batch helpers' signatures; dynamic kwargs construction where the models key is conditionally absent; tutorials mixing batch_completion and batch_completion_models_all_responses examples.","solutions":["Pass the model list as the models kwarg: batch_completion_models_all_responses(models=[...], **kwargs)","Remove any model kwarg — it is intentionally ignored/popped by this function","If you wanted per-call model strings instead, use batch_completion(model=..., ...)","Guard dynamic kwargs: assert 'models' in kwargs before calling"],"exampleFix":"# before\nresponses = batch_completion_models_all_responses(\n    model=[\"gpt-4o-mini\", \"claude-3-5-haiku\"],\n    messages=[{\"role\": \"user\", \"content\": \"hello\"}],\n)\n\n# after\nresponses = batch_completion_models_all_responses(\n    models=[\"gpt-4o-mini\", \"claude-3-5-haiku\"],\n    messages=[{\"role\": \"user\", \"content\": \"hello\"}],\n)\n","handlingStrategy":"validation","validationCode":"if \"models\" not in kwargs or not kwargs[\"models\"]:\n    raise ValueError(\"models kwarg (str or list[str]) is required\")\nresponses = batch_completion_models_all_responses(**kwargs)\n","typeGuard":"def has_models_kwarg(kwargs: dict) -> bool:\n    return \"models\" in kwargs\n","tryCatchPattern":"try:\n    responses = batch_completion_models_all_responses(**kwargs)\nexcept Exception as e:\n    if \"'models' param not in kwargs\" in str(e):\n        raise TypeError(\"call with models=[...] kwarg\") from e\n    raise\n","preventionTips":["Remember the signature rule: models= for *_models_all_responses helpers, model= for batch_completion","Assert required kwargs on dynamically built dicts before calling","Cover both helpers in wrapper unit tests to catch signature drift"],"tags":["batch-completion","models-param","api-misuse","kwargs"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}