Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Truss

The simplest way to serve AI/ML models in production

PyPI version Python versions ci_status

Truss is the CLI for deploying and serving ML models on Baseten. Package your model's serving logic in Python, launch training jobs, and deploy to production—Truss handles containerization, dependency management, and GPU configuration.

Truss lets you serve models with the Baseten Inference Stack as well as deploy models from any open-source framework: vLLM, SGLang, TensorRT-LLM, transformers, diffusers, PyTorch, TensorFlow, and more.

Get started | 100+ examples | Documentation

Why Truss?

  • Write once, run anywhere: Package model code, weights, and dependencies with a model server that behaves the same in development and production.
  • Fast developer loop: Iterate with live reload, skip Docker and Kubernetes configuration, and use a batteries-included serving environment.
  • Support for all Python frameworks: From transformers and diffusers to PyTorch and TensorFlow to vLLM, SGLang, and TensorRT-LLM, Truss supports models created and served with any framework.
  • Production-ready: Built-in support for GPUs, secrets, caching, and autoscaling when deployed to Baseten or your own infrastructure.

Installation

Install Truss with:

pip install --upgrade truss

Quickstart

Deploying a model to Baseten via Truss turns a Hugging Face model into a production-ready API endpoint. You write a config.yaml that specifies the model, the hardware, and the engine, then uvx truss push builds a TensorRT-optimized container and deploys it. No Python code, no Dockerfile, no container management.

This guide walks through deploying Qwen 2.5 3B Instruct, a small but capable LLM, from a config file to a production API. You'll set up Truss, write a config, deploy to Baseten, and call the model's OpenAI-compatible endpoint.

Set up your environment

Before you begin:

  • Sign up or sign in to Baseten.
  • Install uv, a fast Python package manager. This guide uses uvx to run Truss commands without a separate install step.

Authenticate with Baseten

Log in:

uvx truss login

The CLI asks how you want to authenticate. Generate an API key from Settings > API keys if you pick the paste path:

💻 Let's add a Baseten remote!
How would you like to authenticate?
  Paste an API key
  Log in via browser (OAuth)
🤫 Quietly paste your API_KEY:

Skip the picker with --browser or --api-key:

uvx truss login --browser
uvx truss login --api-key "paste-your-api-key-here"

BASETEN_API_KEY is what the OpenAI client uses later to call the model. It does not skip truss login.

Create a Truss project

Scaffold a new project:

uvx truss init qwen-2.5-3b && cd qwen-2.5-3b

When prompted, name the model Qwen 2.5 3B.

? 📦 Name this model: Qwen 2.5 3B
Truss Qwen 2.5 3B was created in ~/qwen-2.5-3b

This creates a directory with a config.yaml, a model/ directory, and supporting files. For engine-based deployments like this one, you only need config.yaml. The model/ directory is for custom Python code when you need custom preprocessing, postprocessing, or unsupported model architectures.

Write the config

Replace the contents of config.yaml with:

model_metadata:
  tags:
    - openai-compatible
model_name: Qwen-2.5-3B
resources:
  accelerator: L4
  use_gpu: true
trt_llm:
  build:
    base_model: decoder
    checkpoint_repository:
      source: HF
      repo: "Qwen/Qwen2.5-3B-Instruct"
    max_seq_len: 8192
    quantization_type: fp8
    tensor_parallel_count: 1
    num_builder_gpus: 2

That's the entire deployment specification.

  • model_name identifies the model in your Baseten dashboard.
  • resources selects an L4 GPU (24 GB VRAM), which is plenty for a 3B parameter model.
  • trt_llm tells Baseten to use Engine-Builder-LLM, which compiles the model with TensorRT-LLM for optimized inference.
  • checkpoint_repository points to the model weights on Hugging Face. Qwen 2.5 3B Instruct is ungated, so no access token is needed.
  • quantization_type: fp8 compresses weights to 8-bit floating point, cutting memory usage roughly in half with negligible quality loss.
  • max_seq_len: 8192 sets the maximum context length for requests.
  • num_builder_gpus: 2 uses two GPUs during the build phase. FP8 quantization needs more GPU memory at compile time than at inference. The first-model guide says a single L4 can run out of memory during compilation without this.

Deploy

Push the model to Baseten. A default push is a published deployment. --watch (development mode with live reload) is not supported for TRT-LLM. For custom Python models, see Customize a model.

uvx truss push

You should see:

Deploying as a published deployment. Use --watch for a development deployment.

✨ Model Qwen 2.5 3B was successfully pushed ✨

   Model ID:      abc1d2ef
   Deployment ID: xyz123
   Endpoint:      https://model-abc1d2ef.api.baseten.co
   Logs:          https://app.baseten.co/models/abc1d2ef/logs/xyz123

You'll need the model ID to call the model's API. You can also find it in your Baseten dashboard.

Baseten now downloads the model weights from Hugging Face, compiles them with TensorRT-LLM, and deploys the resulting container to an L4 GPU. You can watch progress in the logs linked above.

Call the model

Engine-based deployments serve an OpenAI-compatible API. Once the deployment shows "Active" in the dashboard, call it using the OpenAI SDK or cURL. Replace {model_id} with your model ID from the deployment output.

Install the OpenAI SDK if you don't have it, and export the API key the client will send:

uv pip install openai
export BASETEN_API_KEY="paste-your-api-key-here"

Create a chat completion:

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["BASETEN_API_KEY"],
    base_url="https://model-{model_id}.api.baseten.co/environments/production/sync/v1",
)

response = client.chat.completions.create(
    model="Qwen-2.5-3B",
    messages=[
        {"role": "user", "content": "What is machine learning?"}
    ],
)

print(response.choices[0].message.content)

You should see a response like:

Machine learning is a branch of artificial intelligence where systems learn
patterns from data to make predictions or decisions without being explicitly
programmed for each task...

Any code that works with the OpenAI SDK works with your deployment. Just point the base_url at your model's endpoint.

Your model ID is the string after /models/ in the logs URL from uvx truss push. You can also find it in your Baseten dashboard.

IDE support

Truss ships a JSON schema for config.yaml. Projects created with truss init include a schema reference automatically, giving you autocompletion, hover docs, and validation in any editor that supports the YAML language server (VS Code, JetBrains, Neovim, and others).

To add schema support to an existing config.yaml, add this comment as the first line:

# yaml-language-server: $schema=https://raw.githubusercontent.com/basetenlabs/truss/main/truss/config.schema.json

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

truss-0.18.30rc0.tar.gz (633.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

truss-0.18.30rc0-py3-none-any.whl (757.1 kB view details)

Uploaded Python 3

File details

Details for the file truss-0.18.30rc0.tar.gz.

File metadata

  • Download URL: truss-0.18.30rc0.tar.gz
  • Upload date:
  • Size: 633.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for truss-0.18.30rc0.tar.gz
Algorithm Hash digest
SHA256 5fc19b7db305055b6212c5273cf6b354fe78e128988e70b7a170bc23b75ec7fd
MD5 5f9ec6fce406edc6aaee3eade845242c
BLAKE2b-256 ebd1cb3835d66e551187e7cdbc93971f52555e48889227d668dc8c414115f7bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for truss-0.18.30rc0.tar.gz:

Publisher: main.yml on basetenlabs/truss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file truss-0.18.30rc0-py3-none-any.whl.

File metadata

  • Download URL: truss-0.18.30rc0-py3-none-any.whl
  • Upload date:
  • Size: 757.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for truss-0.18.30rc0-py3-none-any.whl
Algorithm Hash digest
SHA256 93257cdbe8289cf34541d9f9a6b2a94a9384d931654bbe8e9b890b289d13a31a
MD5 2aef48e03e135de2207ecaeef5507ac1
BLAKE2b-256 69575b514496d76591db9bd800d47ae771d82fe8f152672776f5554211bde0e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for truss-0.18.30rc0-py3-none-any.whl:

Publisher: main.yml on basetenlabs/truss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.60.0

2 files

This release

0.18.30rc0 This release

2 files

0.18.29

2 files

0.18.28

2 files

0.18.27

2 files

0.18.26

2 files

0.18.25

2 files

0.18.24

2 files

0.18.23

2 files

0.18.22

2 files

0.18.21

2 files

0.18.20

2 files

0.18.19

2 files

0.18.18

2 files

0.18.17

2 files

0.18.16

2 files

0.18.15

2 files

0.18.14

2 files

0.18.13

2 files

0.18.12

2 files

0.18.11

2 files

0.18.10

2 files

0.18.9

2 files

0.18.8

2 files

0.18.7

2 files

0.18.6

2 files

0.18.5

2 files

0.18.4

2 files

0.18.3

2 files

0.18.2

2 files

0.18.1

2 files

0.18.0

2 files

0.17.2

2 files

0.17.1

2 files

0.17.0

2 files

0.16.2

2 files

0.16.1

2 files

0.16.0

2 files

0.15.12

2 files

0.15.11

2 files

0.15.10

2 files

0.15.9

2 files

0.15.8

2 files

0.15.7

2 files

0.15.6

2 files

0.15.5

2 files

0.15.4

2 files

0.15.3

2 files

0.15.2

2 files

0.15.1

2 files

0.15.0

2 files

0.14.2

2 files

0.14.1

2 files

0.14.0

2 files

0.13.5

2 files

0.13.4

2 files

0.13.3

2 files

0.13.2

2 files

0.13.1

2 files

0.13.0

2 files

0.12.15

2 files

0.12.14

2 files

0.12.13

2 files

0.12.12

2 files

0.12.11

2 files

0.12.10

2 files

0.12.9

2 files

0.12.8

2 files

0.12.7

2 files

0.12.6

2 files

0.12.5

2 files

0.12.4

2 files

0.12.3

2 files

0.12.2

2 files

0.12.1

2 files

0.12.0

2 files

0.11.26

2 files

0.11.25

2 files

0.11.24

2 files

0.11.23

2 files

0.11.22

2 files

0.11.21

2 files

0.11.20

2 files

0.11.19

2 files

0.11.18

2 files

0.11.17

2 files

0.11.16

2 files

0.11.15

2 files

0.11.14

2 files

0.11.13

2 files

0.11.12

2 files

0.11.11

2 files

0.11.10

2 files

0.11.9

2 files

0.11.8

2 files

0.11.7

2 files

0.11.6

2 files

0.11.5

2 files

0.11.4

2 files

0.11.3

2 files

0.11.2

2 files

0.11.1

2 files

0.11.0

2 files

0.10.13

2 files

0.10.12

2 files

0.10.11

2 files

0.10.10

2 files

0.10.9

2 files

0.10.8

2 files

0.10.7

2 files

0.10.6

2 files

0.10.5

2 files

0.10.4

2 files

0.10.3

2 files

0.10.2

2 files

0.10.1

2 files

0.10.0

2 files

0.9.120

2 files

0.9.119

2 files

0.9.118

2 files

0.9.117

2 files

0.9.116

2 files

0.9.115

2 files

0.9.114

2 files

0.9.113

2 files

0.9.112

2 files

0.9.111

2 files

0.9.110

2 files

0.9.109

2 files

0.9.108

2 files

0.9.107

2 files

0.9.106

2 files

0.9.105

2 files

0.9.104

2 files

0.9.103

2 files

0.9.102

2 files

0.9.101

2 files

0.9.100

2 files

0.9.98

2 files

0.9.97

2 files

0.9.96

2 files

0.9.95

2 files

0.9.94

2 files

0.9.93

2 files

0.9.92

2 files

0.9.91

2 files

0.9.90

2 files

0.9.89

2 files

0.9.88

2 files

0.9.87

2 files

0.9.86

2 files

0.9.85

2 files

0.9.84

2 files

0.9.83

2 files

0.9.82

2 files

0.9.81

2 files

0.9.80

2 files

0.9.79

2 files

0.9.78

2 files

0.9.77

2 files

0.9.76

2 files

0.9.75

2 files

0.9.74

2 files

0.9.73

2 files

0.9.72

2 files

0.9.71

2 files

0.9.70

2 files

0.9.69

2 files

0.9.68

2 files

0.9.67

2 files

0.9.66

2 files

0.9.65

2 files

0.9.64

2 files

0.9.63

2 files

0.9.62

2 files

0.9.60

2 files

0.9.59

2 files

0.9.59rc15

2 files

0.9.58

2 files

0.9.57

2 files

0.9.56

2 files

0.9.55

2 files

0.9.53

2 files

0.9.51

2 files

0.9.50

2 files

0.9.49

2 files

0.9.48

2 files

0.9.47

2 files

0.9.46

2 files

0.9.45

2 files

0.9.44

2 files

0.9.43

2 files

0.9.42

2 files

0.9.41

2 files

0.9.40

2 files

0.9.39

2 files

0.9.38

2 files

0.9.37

2 files

0.9.36

2 files

0.9.35

2 files

0.9.34

2 files

0.9.33

2 files

0.9.32

2 files

0.9.31

2 files

0.9.30

2 files

0.9.29

2 files

0.9.28

2 files

0.9.27

2 files

0.9.26

2 files

0.9.25

2 files

0.9.24

2 files

0.9.23

2 files

0.9.22

2 files

0.9.21

2 files

0.9.20

2 files

0.9.19

2 files

0.9.18

2 files

0.9.17

2 files

0.9.16

2 files

0.9.15

2 files

0.9.14

2 files

0.9.13

2 files

0.9.12

2 files

0.9.11

2 files

0.9.10

2 files

0.9.9

2 files

0.9.8

2 files

0.9.7

2 files

0.9.6

2 files

0.9.5

2 files

0.9.4

2 files

0.9.3

2 files

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

0.8.2

2 files

0.8.1

2 files

0.8.0rc0

2 files

0.7.23

2 files

0.7.22

2 files

0.7.21

2 files

0.7.20

2 files

0.7.19

2 files

0.7.18

2 files

0.7.17

2 files

0.7.16

2 files

0.7.15

2 files

0.7.14

2 files

0.7.13

2 files

0.7.12

2 files

0.7.11

2 files

0.7.9

2 files

0.7.8

2 files

0.7.7

2 files

0.7.6

2 files

0.7.5

2 files

0.7.4

2 files

0.7.3

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.4

2 files

0.6.3

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.8

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.9

2 files

0.4.8

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.0

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.1

2 files

0.1.0

2 files

0.0.33

2 files

0.0.32

2 files

0.0.31

2 files

0.0.30

2 files

0.0.29

2 files

0.0.28

2 files

0.0.27

2 files

0.0.26

2 files

0.0.25

2 files

0.0.24

2 files

0.0.23

2 files

0.0.22

2 files

0.0.20

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page