Prepare a Python Truss project
You’ll need a Baseten account, the Baseten CLI, and a CLI profile authenticated withbaseten auth login. Use an account with permission to deploy models. Keep one terminal open for the watcher and use a second terminal for prediction requests.
Install jq to extract the published deployment ID during release. This example creates billable CPU compute. Deactivate the deployments when you’re done.
Create the project directory, then save the following files:
Terminal
config.yaml
model/model.py
model_name if HelloWorld already exists in your team. The predict() method accepts a JSON object with a name field and returns a greeting. You can use your own Python Truss project instead; use an input that matches its prediction method in the requests below.
Start a development deployment
Run the following command from the project directory to create a development deployment and watch for changes:abc1d2ef and development deployment ID xyz123. The summary’s CLI hint omits the request body and environment; use the complete prediction command below to call development.
If deployment fails, inspect the build or deployment logs and follow deployment troubleshooting. A build failure occurs before the container starts; a startup failure occurs while the model loads.
Test an edit
To verify a code change:-
In your second terminal, send a request to the development environment. Replace
abc1d2efwith your model ID: -
Replace
model/model.pywith the following code and save it:model/model.py -
Wait for the watcher to finish applying the patch, then send the same request again:
Terminal
Re-attach to a development deployment
Ctrl+C stops the local watcher but leaves the development deployment running. To sync changes and resume watching it, run the following command from the project directory:Terminal
baseten model watch syncs any changes made while disconnected, then resumes watching. It requires an existing development deployment. If you don’t have one, use baseten model push --watch to create it.
To resume watching with hot reload, run the following command:
Terminal
What gets live-patched
The Baseten CLI monitors your project directory and applies patches for the following changes without a full rebuild:
With the
--watch-hot-reload or --hot-reload flags, the Baseten CLI hot-reloads model code changes by swapping the model class in-process without restarting the inference server. This preserves in-memory state like loaded weights and caches. If a patch includes non-model changes (such as requirements or config), it falls back to a standard restart.
What requires a full redeploy
The patch system doesn’t support some changes. When you make these changes, stop the watch session and runbaseten model push (or baseten model push --watch to start a new development deployment):
Limitations
Development deployments optimize for iteration, not production traffic:- Single replica: Fixed at 0 minimum, 1 maximum. No autoscaling beyond one replica.
- No gRPC: Trusses with gRPC transport require a published deployment.
- No custom Docker servers or TRT-LLM engine builds: Use a published deployment for these configurations.
Publish and validate an update
Publish an immutable deployment when you’re ready to release a Python Truss model or update a custom Docker server or engine configuration. Use the same project andmodel_name as the model you want to update. If the model already has a production deployment, a push without an environment creates a candidate; promote it explicitly to update production.
When the model has no production deployment, Baseten assigns its first published deployment to production. For the greeting model in this walkthrough, the first publish therefore creates the initial production release. The request below validates that deployment directly.
To publish and test a candidate:
-
Save a valid input for your model as
request.json. For the Python greeting model, use:For the vLLM Qwen server, use:request.jsonrequest.json -
Stop the watcher if it’s running. From the project directory, publish the current files and save the new deployment ID:
The command streams build and startup logs, waits for the deployment to become Active, and saves its ID. If the push fails, inspect the logs before continuing.Terminal
-
Send your test input to the published deployment. Replace
abc1d2efwith your model ID:The greeting model returnsTerminal{"greeting": "Welcome, Baseten!"}. For your own model, confirm the response matches the behavior you intend to release.
Deploy to production
For an update to an existing production release, promote the validated deployment using the ID inpublished_deployment_id. Save the ID returned by promotion and follow the same procedure’s environment check. Promotion can return a different ID, and it can finish after the command returns.
For the first published release, skip promotion and use published_deployment_id in the environment check: Baseten has already selected that deployment for production.
After the production environment’s current_deployment.id matches the promoted ID, send the same input through the stable endpoint:
Clean up
When you’ve finished the example, deactivate each deployment you created, including the development deployment and any published or promoted deployments. Confirm each deployment reaches Inactive. Stopping the watcher doesn’t stop the deployment or its compute spend.CLI reference: model push
Full list of options for the push command.
CLI reference: model watch
Full list of options for the watch command.
Autoscaling
Configure replicas, concurrency targets, and scale-to-zero for production.
Environments
Manage staging, production, and custom environments.