Railway
Railway provider for ComputeSDK - Deploy and manage containerized sandboxes on Railway’s infrastructure.
Installation
Section titled “Installation”npm install @computesdk/railwayWith ComputeSDK
Section titled “With ComputeSDK”import { createCompute } from 'computesdk';
import { railway } from '@computesdk/railway';
// Set as default provider
const compute = createCompute({
provider: railway({
apiKey: process.env.RAILWAY_API_KEY,
projectId: process.env.RAILWAY_PROJECT_ID,
environmentId: process.env.RAILWAY_ENVIRONMENT_ID
}),
apiKey: process.env.COMPUTESDK_API_KEY
});
// Create sandbox
const sandbox = await compute.sandbox.create();
// List all sandboxes
const sandboxes = await compute.sandbox.list();
console.log(`Active sandboxes: ${sandboxes.length}`);
// Clean up
await compute.sandbox.destroy(sandbox.sandboxId);Configuration
Section titled “Configuration”Environment Variables
Section titled “Environment Variables”export RAILWAY_API_KEY=your_railway_api_key
export RAILWAY_PROJECT_ID=your_railway_project_id
export RAILWAY_ENVIRONMENT_ID=your_railway_environment_idConfiguration Options
Section titled “Configuration Options”interface RailwayConfig {
/** Railway API key - if not provided, will use RAILWAY_API_KEY env var */
apiKey?: string;
/** Railway Project ID - if not provided, will use RAILWAY_PROJECT_ID env var */
projectId?: string;
/** Railway Environment ID - if not provided, will use RAILWAY_ENVIRONMENT_ID env var */
environmentId?: string;
}Getting Your Railway Credentials
Section titled “Getting Your Railway Credentials”- API Key: Generate a personal API token from Railway Dashboard → Account Settings → Tokens
- Project ID: Found in your Railway project URL:
https://railway.app/project/{PROJECT_ID} - Environment ID: Available in your project’s environment settings
SDK Reference Links:
Section titled “SDK Reference Links:”- Sandbox Management - Create, list, and destroy sandboxes
- Code Execution - Execute code snippets in various runtimes
- Command Execution - Run shell commands and scripts
- Filesystem Operations - Read, write, and manage files in sandboxes
- Error Handling - Handle command failures and runtime errors
Implementation Notes
Section titled “Implementation Notes”- Services are automatically deployed upon creation
- Sandboxes are backed by Railway services in your specified project and environment
- Destroy operations gracefully handle already-deleted services