{"record":{"id":"8f85c02f6fe6d83f","repo":"BerriAI/litellm","slug":"filtering-by-provider-is-not-supported-when-usin","errorCode":null,"errorMessage":"Filtering by 'provider' is not supported when using managed batches.","messagePattern":"Filtering by 'provider' is not supported when using managed batches\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"enterprise/litellm_enterprise/proxy/hooks/managed_files.py","lineNumber":423,"sourceCode":"        raise HTTPException(\n            status_code=404,\n            detail=f\"Object not found: {unified_object_id}\",\n        )\n\n    async def list_user_batches(\n        self,\n        user_api_key_dict: UserAPIKeyAuth,\n        limit: Optional[int] = None,\n        after: Optional[str] = None,\n        provider: Optional[str] = None,\n        target_model_names: Optional[str] = None,\n        llm_router: Optional[Router] = None,\n    ) -> Dict[str, object]:\n        # Provider filtering is not supported for managed batches\n        # This is because the encoded object ids stored in the managed objects table do not contain the provider information\n        # To support provider filtering, we would need to store the provider information in the encoded object ids\n        if provider:\n            raise Exception(\"Filtering by 'provider' is not supported when using managed batches.\")\n\n        # Model name filtering is not supported for managed batches\n        # This is because the encoded object ids stored in the managed objects table do not contain the model name\n        # A hash of the model name + litellm_params for the model name is encoded as the model id. This is not sufficient to reliably map the target model names to the model ids.\n        if target_model_names:\n            raise Exception(\"Filtering by 'target_model_names' is not supported when using managed batches.\")\n\n        owner_filter = build_owner_filter(user_api_key_dict)\n        if owner_filter is None:\n            return build_list_page([])\n\n        where_clause: Dict[str, object] = {\"file_purpose\": \"batch\", **owner_filter}\n\n        if after:\n            cursor_row = await _managed_object_table(self.prisma_client).find_first(\n                where={**where_clause, \"unified_object_id\": after}\n            )\n            if cursor_row is None:","sourceCodeStart":405,"sourceCodeEnd":441,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/enterprise/litellm_enterprise/proxy/hooks/managed_files.py#L405-L441","documentation":"Generic Exception from list_user_batches: passing a non-None provider filter is rejected because encoded object ids in the managed objects table do not encode provider information, so provider filtering cannot be implemented reliably for managed batches.","triggerScenarios":"Calling list_user_batches with provider='azure' (or any value) while managed batches/files are enabled. Any truthy provider triggers the raise before the query is built.","commonSituations":"Porting client code written for unmanaged (pass-through) batches, where provider filtering worked, to a managed-files deployment; UI filters carried over from a provider-aware file list to the batch list.","solutions":["Remove the provider parameter from the list_user_batches call","If provider separation is required, maintain separate proxies/deployments per provider, or track provider metadata in your own DB keyed by unified_object_id and filter client-side","Watch for the sibling restriction: target_model_names is also unsupported (managed_files.py:429)"],"exampleFix":"# before\nbatches = await managed_files.list_user_batches(\n    user_api_key_dict, limit=20, provider='azure')\n\n# after\nbatches = await managed_files.list_user_batches(user_api_key_dict, limit=20)\n# filter provider client-side using your own metadata","handlingStrategy":"validation","validationCode":"def clean_batch_filters(provider=None, target_model_names=None, **kw):\n    if provider:\n        logger.warning('provider filter unsupported for managed batches; dropped')\n    kw.pop('provider', None)\n    return kw","typeGuard":"def is_supported_batch_filter(provider: str | None) -> bool:\n    return provider is None","tryCatchPattern":"try:\n    await managed_files.list_user_batches(uak, limit=20, provider=p)\nexcept Exception as e:\n    if 'not supported when using managed batches' in str(e):\n        return await managed_files.list_user_batches(uak, limit=20)\n    raise","preventionTips":["Wrap batch listing in one helper that strips unsupported kwargs","Keep a matrix of supported filters per managed vs unmanaged mode in your client SDK docs"],"tags":["managed-batches","unsupported-operation","validation","litellm-enterprise"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}