> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ag2.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# autogen.import_utils.require_optional_import

<code class="doc-symbol doc-symbol-heading doc-symbol-function" />

#### require\_optional\_import

```python theme={null}
require_optional_import(
    modules: str | Iterable[str],
    dep_target: str,
    *,
    except_for: str | Iterable[str] | None = None
) -> Callable[[~T], ~T]
```

Decorator to handle optional module dependencies

<b>Parameters:</b>

| Name         | Description                                                                                                                               |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `modules`    | Module name or list of module names required<br /><br />**Type:** str \| Iterable\[str]                                                   |
| `dep_target` | Target name for pip installation (e.g.<br /><br />'test' in pip install ag2\[test])<br /><br />**Type:** str                              |
| `except_for` | Name or list of names of objects to exclude from patching<br /><br />**Type:** str \| Iterable\[str] \| None<br /><br />**Default:** None |

<br />
