# CodeInterpreterTool

> **Class** in `langchain_azure_ai`

📖 [View in docs](https://reference.langchain.com/python/langchain-azure-ai/tools/builtin/_tools/CodeInterpreterTool)

A tool that runs Python code server-side to help generate a response.

The model can write and execute Python code within a sandboxed container
and include the results in its response.

Wraps :class:`openai.types.responses.tool_param.CodeInterpreter`.

Example::

    from langchain.chat_models import init_chat_model
    from langchain_azure_ai.tools.builtin import CodeInterpreterTool
    from azure.identity import DefaultAzureCredential

    credential = DefaultAzureCredential()
    model = init_chat_model(model="azure_ai:gpt-4.1", credential=credential)
    tool = CodeInterpreterTool()
    model_with_code = model.bind_tools([tool])
    response = model_with_code.invoke("Plot a sine wave using Python")

## Signature

```python
CodeInterpreterTool(
    self,
    *,
    file_ids: Optional[List[str]] = None,
    memory_limit: Optional[str] = None,
    network_policy: Optional[Dict] = None,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_ids` | `Optional[List[str]]` | No | Optional list of uploaded file IDs to make available inside the container. (default: `None`) |
| `memory_limit` | `Optional[str]` | No | Memory limit for the container.  Accepted values are ``"1g"``, ``"4g"``, ``"16g"``, and ``"64g"``. (default: `None`) |
| `network_policy` | `Optional[Dict]` | No | Network access policy for the container.  .. seealso::     :class:`~openai.types.responses.     tool_param.CodeInterpreterContainerCodeInterpreterToolAutoNetworkPolicy` (default: `None`) |

## Extends

- `BuiltinTool`

## Constructors

```python
__init__(
    self,
    *,
    file_ids: Optional[List[str]] = None,
    memory_limit: Optional[str] = None,
    network_policy: Optional[Dict] = None,
) -> None
```

| Name | Type |
|------|------|
| `file_ids` | `Optional[List[str]]` |
| `memory_limit` | `Optional[str]` |
| `network_policy` | `Optional[Dict]` |


---

[View source on GitHub](https://github.com/langchain-ai/langchain-azure/blob/7a6a664d617264df8dcb12fcfb1bacc09f21d504/libs/azure-ai/langchain_azure_ai/tools/builtin/_tools.py#L99)