Install and authenticate
Requirements
Section titled “Requirements”| SDK | Package | Runtime |
|---|---|---|
| Python | svm |
Python 3.10 or newer |
| TypeScript | @svm/sandbox |
Node.js 18 or newer |
| Go | github.com/jupimartofficial-cell/icloud/firecracker-agent-platform/sdk/go |
Go 1.27 or newer |
| Ruby | svm (module SVM) |
Ruby 2.6 or newer |
| Java | dev.svm:sandbox |
Java 11 or newer |
All five are at version 0.2.0 and share one method surface. A method has the same meaning everywhere, written in each language’s
own style: run_code in Python and Ruby, runCode in TypeScript and Java, RunCode in Go.
Install
Section titled “Install”pip install ./sdk/python # add [cli] for the svm command: pip install './sdk/python[cli]'cd sdk/typescript && pnpm install --frozen-lockfile && pnpm run buildnpm install /path/to/sdk/typescript # in your projectgo get github.com/jupimartofficial-cell/icloud/firecracker-agent-platform/sdk/gocd sdk/ruby && gem build svm.gemspec && gem install ./svm-0.2.0.gemcd sdk/java && mvn -q install -DskipTests<dependency> <groupId>dev.svm</groupId> <artifactId>sandbox</artifactId> <version>0.2.0</version></dependency>Authenticate
Section titled “Authenticate”-
Create an API key in the SVM console under API keys. The key is shown once.
-
Put the key and your API domain in the environment. Every SDK and the CLI read them:
Terminal window export SVM_API_KEY='…' # never commit it, never pass it into a sandboxexport SVM_DOMAIN='api.example.com'Or save them once with the CLI. The key is read without echo, and the file is written with mode
0600:Terminal window svm --domain api.example.com auth configure -
Create a client. With nothing passed, the SDK uses the environment, then the config file. Pass credentials explicitly when your application keeps them elsewhere:
import osfrom svm import Sandbox, SandboxClientclient = SandboxClient(domain=os.environ["SVM_DOMAIN"],api_key=os.environ["SVM_API_KEY"],)with Sandbox.create(template="base", client=client) as sandbox:print(sandbox.id, sandbox.state)import { Sandbox, SandboxClient } from "@svm/sandbox";const client = new SandboxClient({apiKey: process.env.SVM_API_KEY,domain: process.env.SVM_DOMAIN,});const sandbox = await Sandbox.create({ template: "base" }, client);try {console.log(sandbox.id, sandbox.state);} finally {await sandbox.kill();}client, err := svm.NewClient(svm.ClientOptions{APIKey: os.Getenv("SVM_API_KEY"),Domain: os.Getenv("SVM_DOMAIN"),Timeout: 60 * time.Second,})if err != nil {return err}sandbox, err := client.CreateSandbox(ctx, svm.CreateSandboxOptions{Template: "base"})if err != nil {return err}defer sandbox.Kill(ctx)fmt.Println("created", sandbox.Info().SandboxID)require "svm"client = SVM::Client.new(domain: ENV.fetch("SVM_DOMAIN"),api_key: ENV.fetch("SVM_API_KEY"),timeout: 30)box = SVM::Sandbox.create(client: client, template: "base")beginputs "#{box.id} is #{box.state}"ensurebox.killendimport dev.svm.sandbox.Client;import dev.svm.sandbox.Sandbox;public class ClientConfigExample {public static void main(String[] args) {String domain = System.getenv("SVM_DOMAIN");String apiKey = System.getenv("SVM_API_KEY");// domain, API key, bearer token (null when using a key), allow plain http outside localhostClient client = new Client(domain, apiKey, null, false);Sandbox.CreateOptions options = new Sandbox.CreateOptions();options.template = "base";options.wait = true;try (Sandbox sandbox = Sandbox.create(client, options)) {System.out.println("created " + sandbox.id() + " on " + client.baseUrl());}}}
Where credentials come from
Section titled “Where credentials come from”The SDKs check arguments first, then the environment, then the config file. The first source that holds a credential decides it. The domain is resolved the same way, on its own.
| Setting | Argument | Environment |
|---|---|---|
| Domain | domain |
SVM_DOMAIN |
| API key | api_key |
SVM_API_KEY |
| Bearer session token | bearer_token |
SVM_ACCESS_TOKEN |
The config file is JSON ({"domain": "...", "api_key": "..."}). It is read from $SVM_CONFIG, or else from
~/.config/fcap/config.json. A file that holds a key must not be readable by others (chmod 600); the SDK refuses it otherwise.
Retries and timeouts
Section titled “Retries and timeouts”Each SDK retries the same way:
- Connection failures, and 502, 503 and 504 responses, are retried with jittered backoff: six attempts in all.
- A
429 RATE_LIMITEDresponse is retried after the wait the server asks for. - A POST is sent with an idempotency key, so a retried create never creates twice.
- Other 4xx responses are not retried.
Each attempt times out after 10 seconds unless you set another limit.
The full list of errors you can catch is in Errors and retries.