BetaServer tools are currently in beta. The API and behavior may change.
openrouter:shell server tool gives a model a hosted shell — a sandbox-backed clone of OpenAI’s hosted shell tool that works with any model. When the model needs to run commands, it emits a shell call; OpenRouter executes the commands server-side in an isolated Linux container and returns each command’s stdout, stderr, and exit or timeout outcome.
Unlike the Bash tool, the shell tool has no client-side execution mode: commands always run in a hosted environment, either OpenAI’s native shell or OpenRouter’s sandbox.
How It Works
- You include
{ "type": "openrouter:shell" }in yourtoolsarray on a Responses API request. You can also send OpenAI’s nativeshelltool shape — on non-OpenAI models it is routed to the OpenRouter sandbox automatically. - Based on the prompt, the model decides to run one or more shell commands and emits a shell call.
- OpenRouter executes the commands in order, each in its own invocation, inside a sandboxed container.
- Each command’s
stdout,stderr, and outcome (exit code or timeout) are returned to the model. - The model incorporates the results and may run further command batches in the same request.
Quick Start
Configuration
The shell tool accepts optionalparameters to choose its execution engine and environment:
Defaults and caps reflect current server-enforced limits and may change while the tool is in beta.
Call Arguments
The model generates the call arguments, mirroring OpenAI’s hosted shellshell_call.action:
OpenAI native shell tool
On the Responses API you can also send OpenAI’s native tool shape ({ "type": "shell" }, or the legacy Codex local_shell) instead of openrouter:shell. On OpenAI models this uses OpenAI’s own hosted shell; on any other model, OpenRouter routes the call to its sandbox transparently. The response emits the native shell_call output item either way.
Response Format
The tool returns one entry per command, matching OpenAI’sshell_call_output.output[]:
outcome is either { "type": "exit", "exit_code": <int> } or { "type": "timeout" }. A non-zero exit code indicates the command failed; the error output is returned on stderr so the model can read and react to it.
Security
Shell execution is sandboxed by design:- Commands execute in an isolated container — not on OpenRouter infrastructure or your machine. With
container_autothe container is ephemeral; withcontainer_referenceit persists across requests. - Containers are scoped per account and workspace, so they are never shared across tenants.
- Execution time is bounded by
timeout_ms(clamped to a server-side maximum). stdoutandstderrare each truncated tomax_output_length(a per-stream cap, itself clamped to a server-side maximum).
Next Steps
- Server Tools Overview — Learn about server tools
- Bash — Sandboxed shell for the Anthropic Messages API
- Tool Calling — Learn about user-defined tool calling