BetaServer tools are currently in beta. The API and behavior may change.Sandbox containers work on the global endpoint (
openrouter.ai) only.
Requests through the
in-region endpoints
(eu.openrouter.ai, us.openrouter.ai) return an error.Container ids
Every container has an id. The id can be set in the server tool’senvironment configuration. Shell and bash tool results return the id in
their container_id field. There are two modes of configuring the container,
container_auto and container_reference:
Automatic ids (container_auto)
This is the default when you omit environment. The id depends on your
request:
- When the request has a session id, the container id is
sess_plus the session id. All requests with the same session id share one container. - When the request has no session id, the container id is
gen_plus a hash of the request id. Each request gets its own container.
- The
session_idfield in the request body. - The
x-session-idrequest header. - The
prompt_cache_keyfield in the request body.
_, and -. An id with other
characters is ignored, and the request falls back to a per-request
container. When the session id is longer than 20 characters, only the last
20 characters are used.
Your own ids (container_reference)
With container_reference, you can pass a container_id from another
session, or pass a custom container id. The id must be 1 to
40 characters and use only letters, digits, _, and -. Every request with
the same id reaches the same container and the same files.
Containers are scoped to your workspace. Two workspaces can use the same id
without seeing each other’s files.
One id, two tools
The shell tool and the bash tool use separate compute environments, even for the same container id. They share the same saved files.Container lifetime
A container sleeps after it has been idle. Thesleep_after_seconds
setting controls the idle time:
- The default is 900 seconds (15 minutes).
- The maximum is 14,400 seconds (4 hours).
- Each command resets the timer.
File persistence
Commands run in/home/sandbox, which is also the home directory. After
every command, the changed files under the home directory are saved to
storage. Deleted files stay deleted. Files outside the home directory are
not saved.
Each tool result reports the files the command created or changed, in the
files field:
Attach workspace files
You can copy files from your workspace into a container before the first command runs. First upload the files with the Files API. Then pass their ids in thefile_ids field of the container environment:
- You can attach up to 20 files.
- Each file appears in the home directory as a writable copy. The copy is
named with the last 8 characters of the file id, a
-, and the base filename. A file stored asdata/report.csvwith an id ending inNR6q4V8wappears as~/NR6q4V8w-report.csv. This prefix keeps two files with the same name apart. - The copy is independent. Changes inside the container do not change the workspace file.
- An unknown or malformed file id fails the request with a
400error before any command runs.
Download container files
Files created inside a container can be downloaded through the container files endpoints. List the files in a container:GET /api/v1/containers/{container_id}/fileslists the files. Thelimitparameter sets the page size, from 1 to 1000 (default 100). Use theafterparameter with a file id to get the next page.GET /api/v1/containers/{container_id}/files/{file_id}returns the metadata of one file.GET /api/v1/containers/{container_id}/files/{file_id}/contentstreams the file content.
cfile_. They encode the file path, and they
match the file_id values in the tool result’s files field.
Save a container file to your workspace
Container files live with the container. To keep a file for the long term, promote it to a workspace document:POST /api/v1/containers/{container_id}/files/{file_id}/promote copies the
file into your workspace documents. The response is the new document in the
Files API shape, with a new or_file_ id. You
can then use the new id like any uploaded file, for example in
file_ids.
Rules:
- The copy is independent. The container file stays in the container, and later changes to it do not change the document.
- The document keeps the container file path as its filename.
- Files larger than 100 MiB return a
413error. - Any content the sandbox produced is accepted. The file type is read from the content; unknown content is stored as binary data.
- Like uploaded files, the new document cannot be downloaded through the Files API. Download the container file through the content endpoint first if you need the bytes.
Network access
By default, a container has no outbound internet access. Thenetwork_policy setting can allow specific domains. See the
shell network policy
and bash network policy
sections.