Create an RL training environment
Creates a reinforcement learning environment for training agents. Links to an existing simulation and configures episode parameters.
This endpoint works with simulations built on any supported provider, including AWS, GCP, Azure, OCI, and DigitalOcean. Training an agent against a DigitalOcean simulation lets you learn optimal autoscaling strategies for Droplet-based workloads, Managed Database failover handling, and multi-datacenter traffic routing — all without incurring real cloud costs. The observation space, action space, and reward function are identical regardless of provider.
Idle TTL: Authenticated RL environments expire after 2 hours of inactivity (no step or reset call received). Expired environments and their linked simulations are removed automatically; subsequent requests return 404. Reset the idle timer by calling POST /rl/environments/{environmentId}/step or POST /rl/environments/{environmentId}/reset at least once every 2 hours during long training runs.
Note: In-memory deployments (the default) do not persist RL environments across server restarts. Reconnect or recreate the environment after a restart.
UI Status Viewer: Once an environment is running you can monitor its episodes, cumulative rewards, and health without writing code — open the RL Environment Status viewer in the platform UI and enter your API key to see all active environments at a glance.
Request
- Base URL: https://www.cloudworldmodel.ai/api
- URL: https://www.cloudworldmodel.ai/api/rl/environments
- Auth: one of:
- HTTP bearer
- API key in header X-PAYMENT
- API key in header PAYMENT-SIGNATURE
Request body
Example request
{
"simulationId": "a638caad-7423-40a3-bb09-f91235d9392d",
"episodeConfig": {
"maxSteps": 300,
"targetTrafficPattern": "ramp",
"initialTraffic": 5000,
"targetSLA": {
"maxLatencyP95": 200,
"maxErrorRate": 1
},
"costBudgetPerHour": 5,
"tick_seconds": 60,
"unmodeled_cost_penalty_per_dimension": 0.1,
"evalCostOverrides": {
"egress": 0.5,
"cross_az_traffic": 0.3
}
},
"rewardWeights": {
"cost": 0.4,
"resilience": 0.2,
"latency": 0.2,
"performance": 0.1,
"stability": 0.1
},
"webhookUrl": "https://your-app.com/webhooks/rl-episode",
"webhookSecret": "your-secret-key-here"
}Response
RL environment created successfully
Example response
{
"environment": {
"episodeConfig": {
"maxSteps": 300,
"targetTrafficPattern": "ramp",
"initialTraffic": 5000,
"targetSLA": {
"maxLatencyP95": 200,
"maxErrorRate": 1
},
"costBudgetPerHour": 5,
"tick_seconds": 60,
"unmodeled_cost_penalty_per_dimension": 0.1,
"evalCostOverrides": {
"egress": 0.5,
"cross_az_traffic": 0.3
}
},
"currentStep": 42,
"totalReward": 12.45,
"isActive": true,
"lastSimTimeHuman": "1h 30m",
"webhookDeliveryStatus": "delivered",
"webhookDeliveryAttempts": 1,
"idleExpiresAt": "2024-01-15T14:00:00.000Z",
"rewardWeights": {
"cost": 0.4,
"resilience": 0.2,
"latency": 0.2,
"performance": 0.1,
"stability": 0.1
}
},
"observation": {
"metrics": {
"cpuUsage": 65.3,
"latencyP50": 45,
"latencyP95": 91,
"errorRate": 0.5,
"throughput": 4500,
"costPerHour": 0.31,
"connectionPressure": 0.42
},
"resources": [
{
"id": "ec2-1",
"type": "compute",
"name": "Web Server 1",
"provider": "aws",
"location": {
"regionKey": "us-east-2"
},
"characteristics": {
"workload": "crud",
"appRuntime": "node",
"appWorkerCount": 2,
"appDbPoolSize": 250,
"workloadDatabaseVersion": "8.0",
"workloadDatabaseEngine": "mysql",
"rdsSqlServerBilling": {
"instanceClass": "db.t3.micro",
"storageType": "gp2",
"allocatedStorageGiB": 20,
"durationHours": 480,
"sustainedCpuPercent": 43
},
"serviceFamily": "ec2",
"containerCpu": 0.5,
"containerMemoryGiB": 1,
"runtimeMemoryProfile": {
"workingSetGiB": 0.78125
},
"concurrency": 80,
"requestDurationSeconds": 0.25,
"requestServingTargetUtilizationPct": 70,
"billingState": "stopped",
"size": "m5.large",
"instanceType": "t3.medium",
"ocpus": 4,
"maxThroughput": 2000,
"capacityRps": 100,
"baseLatency": 3,
"maxConnections": 800,
"capacityGB": 500,
"maxIops": 3000,
"inferenceMode": true,
"accelerator": "a10g",
"managedComputePlatform": "nvidia-dgx-cloud",
"openshiftOffering": "rosa-hcp",
"topology": {
"intraNode": "nvlink-nvswitch",
"interNode": "infiniband"
},
"intraNode": "nvlink-nvswitch",
"interNode": "infiniband",
"includesControlPlane": true,
"bundledNetworking": true,
"trainingMode": true,
"tokensPerRequest": 500,
"inputTokensPerRequest": 1000,
"cacheHitRate": 0.85,
"cacheableRequestShare": 0.75,
"asynchronousRequestShare": 0.15,
"queueConsumerCount": 4,
"queueDrainRatePerConsumerRps": 125,
"queueCapacityMessages": 20000,
"queueSimulationStepSeconds": 1,
"autoscaling": true,
"maxInstances": 5,
"minInstances": 2,
"scaleOutCpuThreshold": 60,
"scaleInCpuThreshold": 25,
"nodeCount": 2,
"workerVcpu": 4,
"minNodes": 2,
"maxNodes": 10,
"perNodeRate": 3.2,
"pricingModel": "on-demand",
"nodePools": [
{
"name": "general",
"nodeCount": 2,
"workerVcpu": 8,
"minNodes": 2,
"maxNodes": 10,
"perNodeRate": 0.096,
"maxThroughput": 10000
}
],
"streamShardsCount": 4,
"streamWriteRps": 3500,
"eventNotificationsEnabled": true,
"partitionCount": 8,
"streamPartitions": 4,
"partitionWriteRps": 5000,
"warmupSteps": 5,
"warmupSeverity": 0.8
},
"routedRps": 15,
"availabilityState": "available",
"isRoutable": true,
"failureParkStepsRemaining": 3,
"recoveryPolicy": {
"criticalCpuThreshold": 75,
"criticalSteps": 2,
"warningCpuThreshold": 60,
"warningSteps": 1,
"failureParkSteps": 2
}
}
],
"traffic": 5000,
"currentTime": 2520,
"sim_time_seconds": 2520,
"tick_seconds": 60
}
}Changes
No recorded changes to this operation across all 1 revision of this API.