Configuration
The SDK resolves credentials in the following priority order:-
Explicit values passed to
IAMAuth/JWTAuthconstructors viaContreeConfig. -
Environment variables:
NEBIUS_API_KEY— IAM tokenNEBIUS_PROJECT_ID— ConTree project IDCONTREE_BASE_URL— ConTree instance URL (forJWTAuth)
-
auth.ini— if thecontreeCLI is installed, credentials written bycontree authare read automatically from~/.config/contree/auth.ini.
auth.ini profile defaults to default and can be overridden with CONTREE_PROFILE. The config directory respects $CONTREE_HOME and $XDG_CONFIG_HOME.
Alternatively, you can pass auth directly when creating a client via ContreeConfig(auth=IAMAuth(...)) or use JWTAuth for legacy token-based access.
Creating a Client
The first step is to create a ConTree client. You can choose between async and sync versions depending on your application needs. Here’s how to create a client and verify the connection by listing available images:- Async
- Sync
Contree for all client options.Working with Images
Images are the foundation of ConTree. The simplest way to reference an image is by tag usingimages.use(), which creates an image object without making an API call:
- Async
- Sync
images.use(strict=True). To import from an external registry (or return an existing image if already imported), use images.oci().
See Working with Images for a full overview of available methods, examples, and what you can pass as a reference.
Running Commands
Once you have an image, you can run commands inside it. Each command execution creates a new version of the image with your changes.Basic Command Execution
You can run various shell commands and handle their output:- Async
- Sync
run() for all command execution options.Understanding the Results
When you run a command, you get back a result object that contains:stdout: Standard output from the commandstderr: Standard error from the commandexit_code: The exit code (0 for success, non-zero for errors)uuid: The UUID of the new image version created by this command