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. |
promote | bool | Promote the deployment to production, even if a production deployment already exists. |
preserve_previous_production_deployment | bool | Preserve the previous production deployment’s autoscaling settings (only with promote). |
deployment_name | Optional[str] | Custom deployment name (must contain only alphanumeric, ., -, or _ characters). (Requires 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. |
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. |
true when deployment is ready.
Raises: TimeoutError if deployment doesn’t become active within timeout_seconds. ValueError if deployment fails.