Links

Local development setup

Set up your local development environment to deploy models and more on Baseten.
You don't need to perform this setup to use your Baseten account. However, if you've trained your own model, you need the Baseten package installed in your python environment. It's best to install Baseten in the same environment that you use to train your models.
Once your custom model is on Baseten, everything else can be done through the user interface, but there are programmatic interfaces for some parts of the Baseten platform:
  • Python client: Baseten's Python client is the most complete and convenient way to interface with your Baseten account from a local development environment or Jupyter notebook.
  • Command-line interface (CLI): the Baseten CLI is a handy utility for authenticating with your Baseten account.
  • Deployed model APIs: applications and models deployed on your Baseten account automatically have API endpoints.
To connect your local development environment to your Baseten account, follow the steps below.

Installing the Baseten client

I'll start making instant coffee, you start configuring your local development environment to deploy and manage models on Baseten. I bet we'll finish at around the same time, and the coffee is, you know, instant.
Pull up a terminal in your Python environment and complete the following three and a half steps:
  1. 1.
    Run pip install --upgrade baseten, pretty straightforward.
  2. 2.
    Generate an API key following these instructions.
  3. 3.
    Run baseten login and enter the value of your API key from step 2.
The aforementioned half-step is to check and see if you need to take any of the uncommon setup steps below, but 99% of users are good to go from here!

Installing Truss

Truss is an open-source Python package for model serving and deployment. Baseten uses Truss under the hood, but Truss offers a great deal of functionality independent of Baseten. You can use Truss directly for local serving, model testing, or configuring complex models, as well as packaging models in a shareable, standardized format.
The truss package is a dependency of the baseten package, so it is installed as part of pip install --upgrade baseten. If you want to install Truss directly, just run pip install --upgrade truss.
To learn more about Truss, visit the Truss documentation.

Uncommon setup steps

If you're wondering "do I need to do these" the answer is probably no; if you need to do this, you'll know.

CLI-free setup

Maybe you're using the Baseten client from a serverless function or other environment where running a terminal is difficult. In this case, you'll want to log in within the code itself, not the CLI.
Follow the first two steps from above, then run export BASETEN_API_KEY=paste_key_here or otherwise add your API key as an environment variable.
import os
import baseten
baseten.login(os.environ['BASETEN_API_KEY'])

Self-hosted Baseten installation

If you have a self-hosted Baseten installation, the main sequence becomes four steps:
  1. 1.
    Run pip install --upgrade baseten, pretty straightforward.
  2. 2.
    Generate an API key following these instructions.
  3. 3.
    Run baseten configure URL where URL is the installation's base URL, like https://baseten.internal.mycompany.com.
  4. 4.
    Run baseten login and enter the value of your API key from step 2.
If you both have a custom installation and want a CLI-free setup, you can do by following the first two steps from above, then run export BASETEN_API_KEY=paste_key_here or otherwise add your API key as an environment variable.
import os
import baseten
baseten.configure('https://baseten.internal.mycompany.com') # Your workspace's base URL
baseten.login(os.environ['BASETEN_API_KEY'])