Code sandbox
Sandboxed Python execution for agentic workflows — run LLM-generated code and feed the output back to the model. $0.03 per session; sessions live 60 minutes.
Sessions
A session is a live execution environment with a working directory that persists across calls — write a file in one execution, read it in the next. Omit session_id and one is created (and billed) automatically.
curl -X POST https://ragnarok-ai.com/api/v1/sandbox/execute \
-H "Authorization: Bearer sk-ft-…" \
-H "Content-Type: application/json" \
-d '{"code": "print(6 * 7)"}'
# → { "session_id": "sbx_…", "stdout": "42\n", "stderr": "",
# "exit_code": 0, "duration_ms": 21, "executions": 1 }curl -X POST https://ragnarok-ai.com/api/v1/sandbox/execute \
-H "Authorization: Bearer sk-ft-…" \
-H "Content-Type: application/json" \
-d '{"session_id": "sbx_…", "code": "print(open(\"x.txt\").read())"}'GET /v1/sandbox/sessions lists your active sessions with execution counts and expiry times. Executions time out after 15 seconds.
Pairing with function calling
Register a run_python tool in a chat completion with function calling; when the model calls it, forward the code to the sandbox and return stdout as the tool result. This closed loop — generate, execute, observe — is the core of agentic coding and of RL environments that reward passing tests.