For the complete documentation index, see llms.txt. This page is also available as Markdown.

Railway

Railway provider for ComputeSDK — run commands in Railway Sandboxes, ephemeral compute environments backed by the Railway platform.

Installation & Setup

npm install @computesdk/railway

Requires Node.js >= 22 — the underlying railway SDK depends on Node 22 APIs (e.g. global WebSocket).

Add your Railway credentials to a .env file:

RAILWAY_API_TOKEN=your_token
RAILWAY_ENVIRONMENT_ID=your_environment_id

Create the token at railway.com/account/tokens; find the environment ID under your Railway project's environment settings.

Usage

import { railway } from '@computesdk/railway';

const compute = railway({
  token: process.env.RAILWAY_API_TOKEN,
  environmentId: process.env.RAILWAY_ENVIRONMENT_ID,
});

// Create sandbox
const sandbox = await compute.sandbox.create();

// Run a command
const result = await sandbox.runCommand('echo "Hello from Railway!"');
console.log(result.stdout); // "Hello from Railway!"

// Clean up
await sandbox.destroy();

Configuration Options

Supported Operations

Method
Supported
Notes

create

Creates a Railway sandbox. Honors envs, idleTimeoutMinutes, and networkIsolation create options.

getById

Returns null when the sandbox is not found.

list

Connects to each listed sandbox; unreachable ones are dropped.

destroy

Best-effort; ignores already-destroyed / unreachable sandboxes.

runCommand

Runs via Railway's sandbox.exec. A signal-terminated command reports exit code -1.

getInfo

getUrl

Throws — Railway sandboxes cannot expose ports / public URLs. Use sandbox-to-sandbox networking within a Railway environment instead.

filesystem

Implemented over the shell (base64, ls -la, mkdir -p, rm -rf, etc.).

Notes

  • Railway has no dedicated filesystem or port-exposure API, so getUrl throws and filesystem operations are shell-backed.

Last updated

Was this helpful?