{"record":{"id":"07a3759fb385f20a","repo":"BerriAI/litellm","slug":"either-model-or-agent-must-be-provided","errorCode":null,"errorMessage":"Either 'model' or 'agent' must be provided","messagePattern":"Either 'model' or 'agent' must be provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/gemini/interactions/transformation.py","lineNumber":154,"sourceCode":"        - ``response_mime_type`` is folded into ``response_format`` and stripped from\n          the body (the field was removed in Api-Revision 2026-05-20).\n        - ``generation_config.image_config`` is moved to a ``response_format`` entry\n          with ``\"type\": \"image\"`` (also removed from generation_config in 2026-05-20).\n\n        When on the legacy schema (use_legacy_interactions_schema=True):\n        - All fields are forwarded as-is.\n        \"\"\"\n        use_legacy: Final[bool] = litellm.use_legacy_interactions_schema\n\n        request_body: Final[dict[str, Any]] = {}\n\n        # Model or Agent (one required)\n        if model:\n            request_body[\"model\"] = GeminiModelInfo.get_base_model(model) or model\n        elif agent:\n            request_body[\"agent\"] = agent\n        else:\n            raise ValueError(\"Either 'model' or 'agent' must be provided\")\n\n        # Input\n        if input is not None:\n            request_body[\"input\"] = input\n\n        # Pass through optional params — legacy schema keeps all fields as-is.\n        optional_keys: Final = [\n            \"tools\",\n            \"system_instruction\",\n            \"stream\",\n            \"store\",\n            \"background\",\n            \"environment\",\n            \"response_modalities\",\n            \"previous_interaction_id\",\n        ]\n        for key in optional_keys:\n            if optional_params.get(key) is not None:","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/gemini/interactions/transformation.py#L136-L172","documentation":"Request validation in GoogleAIStudioInteractionsConfig.transform_request. The Interactions API body must identify either a model or an agent; if both are falsy (None or empty string) the transform raises before any HTTP call. If model is set it is normalized through get_base_model (strips a 'gemini/' prefix); agent is passed through as-is.","triggerScenarios":"litellm.interactions.create(input=...) with both model and agent omitted; passing model='' or agent='' from empty form/config fields; kwargs typos (e.g. model_name=) that leave the real parameters None.","commonSituations":"Config-driven pipelines where the model key is missing in YAML/JSON and code defaults to None; UIs where the user selects neither a model nor an agent; refactors renaming the parameter and silently dropping it.","solutions":["Pass a model: litellm.interactions.create(model='gemini-2.5-flash', input=...)","Or an agent id: litellm.interactions.create(agent='agents/my-agent', input=...)","Validate at your API boundary: reject requests where both model and agent are missing before calling litellm","Check for typos/dead kwargs — misspelled parameters are silently ignored, leaving model=None"],"exampleFix":"# before\nr = litellm.interactions.create(input={'text': 'hi'}, api_key=KEY)\n# ValueError: Either 'model' or 'agent' must be provided\n\n# after\nr = litellm.interactions.create(\n    model=cfg.get('model') or 'gemini-2.5-flash',  # explicit default\n    input={'text': 'hi'},\n    api_key=KEY,\n)","handlingStrategy":"validation","validationCode":"def valid_interaction_target(model: str | None, agent: str | None) -> bool:\n    return bool(model or agent)\n\nassert valid_interaction_target(cfg.get('model'), cfg.get('agent')), \\\n    \"interactions.create requires 'model' or 'agent'\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enforce model-or-agent at the API boundary before calling litellm","Beware silently-ignored misspelled kwargs — they leave model=None","Default to a known-good model in config-driven pipelines"],"tags":["gemini","interactions-api","request-validation","missing-parameter"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}