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

# Code interpreter server tool

> Run Python in an isolated sandbox during a model response with the orq:code_interpreter server tool.

The `orq:code_interpreter` tool runs Python in an isolated, workspace-scoped sandbox. It is suited to calculations, data transformation, parsing, and other tasks where executing code is more reliable than reasoning in text.

## Quick start

The examples use the client configuration from the [Server tools overview](/docs/ai-gateway/features/server-tools).

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X POST https://api.orq.ai/v3/router/chat/completions \
    -H "Authorization: Bearer $ORQ_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "openai/gpt-5.4-mini",
      "messages": [
        { "role": "user", "content": "Calculate the compound annual growth rate from 4.2 million to 7.1 million over five years." }
      ],
      "tools": [
        { "type": "orq:code_interpreter" }
      ]
    }'
  ```

  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const response = await client.chat.completions.create({
    model: 'openai/gpt-5.4-mini',
    messages: [
      {
        role: 'user',
        content:
          'Calculate the compound annual growth rate from 4.2 million to 7.1 million over five years.',
      },
    ],
    tools: [{ type: 'orq:code_interpreter' }] as any,
  });

  console.log(response.choices[0].message.content);
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  response = client.chat.completions.create(
      model="openai/gpt-5.4-mini",
      messages=[
          {
              "role": "user",
              "content": "Calculate the compound annual growth rate from 4.2 million to 7.1 million over five years.",
          }
      ],
      tools=[{"type": "orq:code_interpreter"}],
  )

  print(response.choices[0].message.content)
  ```
</CodeGroup>

The model writes the Python code. A value assigned to `result` and anything written to standard output are returned to the model.

## Configuration

| Parameter           | Type      | Required | Default    | Description                                                                                                  |
| ------------------- | --------- | -------- | ---------- | ------------------------------------------------------------------------------------------------------------ |
| `type`              | string    | Yes      |            | Must be `orq:code_interpreter`.                                                                              |
| `files`             | object\[] | No       | None       | Workspace files to stage in `/workspace`. Maximum: 10 files.                                                 |
| `files[].file_id`   | string    | Yes      |            | Workspace file ID.                                                                                           |
| `files[].name`      | string    | Yes      |            | File name exposed in `/workspace`. Names must be unique and may contain letters, numbers, `.`, `_`, and `-`. |
| `network.mode`      | string    | No       | `disabled` | Network policy intent. Accepted values are `disabled` and `allowlist`.                                       |
| `network.allowlist` | string\[] | No       | None       | Bare hostnames or IPv4 addresses. Required when mode is `allowlist`. Maximum: 50 entries.                    |

Each staged file can be up to 10 MB.

<Note>
  Network settings are accepted and validated, but sandbox egress enforcement is
  still rolling out. Sandbox executions retain the deployment's default public
  internet access until enforcement is enabled.
</Note>

## Availability and usage

The deployment must have sandbox infrastructure configured. When it is unavailable, the model receives a tool error instead of a Python result.

Code interpreter has no separate server-tool charge in this release. The number of sessions appears at `usage.server_tool_use.code_interpreter_sessions`.
