> ## Documentation Index
> Fetch the complete documentation index at: https://docs.baseten.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Truss SDK Reference

> Python SDK for deploying and managing models with Truss.

## Authentication

### `truss.login(api_key: str) → None`

Authenticates with Baseten using an API key.

**Parameters:**

| Name      | Type  | Description      |
| --------- | ----- | ---------------- |
| `api_key` | *str* | Baseten API Key. |

***

## Deploying a Model

### `truss.push(target_directory: str, **kwargs) → ModelDeployment`

Deploys a **Truss** model to Baseten.

**Parameters:**

| Name                                      | Type              | Description                                                                                                              |
| ----------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `target_directory`                        | *str*             | Path to the Truss directory to push.                                                                                     |
| `remote`                                  | *Optional\[str]*  | Name of the remote in `.trussrc` to push to.                                                                             |
| `model_name`                              | *Optional\[str]*  | Temporarily override the model name for this deployment without updating `config.yaml`.                                  |
| `publish`                                 | *bool*            | Deploy as **published**. If no production deployment exists, promote it to production.                                   |
| `promote`                                 | *bool*            | Deploy as **published** and promote to production, even if a production deployment exists.                               |
| `preserve_previous_production_deployment` | *bool*            | Preserve the previous production deployment's **autoscaling settings** (only with `promote`).                            |
| `trusted`                                 | *bool*            | **Deprecated.** All models are trusted by default. This parameter is ignored.                                            |
| `deployment_name`                         | *Optional\[str]*  | Custom deployment name (must contain only alphanumeric, `.`, `-`, or `_` characters). (Requires `publish` or `promote`.) |
| `disable_truss_download`                  | *bool*            | Disable downloading of the Truss directory from the UI.                                                                  |
| `environment`                             | *Optional\[str]*  | Name of a stable environment to deploy to.                                                                               |
| `labels`                                  | *Optional\[dict]* | JSON-serializable dictionary of label key-value pairs to attach to the deployment.                                       |
| `team`                                    | *Optional\[str]*  | Name of the team to push the model to.                                                                                   |

**Returns:** [ModelDeployment](#class-truss-api-definitions-modeldeployment) – An object representing the deployed model.

***

## Model Deployment Object

### *class* `truss.api.definitions.ModelDeployment`

Represents a deployed model (returned by `truss.push()`).

**Attributes**

`model_id` → `str`: Unique ID of the deployed model.
`model_deployment_id` → `str`: Unique ID of the model deployment.

**Methods**

`wait_for_active(timeout_seconds: int = 600)` → bool
Waits for the deployment to become **active**.

| Name              | Type  | Description                                         |
| ----------------- | ----- | --------------------------------------------------- |
| `timeout_seconds` | *int* | Maximum time to wait in seconds. Defaults to `600`. |

**Returns**: `true` when deployment is ready.
**Raises**: `TimeoutError` if deployment doesn't become active within `timeout_seconds`. `ValueError` if deployment fails.
