Once you’ve deployed your model, it’s time to use it! Every model on Baseten is served behind an API endpoint. To call a model, you need:

  • The model’s ID.
  • An API key for your Baseten account.
  • JSON-serializable model input.

You can call a model using:

Call by API endpoint

import urllib3
import os

model_id = ""
# Read secrets from environment variables
baseten_api_key = os.environ["BASETEN_API_KEY"]

resp = urllib3.request(
    headers={"Authorization": f"Api-Key {baseten_api_key}"},
    json={}, # JSON-serializable model input


See the Baseten API reference for more details.

Call with Truss CLI

truss predict --model $MODEL_ID -d '$MODEL_INPUT'

See the Truss CLI reference for more details.