This release is a pre-release and may not be stable for production use.
CeyNox Sandbox SDK for Python
⚠️ Alpha: not for production use. CeyNox Sandbox is not open to the public yet. This pre-release is for invited testers only; you need an invitation to get an API address and key, which your console then shows you. Interfaces may change between alpha releases without notice. Interested? Email support@ceynovahq.com.
Run untrusted code, from AI agents or anywhere else, in isolated cloud sandboxes instead of on your own machine.
Features
- Isolated Linux sandboxes, each separate from your machine and from every other customer's sandbox.
- Commands in the foreground or background, with streamed output, exit codes and timeouts.
- Files: read, write and list.
- Pause a sandbox with its memory and disk, and resume it later.
- Sync (
Sandbox) and async (AsyncSandbox) APIs, fully typed. - The
ceynox-sandboxcommand: sandboxes, commands, file copies and SSH from a terminal. - Compatible with code written for the E2B SDK.
Requirements
- Python 3.11 or later.
- An invitation to the alpha: your console then gives you your API address and an API key.
Install
pip install --pre ceynox-sandbox
--pre is needed while only pre-releases exist.
Quick start
Save your API key and your API's address once. Your console's API keys page shows this line with your address filled in; the command asks for the key:
ceynox-sandbox login --api-url https://api.<your environment>
Then:
from ceynox_sandbox import Sandbox
with Sandbox.create() as sandbox:
result = sandbox.commands.run("python3 -c 'print(6 * 7)'")
print(result.exit_code, result.stdout) # 0 42
The sandbox is killed when the with block ends.
Usage
Commands
from ceynox_sandbox import CommandExitException, Sandbox
with Sandbox.create() as sandbox:
result = sandbox.commands.run("echo $NAME", cwd="/tmp", envs={"NAME": "hello"})
print(result.stdout) # hello
# A non-zero exit raises, carrying the exit code and the output.
try:
sandbox.commands.run("exit 3")
except CommandExitException as error:
print(error.exit_code) # 3
# Stream output as it arrives, and end the command after 10 seconds.
sandbox.commands.run(
"for i in 1 2 3; do echo $i; sleep 1; done",
on_stdout=lambda data: print("out:", data, end=""),
timeout=10,
)
# Run as root instead of the unprivileged `user`.
print(sandbox.commands.run("whoami", user="root").stdout) # root
# In the background: wait for it later.
handle = sandbox.commands.run("sleep 2 && echo done", background=True)
print(handle.wait().stdout) # done
Files
with Sandbox.create() as sandbox:
sandbox.files.write("/home/user/hello.txt", "hello")
print(sandbox.files.read("/home/user/hello.txt")) # hello
for entry in sandbox.files.list("/home/user"):
print(entry.name, entry.type)
Async
import asyncio
from ceynox_sandbox import AsyncSandbox
async def main() -> None:
async with await AsyncSandbox.create() as sandbox:
result = await sandbox.commands.run("uname -a")
print(result.stdout)
asyncio.run(main())
Lifetime, pause and resume
sandbox = Sandbox.create(timeout=600) # ends after 10 minutes unless extended
sandbox.set_timeout(3600) # now an hour from now
sandbox.pause() # keeps its memory and disk
same = Sandbox.connect(sandbox.sandbox_id) # resumes it where it left off
same.kill()
Passing the key and address in code
import os
sandbox = Sandbox.create(api_key=os.environ["MY_CEYNOX_KEY"], api_url="https://api.<your environment>")
Command line
The package installs ceynox-sandbox:
ceynox-sandbox login --api-url https://api.<your environment> # save your key and address
ceynox-sandbox create # prints the new sandbox's id
ceynox-sandbox list
ceynox-sandbox exec <id> -- uname -a
ceynox-sandbox cp ./app <id>:app
ceynox-sandbox ssh <id>
ceynox-sandbox profiles # the saved profiles and their addresses
ceynox-sandbox --help
ceynox-sandbox --version
It lists, creates, pauses, resumes and kills sandboxes, runs commands, copies files, forwards ports and opens SSH sessions with short-lived certificates.
Configuration
| Setting | In code | Environment | What it sets |
|---|---|---|---|
| API key | api_key |
CEYNOX_API_KEY |
Your API key (keys start with cnx_) |
| API address | api_url |
CEYNOX_API_URL |
Your API's address (https://…) |
| Profile | profile |
CEYNOX_PROFILE |
A profile saved with ceynox-sandbox login --profile <name>, used as a whole |
The key and the address always go together:
- Neither given in code or the environment: both come from the saved
defaultprofile. - Only one given: the other is never taken from the default profile. Without a key nothing is sent; without an address the production API is used.
- A profile named (
profile=orCEYNOX_PROFILE): that profile is used as a whole, filling whichever of the two is not given.
ceynox-sandbox login --profile <name> --api-url … saves more than one profile, for example one per environment.
Error handling
Every error the SDK raises is a CeyNoxException:
from ceynox_sandbox import (
ApiUnreachableException,
AuthenticationException,
CeyNoxException,
Sandbox,
)
try:
sandbox = Sandbox.create()
except AuthenticationException as error:
print("no key, or the key was refused:", error)
except ApiUnreachableException as error:
print("the API could not be reached at", error.api_url)
except CeyNoxException as error:
print("something else went wrong:", error)
As in the E2B SDK, AuthenticationException and ServiceBusyException are not SandboxExceptions, so catch CeyNoxException to handle everything.
Security
- Your key and a sandbox's access tokens are sent only over HTTPS. Plain HTTP is refused except to this computer (
localhost,127.0.0.0/8,::1). - A key is sent only to the address it is paired with (see Configuration), and a key that is not a CeyNox key (
cnx_…) is never sent, so another provider's key left in the environment stays where it is. - Saved profiles live in
~/.ceynox/credentials.json, written readable only by you, and refused if anyone else can read it.loginreads the key from the terminal or standard input, never from the command line. - Output from a sandbox is produced by code you may not control: treat it as untrusted data.
- To report a vulnerability, email support@ceynovahq.com.
Coming from E2B
This SDK is a fork of the E2B Python SDK and keeps its interface, so code written for E2B needs little change: import from ceynox_sandbox and use a CeyNox key. Anything the service does not offer yet fails at once with a "not supported by CeyNox Sandbox yet" error, before any request is made. A few E2B options are kept only for compatibility and will go before 1.0: keep_memory (a pause always keeps memory) and the headers option (use api_headers).
Versioning
Pre-1.0 alpha; no stability guarantees; not for production. Breaking changes are possible between alphas. From 1.0 the package follows semantic versioning. ceynox_sandbox.__version__ and ceynox-sandbox --version say which version is installed.
Support
Email support@ceynovahq.com.
Licence
Apache License 2.0 (LICENSE) for CeyNova Labs' code. The parts taken from the E2B SDK keep their original licences, included as LICENSE.upstream-package (MIT) and LICENSE.upstream-repository (Apache 2.0). NOTICE says where the code came from and what was changed.
Metadata
Release files for ceynox-sandbox 0.1.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ceynox_sandbox-0.1.0a1.tar.gz | 192.1 kB | Without provenance | Details for ceynox_sandbox-0.1.0a1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ceynox_sandbox-0.1.0a1-py3-none-any.whl | Python 3 | none | any | Details for ceynox_sandbox-0.1.0a1-py3-none-any.whl |
Total release size: 463.7 kB
Release files / ceynox_sandbox-0.1.0a1.tar.gz
| Download URL | ceynox_sandbox-0.1.0a1.tar.gz |
|---|---|
| Size | 192.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1aa834958de6fef42b4aa7d228bc9b952c6c3c5527ee1f9ad25c3406d0ccef7
|
|
BLAKE2b-256 checksum How to use checksums |
0f55e759812e551633e2b6df91413a766da9540ec684250ff9e4b4dbd0a326a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / ceynox_sandbox-0.1.0a1-py3-none-any.whl
| Download URL | ceynox_sandbox-0.1.0a1-py3-none-any.whl |
|---|---|
| Size | 271.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d45f06a7a52013d61ef42e482f28cbbcfd7fe3dac4d20147cddc0501b49be80
|
|
BLAKE2b-256 checksum How to use checksums |
bf8258cd64e8707a07ff652f7012637f28a4b7b6e41a358146b00350adfbd4bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for ceynox-sandbox 0.1.0a1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.