Skip to main content
This quickstart uses contree-sdk 0.3.6 and alpine:3.19 to create a file in one operation, save the resulting filesystem, and read the file in a second operation.
1

Set up access

Create an API key and copy the project ID as described in Set up access. For the Python SDK, export both values in each shell that runs the program:
The SDK reads NEBIUS_PROJECT_ID. NEBIUS_AI_PROJECT is the CLI’s profile-registration variable and does not replace it.
2

Create a project

Install uv if it is not already available, then create an isolated project and install SDK 0.3.6:
Use Python 3.12 for this quickstart.
3

Save and reuse a file

Create quickstart.py:
Run it locally:
Expected output includes an immutable image UUID followed by:
The object returned by awaiting a run exposes both its process result (exit_code, stdout, and stderr) and its saved image. When the run saves an image, you can use its uuid and call .run() again, as checkpoint does here. A disposable result has uuid is None and cannot be used to start another run.base.run(...) prepares the first operation. Awaiting the returned object submits the operation and waits for its result. Because disposable=False was selected before submission, a successful preparation can return a reusable image. The second operation sets disposable=True, so its filesystem changes are discarded.
4

Inspect failures before continuing

An accepted operation and a completed command are different outcomes. Check the process result before using its output or image:

Command succeeded: exit_code == 0

Use the output and, when requested, the returned image UUID.

Command failed: nonzero exit_code

Inspect stderr and fix the command or input. Follow the result-image rules before reusing files from that run.

SDK raised an exception

The operation did not produce a normal process result. Record safe diagnostic details and follow Troubleshooting.
When an SDK 0.3.6 wait ends before a terminal result, the SDK attempts best-effort cancellation. A REST event-stream disconnect has different behavior. See Execution lifecycle.

Continue