- 1Make a production project
In the console, make a project for production. Its sandboxes, API keys and usage stay apart from the project you tried VirtX in. A deploy page in the console, which makes the project and its key for you, is coming soon.
Open console - 2Give your agent its key
Make an API key in that project and set it as VIRTX_API_KEY where your agent runs. The console shows a key once.
- 3Open a sandbox for each user
Name a sandbox after the user it is for. Your agent finds it by that name, and makes it the first time.
- 4Watch them
The project's Sandboxes page lists each one as it opens, and its Usage page shows what they used, by day.
One sandbox per user
The whole change to your agent: connect to VirtX cloud with the production key, and ask for the user's sandbox by name before each task. Find it or make it has the same lines in Rust.
import asyncio
import os
from virtx import BearerAuth, Client, VirtxError
IMAGE = "python:3.12"
async def sandbox_for(client: Client, user_id: str):
# the user's sandbox: found by its name, made the first time
name = f"user-{user_id}"
sandbox = await client.find_sandbox(name)
if sandbox is None:
try:
sandbox = await client.create_sandbox(IMAGE, name=name)
except VirtxError as error:
if error.status != 409: # 409: another request made it first
raise
sandbox = await client.find_sandbox(name)
return sandbox
async def main():
key = BearerAuth(os.environ["VIRTX_API_KEY"])
async with Client.connect("https://cloud.virtx.sh", key) as client:
# once: the image is pulled into the project, and every sandbox starts from it
await client.pull_image(IMAGE).complete()
sandbox = await sandbox_for(client, "42")
asyncio.run(main())import { Client, VirtxError } from '@brekkylab/virtx'
const IMAGE = 'python:3.12'
const key = { type: 'bearer', token: process.env.VIRTX_API_KEY }
const client = Client.connect('https://cloud.virtx.sh', key)
// once: the image is pulled into the project, and every sandbox starts from it
await client.pullImage(IMAGE).complete()
// the user's sandbox: found by its name, made the first time
async function sandboxFor(userId) {
const name = `user-${userId}`
let sandbox = await client.findSandbox(name)
if (sandbox === undefined) {
try {
sandbox = await client.createSandbox(IMAGE, { name })
} catch (error) {
// 409: another request made it first
if (!(error instanceof VirtxError) || error.status !== 409) throw error
sandbox = await client.findSandbox(name)
}
}
return sandbox
}
const sandbox = await sandboxFor('42')Once nothing has used a sandbox for a while, it is parked with its disk kept, and pays for that disk only. Its next command boots it. What gets measured
Before you launch
- Access
- VirtX cloud is in early access: only a Google account whose application is approved signs in. Apply for early access
- Credits
- An approved account starts with $10 of credits. Credits go on sale after early access. Pricing
- Limits
- One organization has limits on what runs at a time, across its projects. For a launch that needs more, write to contact@brekkylab.com.
- Ports
- A sandbox's ports are not open to the internet. Your agent reaches them through the SDK's port forwarder. Networks and ports
- GPU
- GPU sandboxes are not available on VirtX cloud yet.
- Your agent
- VirtX runs the sandboxes, not the agent. Its process stays on your server, a worker or wherever you run it now.
On your own server
The same code runs against a VirtX server you host: connect to its address in place of the cloud's. Running your own server