> ## Documentation Index
> Fetch the complete documentation index at: /docs/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.md).

```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST https://router.toqan.ai/eu/v3/router/chat/completions \
  -H "Authorization: Bearer $TOQAN_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)
```

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.

## Availability and usage

Each execution times out after 60 seconds.

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`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.