Implementation:Openai Openai python Function Shell Tool
| Knowledge Sources | |
|---|---|
| Domains | API_Types, Responses_API |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete type for defining a shell tool that allows the model to execute shell commands, provided by the openai-python SDK.
Description
FunctionShellTool is a Pydantic model representing a tool definition that grants the model the ability to execute shell commands. It carries a fixed type literal of "shell" and an optional environment field that specifies the execution environment. The environment can be a ContainerAuto, LocalEnvironment, or ContainerReference, discriminated by a type property. This type is auto-generated from the OpenAI OpenAPI specification by Stainless.
Usage
Import FunctionShellTool when configuring tool definitions for a Responses API request that should allow the model to run shell commands in a specified container or local environment.
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/types/responses/function_shell_tool.py
Signature
class FunctionShellTool(BaseModel):
"""A tool that allows the model to execute shell commands."""
type: Literal["shell"]
"""The type of the shell tool. Always `shell`."""
environment: Optional[Environment] = None
Import
from openai.types.responses import FunctionShellTool
I/O Contract
Fields
| Name | Type | Required | Description |
|---|---|---|---|
| type | Literal["shell"] |
Yes | The type of the shell tool. Always "shell".
|
| environment | Optional[Union[ContainerAuto, LocalEnvironment, ContainerReference]] |
No | The execution environment for shell commands, discriminated by type.
|
Usage Examples
from openai.types.responses import FunctionShellTool
# Define a shell tool with default (no explicit) environment
shell_tool = FunctionShellTool(type="shell")
# Include in a Responses API request tools list
response = client.responses.create(
model="gpt-4o",
input="List the files in the current directory",
tools=[shell_tool],
)