The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Merge origin/litellm_internal_staging into litellm_/rbac-batches-action-items-c00ade
yassin80081107df00
diff --cc enterprise/litellm_enterprise/proxy/hooks/managed_files.pyindex 27363f45505,570b306d6df..2c5f30456c1--- a/enterprise/litellm_enterprise/proxy/hooks/managed_files.py+++ b/enterprise/litellm_enterprise/proxy/hooks/managed_files.py@@@ -29,14 -46,22 +46,24 @@@ from litellm.proxy._types importUserAPIKeyAuth,)from litellm.proxy.openai_files_endpoints.common_utils import (+ FILE_LIST_CONTINUATION_CHUNK_SIZE,+ MAX_FILE_LIST_LIMIT,_is_base64_encoded_unified_file_id,+ apply_unified_file_ids,+ decode_model_from_file_id,+ ensure_batch_response_managed_file_ids,get_batch_id_from_unified_batch_id,get_content_type_from_file_object,get_model_id_from_unified_batch_id,- get_models_from_unified_file_id,+ get_original_file_id,+ map_raw_file_ids_to_unified,normalize_mime_type_for_provider,+ resolve_managed_output_file_model_name,+ validate_file_list_limit,+ validate_file_list_purpose,+ )+ from litellm.proxy.pass_through_endpoints.llm_provider_handlers.batch_attribution import (+ request_tags_from_metadata,)from litellm.types.llms.openai import ( # pyright: ignore[reportAttributeAccessIssue]AllMessageValues,@@@ -184,27 -306,6 +308,7 @@@ class _PROXY_LiteLLMManagedFiles(Customfile_purpose=file_purpose,file_object=file_object,)+- if update_only:- updated_count = (- await self.prisma_client.db.litellm_managedobjecttable.update_many(- where={"unified_object_id": unified_object_id},- data={- "file_object": file_object.model_dump_json(),- "status": file_object.status,- "updated_by": user_api_key_dict.user_id,- },- )- )- if updated_count == 0:- return- await self.internal_usage_cache.async_set_cache(- key=unified_object_id,- value=litellm_managed_object.model_dump(),- litellm_parent_otel_span=litellm_parent_otel_span,- )- return-await self.internal_usage_cache.async_set_cache(key=unified_object_id,value=litellm_managed_object.model_dump(),@@@ -524,15 -609,9 +709,13 @@@status_code=403,detail=f"User {user_api_key_dict.user_id} does not have access to the file {retrieve_file_id}",)+ if retrieve_file_id:+ await self.enforce_provider_file_access(+ retrieve_file_id, user_api_key_dict+ )return False- async def check_file_ids_access(- self, file_ids: List[str], user_api_key_dict: UserAPIKeyAuth- ) -> None:+ async def check_file_ids_access(self, file_ids: List[str], user_api_key_dict: UserAPIKeyAuth) -> None:"""Check if the user has access to a list of file IDs.Only checks managed (unified) file IDs.@@@ -708,13 -760,7 +864,9 @@@f"LiteLLM Managed {accessor_key} with id={retrieve_object_id} is invalid - does not contain encoded model_id.")data["model"] = potential_model_id- data[accessor_key] = get_batch_id_from_unified_batch_id(- potential_llm_object_id- )+ data[accessor_key] = get_batch_id_from_unified_batch_id(potential_llm_object_id)+ elif retrieve_object_id and accessor_key == "batch_id":- await self.enforce_batch_object_access(- retrieve_object_id, user_api_key_dict- )++ await self.enforce_batch_object_access(retrieve_object_id, user_api_key_dict)elif call_type == CallTypes.acreate_fine_tuning_job.value:input_file_id = cast(Optional[str], data.get("training_file"))if input_file_id:@@@ -1326,13 -1291,9 +1397,15 @@@model_object_id=original_response_id,file_purpose="batch",user_api_key_dict=user_api_key_dict,- update_only=not is_batch_create,+ request_tags=request_tags_from_metadata(request_metadata if isinstance(request_metadata, dict) else {}),+ persist_attribution=is_batch_create,++ create_if_missing=is_batch_create,)+ if not is_batch_create:+ await self.store_batch_output_file_ownership(+ response=response,+ litellm_parent_otel_span=user_api_key_dict.parent_otel_span,+ )# Only record batch creation metric on actual create (not retrieve/cancel).# unified_file_id in _hidden_params is only set by the create_batch endpoint.diff --cc tests/enterprise/litellm_enterprise/proxy/hooks/test_managed_files.pyindex 49d7a53d40a,e7d7fdaef81..e3025255518--- a/tests/enterprise/litellm_enterprise/proxy/hooks/test_managed_files.py+++ b/tests/enterprise/litellm_enterprise/proxy/hooks/test_managed_files.py@@@ -2370,412 -3153,143 +3154,558 @@@ async def test_same_user_different_keysassert result1["batch_id"] == result2["batch_id"]+MODEL_ENCODED_BATCH_ID = encode_file_id_with_model(+ "batch_provider123", "gpt-4o-team-alias", id_type="batch"+)+MODEL_ENCODED_OUTPUT_FILE_ID = encode_file_id_with_model(+ "file-output456", "gpt-4o-team-alias", id_type="file"+)+RAW_PROVIDER_BATCH_ID = "batch_provider123"+RAW_PROVIDER_FILE_ID = "file-output456"+++def _owned_record(created_by, team_id):+ record = MagicMock()+ record.created_by = created_by+ record.team_id = team_id+ return record++- def _batch_response(batch_id, output_file_id=None):++def _batch_response(batch_id, output_file_id=None, is_create=False):+ from litellm.types.utils import LiteLLMBatch+- return LiteLLMBatch(++ batch = LiteLLMBatch(+ id=batch_id,+ completion_window="24h",+ created_at=1700000000,+ endpoint="/v1/chat/completions",+ input_file_id="file-input789",+ object="batch",+ status="completed",+ output_file_id=output_file_id,+ )++ if is_create:++ batch._hidden_params["unified_file_id"] = "unified-input-file-id"++ return batch++[email protected]("call_type", ["aretrieve_batch", "acancel_batch"])+ "batch_id", [MODEL_ENCODED_BATCH_ID, RAW_PROVIDER_BATCH_ID]+)+async def test_team_b_cannot_access_team_a_provider_format_batch(+ call_type, batch_id+):+ """+ Cross-team retrieve/cancel of a model-encoded or raw provider batch id+ must 403 when an ownership row exists for another team.++ Regression test: before this check only unified (litellm_proxy-prefixed)+ batch ids were enforced, so any key could read any model-encoded or raw+ provider batch.+ """+ from litellm.proxy._types import UserAPIKeyAuth++ prisma_client = AsyncMock()+ prisma_client.db.litellm_managedobjecttable.find_first.return_value = (+ _owned_record(created_by="user_a", team_id="team_a")+ )+ proxy_managed_files = _PROXY_LiteLLMManagedFiles(+ DualCache(), prisma_client=prisma_client+ )++ with pytest.raises(HTTPException) as exc_info:+ await proxy_managed_files.async_pre_call_hook(+ user_api_key_dict=UserAPIKeyAuth(+ user_id="user_b", team_id="team_b", parent_otel_span=MagicMock()+ ),+ cache=MagicMock(),+ data={"batch_id": batch_id},+ call_type=call_type,+ )++ assert exc_info.value.status_code == 403+ prisma_client.db.litellm_managedobjecttable.find_first.assert_awaited_once_with(+ where={"unified_object_id": batch_id}+ )+++ "caller_kwargs",+ [+ {"user_id": "user_a", "team_id": "team_a"},+ {"user_id": "teammate_of_a", "team_id": "team_a"},+ {"user_id": "admin_user", "user_role": "proxy_admin"},+ ],+)+async def test_authorized_callers_can_access_provider_format_batch(caller_kwargs):+ """+ The creator, a same-team member, and a proxy admin can all retrieve a+ model-encoded batch owned by team_a. Data must pass through unmodified so+ the endpoint's own routing still applies.+ """+ from litellm.proxy._types import UserAPIKeyAuth++ prisma_client = AsyncMock()+ prisma_client.db.litellm_managedobjecttable.find_first.return_value = (+ _owned_record(created_by="user_a", team_id="team_a")+ )+ proxy_managed_files = _PROXY_LiteLLMManagedFiles(+ DualCache(), prisma_client=prisma_client+ )++ result = await proxy_managed_files.async_pre_call_hook(+ user_api_key_dict=UserAPIKeyAuth(+ parent_otel_span=MagicMock(), **caller_kwargs+ ),+ cache=MagicMock(),+ data={"batch_id": MODEL_ENCODED_BATCH_ID},+ call_type="aretrieve_batch",+ )++ assert result["batch_id"] == MODEL_ENCODED_BATCH_ID+ assert "model" not in result+++async def test_provider_format_batch_without_ownership_row_stays_accessible():+ """+ A provider-format batch id with no ownership row (created before ownership+ tracking, or directly on the provider account) must stay retrievable.+ """+ from litellm.proxy._types import UserAPIKeyAuth++ prisma_client = AsyncMock()+ prisma_client.db.litellm_managedobjecttable.find_first.return_value = None+ proxy_managed_files = _PROXY_LiteLLMManagedFiles(+ DualCache(), prisma_client=prisma_client+ )++ result = await proxy_managed_files.async_pre_call_hook(+ user_api_key_dict=UserAPIKeyAuth(+ user_id="user_b", team_id="team_b", parent_otel_span=MagicMock()+ ),+ cache=MagicMock(),+ data={"batch_id": RAW_PROVIDER_BATCH_ID},+ call_type="aretrieve_batch",+ )++ assert result["batch_id"] == RAW_PROVIDER_BATCH_ID+++async def test_fine_tuning_provider_format_id_not_enforced():+ """+ Provider-format fine-tuning job ids are deliberately out of scope for+ ownership enforcement; only unified fine-tuning ids are checked.+ """+ from litellm.proxy._types import UserAPIKeyAuth++ prisma_client = AsyncMock()+ prisma_client.db.litellm_managedobjecttable.find_first.return_value = (+ _owned_record(created_by="user_a", team_id="team_a")+ )+ proxy_managed_files = _PROXY_LiteLLMManagedFiles(+ DualCache(), prisma_client=prisma_client+ )++ result = await proxy_managed_files.async_pre_call_hook(+ user_api_key_dict=UserAPIKeyAuth(+ user_id="user_b", team_id="team_b", parent_otel_span=MagicMock()+ ),+ cache=MagicMock(),+ data={"fine_tuning_job_id": "ftjob-abc123"},+ call_type="aretrieve_fine_tuning_job",+ )++ assert result["fine_tuning_job_id"] == "ftjob-abc123"+ prisma_client.db.litellm_managedobjecttable.find_first.assert_not_awaited()+++ "call_type", ["afile_content", "afile_retrieve", "afile_delete"]+)+ "file_id", [MODEL_ENCODED_OUTPUT_FILE_ID, RAW_PROVIDER_FILE_ID]+)+async def test_team_b_cannot_access_team_a_provider_format_file(+ call_type, file_id+):+ """+ Cross-team content/retrieve/delete of a model-encoded or raw provider+ file id must 403 when an ownership row exists for another team.+ """+ from litellm.proxy._types import UserAPIKeyAuth++ prisma_client = AsyncMock()+ prisma_client.db.litellm_managedfiletable.find_first.return_value = (+ _owned_record(created_by="user_a", team_id="team_a")+ )+ proxy_managed_files = _PROXY_LiteLLMManagedFiles(+ MagicMock(), prisma_client=prisma_client+ )++ with pytest.raises(HTTPException) as exc_info:+ await proxy_managed_files.async_pre_call_hook(+ user_api_key_dict=UserAPIKeyAuth(+ user_id="user_b", team_id="team_b", parent_otel_span=MagicMock()+ ),+ cache=MagicMock(),+ data={"file_id": file_id},+ call_type=call_type,+ )++ assert exc_info.value.status_code == 403+ prisma_client.db.litellm_managedfiletable.find_first.assert_awaited_once_with(+ where={"unified_file_id": file_id}+ )+++async def test_same_team_can_access_provider_format_file():+ from litellm.proxy._types import UserAPIKeyAuth++ prisma_client = AsyncMock()+ prisma_client.db.litellm_managedfiletable.find_first.return_value = (+ _owned_record(created_by="user_a", team_id="team_a")+ )+ proxy_managed_files = _PROXY_LiteLLMManagedFiles(+ MagicMock(), prisma_client=prisma_client+ )++ result = await proxy_managed_files.async_pre_call_hook(+ user_api_key_dict=UserAPIKeyAuth(+ user_id="teammate_of_a", team_id="team_a", parent_otel_span=MagicMock()+ ),+ cache=MagicMock(),+ data={"file_id": MODEL_ENCODED_OUTPUT_FILE_ID},+ call_type="afile_content",+ )++ assert result["file_id"] == MODEL_ENCODED_OUTPUT_FILE_ID+++async def test_provider_format_file_without_ownership_row_stays_accessible():+ from litellm.proxy._types import UserAPIKeyAuth++ prisma_client = AsyncMock()+ prisma_client.db.litellm_managedfiletable.find_first.return_value = None+ proxy_managed_files = _PROXY_LiteLLMManagedFiles(+ MagicMock(), prisma_client=prisma_client+ )++ result = await proxy_managed_files.async_pre_call_hook(+ user_api_key_dict=UserAPIKeyAuth(+ user_id="user_b", team_id="team_b", parent_otel_span=MagicMock()+ ),+ cache=MagicMock(),+ data={"file_id": RAW_PROVIDER_FILE_ID},+ call_type="afile_content",+ )++ assert result["file_id"] == RAW_PROVIDER_FILE_ID+++async def test_post_call_batch_create_stores_ownership_row():+ """- Batch creation (request data carries completion_window/input_file_id)++ Batch creation (response hidden params carry the unified input file id)+ must write an ownership row attributed to the creating key.+ """+ from litellm.proxy._types import UserAPIKeyAuth++ prisma_client = AsyncMock()+ proxy_managed_files = _PROXY_LiteLLMManagedFiles(+ MagicMock(async_set_cache=AsyncMock()), prisma_client=prisma_client+ )++ await proxy_managed_files.async_post_call_success_hook(+ data={+ "input_file_id": "file-input789",+ "endpoint": "/v1/chat/completions",+ "completion_window": "24h",+ },+ user_api_key_dict=UserAPIKeyAuth(+ user_id="user_a", team_id="team_a", parent_otel_span=MagicMock()+ ),- response=_batch_response(MODEL_ENCODED_BATCH_ID),++ response=_batch_response(MODEL_ENCODED_BATCH_ID, is_create=True),+ )++ upsert_call = prisma_client.db.litellm_managedobjecttable.upsert.await_args+ assert upsert_call.kwargs["where"] == {+ "unified_object_id": MODEL_ENCODED_BATCH_ID+ }+ create_data = upsert_call.kwargs["data"]["create"]+ assert create_data["created_by"] == "user_a"+ assert create_data["team_id"] == "team_a"+ prisma_client.db.litellm_managedobjecttable.update_many.assert_not_awaited()+++async def test_post_call_batch_sync_does_not_claim_ownership():+ """+ Retrieve/cancel of a batch with no ownership row must NOT create one:+ otherwise the first foreign key to touch a legacy batch would become its+ owner and lock out the real creator once enforcement is on.+ """+ from litellm.proxy._types import UserAPIKeyAuth++ prisma_client = AsyncMock()+ prisma_client.db.litellm_managedobjecttable.update_many.return_value = 0- internal_usage_cache = MagicMock(async_set_cache=AsyncMock())+ proxy_managed_files = _PROXY_LiteLLMManagedFiles(- internal_usage_cache, prisma_client=prisma_client++ MagicMock(async_set_cache=AsyncMock()), prisma_client=prisma_client+ )++ await proxy_managed_files.async_post_call_success_hook(+ data={"batch_id": MODEL_ENCODED_BATCH_ID},+ user_api_key_dict=UserAPIKeyAuth(+ user_id="user_b", team_id="team_b", parent_otel_span=MagicMock()+ ),+ response=_batch_response(MODEL_ENCODED_BATCH_ID),+ )++ prisma_client.db.litellm_managedobjecttable.upsert.assert_not_awaited()- internal_usage_cache.async_set_cache.assert_not_awaited()++ prisma_client.db.litellm_managedobjecttable.update_many.assert_awaited_once()+++async def test_post_call_batch_sync_updates_existing_row():+ from litellm.proxy._types import UserAPIKeyAuth++ prisma_client = AsyncMock()+ prisma_client.db.litellm_managedobjecttable.update_many.return_value = 1+ prisma_client.db.litellm_managedobjecttable.find_first.return_value = (+ _owned_record(created_by="user_a", team_id="team_a")+ )+ proxy_managed_files = _PROXY_LiteLLMManagedFiles(+ MagicMock(async_set_cache=AsyncMock()), prisma_client=prisma_client+ )++ await proxy_managed_files.async_post_call_success_hook(+ data={"batch_id": MODEL_ENCODED_BATCH_ID},+ user_api_key_dict=UserAPIKeyAuth(+ user_id="user_a", team_id="team_a", parent_otel_span=MagicMock()+ ),+ response=_batch_response(MODEL_ENCODED_BATCH_ID),+ )++ update_call = prisma_client.db.litellm_managedobjecttable.update_many.await_args+ assert update_call.kwargs["where"] == {+ "unified_object_id": MODEL_ENCODED_BATCH_ID+ }+ assert update_call.kwargs["data"]["status"] == "completed"+ prisma_client.db.litellm_managedobjecttable.upsert.assert_not_awaited()+++async def test_post_call_batch_sync_stores_output_file_ownership_from_batch_row():+ """+ When a synced batch reports a provider-format output file id, an+ ownership row for that file must be written with the BATCH row's+ created_by/team_id, not the caller's identity.+ """+ from litellm.proxy._types import UserAPIKeyAuth++ prisma_client = AsyncMock()+ prisma_client.db.litellm_managedobjecttable.update_many.return_value = 1+ prisma_client.db.litellm_managedobjecttable.find_first.return_value = (+ _owned_record(created_by="user_a", team_id="team_a")+ )+ proxy_managed_files = _PROXY_LiteLLMManagedFiles(+ MagicMock(async_set_cache=AsyncMock()), prisma_client=prisma_client+ )++ await proxy_managed_files.async_post_call_success_hook(+ data={"batch_id": MODEL_ENCODED_BATCH_ID},+ user_api_key_dict=UserAPIKeyAuth(+ user_id="admin_user",+ user_role="proxy_admin",+ parent_otel_span=MagicMock(),+ ),+ response=_batch_response(+ MODEL_ENCODED_BATCH_ID, output_file_id=MODEL_ENCODED_OUTPUT_FILE_ID+ ),+ )++ file_upsert = prisma_client.db.litellm_managedfiletable.upsert.await_args+ assert file_upsert.kwargs["where"] == {+ "unified_file_id": MODEL_ENCODED_OUTPUT_FILE_ID+ }+ create_data = file_upsert.kwargs["data"]["create"]+ assert create_data["created_by"] == "user_a"+ assert create_data["team_id"] == "team_a"+ assert create_data["flat_model_file_ids"] == ["file-output456"]+++async def test_post_call_batch_create_does_not_store_output_file_ownership():+ from litellm.proxy._types import UserAPIKeyAuth++ prisma_client = AsyncMock()+ proxy_managed_files = _PROXY_LiteLLMManagedFiles(+ MagicMock(async_set_cache=AsyncMock()), prisma_client=prisma_client+ )++ await proxy_managed_files.async_post_call_success_hook(+ data={+ "input_file_id": "file-input789",+ "endpoint": "/v1/chat/completions",+ "completion_window": "24h",+ },+ user_api_key_dict=UserAPIKeyAuth(+ user_id="user_a", team_id="team_a", parent_otel_span=MagicMock()+ ),+ response=_batch_response(- MODEL_ENCODED_BATCH_ID, output_file_id=MODEL_ENCODED_OUTPUT_FILE_ID++ MODEL_ENCODED_BATCH_ID,++ output_file_id=MODEL_ENCODED_OUTPUT_FILE_ID,++ is_create=True,+ ),+ )++ prisma_client.db.litellm_managedfiletable.upsert.assert_not_awaited()+++++ @pytest.mark.asyncio+ async def test_file_list_cursors_are_scoped_to_the_caller():+ """A non-owner must not learn other callers' file ids through the page cursors."""+ from openai.pagination import AsyncCursorPage+ from openai.types import FileObject++ from litellm.proxy._types import UserAPIKeyAuth++ owner_file = FileObject(+ id="file-owner-1",+ bytes=100,+ created_at=1,+ filename="owner.jsonl",+ object="file",+ purpose="batch",+ status="processed",+ )+ upstream_page = AsyncCursorPage[FileObject].construct(+ data=[owner_file],+ has_more=True,+ first_id=owner_file.id,+ last_id=owner_file.id,+ object="list",+ )++ prisma_client = AsyncMock()+ prisma_client.db.litellm_managedfiletable.find_many.return_value = []+ proxy_managed_files = _PROXY_LiteLLMManagedFiles(+ DualCache(), prisma_client=prisma_client+ )++ response = await proxy_managed_files.async_post_call_success_hook(+ data={},+ user_api_key_dict=UserAPIKeyAuth(+ user_id="other-user", team_id="other-team", parent_otel_span=MagicMock()+ ),+ response=upstream_page,+ )++ assert response.data == []+ assert response.first_id is None+ assert response.last_id is None+ assert response.has_more is False+++ @pytest.mark.asyncio+ async def test_file_list_cursors_follow_the_owner_scoped_page():+ from openai.pagination import AsyncCursorPage+ from openai.types import FileObject++ from litellm.proxy._types import UserAPIKeyAuth++ def _raw_file(file_id: str) -> FileObject:+ return FileObject(+ id=file_id,+ bytes=100,+ created_at=1,+ filename=f"{file_id}.jsonl",+ object="file",+ purpose="batch",+ status="processed",+ )++ upstream_page = AsyncCursorPage[FileObject].construct(+ data=[_raw_file("file-someone-else"), _raw_file("file-mine")],+ has_more=True,+ first_id="file-someone-else",+ last_id="file-mine",+ object="list",+ )++ managed_row = MagicMock()+ managed_row.unified_file_id = "litellm_proxy:mine"+ managed_row.file_object = {+ "id": "file-mine",+ "bytes": 100,+ "created_at": 1,+ "filename": "mine.jsonl",+ "object": "file",+ "purpose": "batch",+ "status": "processed",+ }+ prisma_client = AsyncMock()+ prisma_client.db.litellm_managedfiletable.find_many.return_value = [managed_row]+ proxy_managed_files = _PROXY_LiteLLMManagedFiles(+ DualCache(), prisma_client=prisma_client+ )++ response = await proxy_managed_files.async_post_call_success_hook(+ data={},+ user_api_key_dict=UserAPIKeyAuth(+ user_id="mine-user", parent_otel_span=MagicMock()+ ),+ response=upstream_page,+ )++ assert [file_object.id for file_object in response.data] == ["litellm_proxy:mine"]+ assert response.first_id == "litellm_proxy:mine"+ assert response.last_id == "litellm_proxy:mine"+ assert response.has_more is False+++ @pytest.mark.asyncio+ async def test_list_user_batches_provider_filter_rejected_with_400():+ from litellm.proxy._types import ProxyException, UserAPIKeyAuth++ proxy_managed_files = _PROXY_LiteLLMManagedFiles(+ DualCache(), prisma_client=MagicMock()+ )++ with pytest.raises(ProxyException) as exc:+ await proxy_managed_files.list_user_batches(+ user_api_key_dict=UserAPIKeyAuth(user_id="123"),+ provider="openai",+ )++ assert exc.value.code == "400"+ assert exc.value.type == "invalid_request_error"+ assert exc.value.param == "provider"+ assert exc.value.message == "Filtering by 'provider' is not supported when using managed batches."+++ @pytest.mark.asyncio+ async def test_list_user_batches_target_model_names_filter_rejected_with_400():+ from litellm.proxy._types import ProxyException, UserAPIKeyAuth++ proxy_managed_files = _PROXY_LiteLLMManagedFiles(+ DualCache(), prisma_client=MagicMock()+ )++ with pytest.raises(ProxyException) as exc:+ await proxy_managed_files.list_user_batches(+ user_api_key_dict=UserAPIKeyAuth(user_id="123"),+ target_model_names="gpt-4o",+ )++ assert exc.value.code == "400"+ assert exc.value.type == "invalid_request_error"+ assert exc.value.param == "target_model_names"+ assert exc.value.message == "Filtering by 'target_model_names' is not supported when using managed batches."